fix(chat): return directly to paid image
This commit is contained in:
@@ -3,6 +3,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import { BackButton } from "@/app/_components";
|
||||
import { consumePendingChatImageReturn } from "@/app/chat/chat-image-return-session";
|
||||
import { Checkbox, MobileShell } from "@/app/_components/core";
|
||||
import { AppConstants } from "@/core/app_constants";
|
||||
import { PendingPaymentOrderStorage } from "@/data/storage";
|
||||
@@ -157,11 +158,28 @@ export function SubscriptionScreen({
|
||||
payment.isPollingOrder;
|
||||
const canActivate =
|
||||
selectedPlan !== null && payment.agreed && !isPaymentBusy;
|
||||
const backHref = returnTo === "chat" ? ROUTES.chat : ROUTES.sidebar;
|
||||
|
||||
const consumeSubscriptionExitUrl = (): string | null => {
|
||||
const pendingImageReturn = consumePendingChatImageReturn();
|
||||
if (pendingImageReturn) return pendingImageReturn.returnUrl;
|
||||
return null;
|
||||
};
|
||||
|
||||
const handleBackClick = () => {
|
||||
router.replace(
|
||||
consumeSubscriptionExitUrl() ??
|
||||
(returnTo === "chat" ? ROUTES.chat : ROUTES.sidebar),
|
||||
);
|
||||
};
|
||||
|
||||
const finishPaymentSuccessClose = () => {
|
||||
setShowPaymentSuccessDialog(false);
|
||||
paymentDispatch({ type: "PaymentReset" });
|
||||
const pendingExitUrl = consumeSubscriptionExitUrl();
|
||||
if (pendingExitUrl) {
|
||||
router.replace(pendingExitUrl);
|
||||
return;
|
||||
}
|
||||
if (returnTo === "chat") {
|
||||
router.replace(ROUTES.chat);
|
||||
}
|
||||
@@ -219,7 +237,7 @@ export function SubscriptionScreen({
|
||||
<header className={styles.header}>
|
||||
<BackButton
|
||||
className={styles.backSlot}
|
||||
href={backHref}
|
||||
onClick={handleBackClick}
|
||||
variant="soft"
|
||||
/>
|
||||
</header>
|
||||
|
||||
Reference in New Issue
Block a user