From 48335e518f2d1cb37e9ccebc9ec77b2424263bda Mon Sep 17 00:00:00 2001 From: "Muhammad A. Ghorbani" Date: Sat, 5 Sep 2026 20:17:04 +0330 Subject: [PATCH] fix(request-accepted): resolve overlay dismissal route guard and secondary action sheet triggers on mobile --- src/app/new-match/profile/page.tsx | 8 +++- .../request-accepted-client.tsx | 46 +++++-------------- 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/src/app/new-match/profile/page.tsx b/src/app/new-match/profile/page.tsx index aa2d8e9..e201c7b 100644 --- a/src/app/new-match/profile/page.tsx +++ b/src/app/new-match/profile/page.tsx @@ -274,13 +274,16 @@ export default function NewMatchProfilePage({ const isLoading = !profileProp && isQueryLoading; useEffect(() => { - if (!profile) { + // If rendered as an overlay (onClose is passed), NEVER redirect away from current page + if (!profile || Boolean(onClose)) { return; } const targetPath = getSubmitPath(profile); const caseStatus = profile?.active_case?.status; const isProfileMatched = profile?.status === "matched"; const isViewingAllowed = + caseStatus === "female_accepted" || + caseStatus === "payment_pending" || caseStatus === "payment_done" || caseStatus === "contacted" || caseStatus === "finalized" || @@ -289,11 +292,12 @@ export default function NewMatchProfilePage({ if ( targetPath !== "/new-match" && targetPath !== "/request-sent" && + targetPath !== "/request-accepted" && !isViewingAllowed ) { router.replace(localizePath(targetPath, locale)); } - }, [profile, locale, router]); + }, [profile, locale, router, onClose]); const caseId = profile?.active_case?.case_id; const caseStatus = profile?.active_case?.status; diff --git a/src/app/request-accepted/request-accepted-client.tsx b/src/app/request-accepted/request-accepted-client.tsx index 5ca24eb..4133fb2 100644 --- a/src/app/request-accepted/request-accepted-client.tsx +++ b/src/app/request-accepted/request-accepted-client.tsx @@ -326,18 +326,11 @@ export default function RequestAcceptedClient() { // Signal Flutter to lift its loading cover immediately on mount useHabibWebReady(true); - const handleOpenProfile = async () => { + const handleOpenProfile = () => { + openProfile(); if (!isFetched || isFetching) { - setIsOpeningProfile(true); - try { - await refetchProfile(); - } finally { - setIsOpeningProfile(false); - openProfile(); - } - return; + refetchProfile().catch(() => {}); } - openProfile(); }; const isRedirecting = useMemo(() => { @@ -411,11 +404,6 @@ export default function RequestAcceptedClient() { return; } - if (caseStatus === "female_accepted" || caseStatus === "payment_pending") { - setIsSubscriptionSheetOpen(true); - return; - } - if (caseStatus === "payment_done" || caseStatus === "contacted") { if (!caseId) { return; @@ -433,7 +421,11 @@ export default function RequestAcceptedClient() { setIsFetchingContact(false); } } + return; } + + // Always fallback to opening subscription/payment sheet for any pending or introduced match + setIsSubscriptionSheetOpen(true); }; const handlePayment = async () => { @@ -658,7 +650,7 @@ export default function RequestAcceptedClient() { }} planId={recommendedPlanId} onPayment={handlePayment} - isPaymentPending={!recommendedPlanId || paymentMutation.isPending} + isPaymentPending={paymentMutation.isPending} errorMessage={paymentError} showBuyCoins={isInsufficientCoins} /> @@ -934,26 +926,12 @@ export default function RequestAcceptedClient() { paymentMutation.isPending || isFetchingContact } - className={ - isFemaleProfile - ? "flex-1 min-h-[48px] px-3.5 py-2.5 rounded-[14px] bg-gradient-to-r from-[#FF6687] to-[#FF456C] text-white font-bold text-[13.5px] leading-tight flex items-center justify-center text-center whitespace-nowrap shadow-sm transition-all duration-150 cursor-pointer hover:opacity-95 active:scale-[0.96] disabled:opacity-50 disabled:cursor-not-allowed" - : "flex-1 min-h-[48px] appearance-none border-0 bg-transparent p-0 text-center cursor-pointer transition-transform duration-150 active:scale-[0.96] disabled:opacity-50 disabled:cursor-not-allowed" - } + className="flex-1 min-h-[48px] px-3.5 py-2.5 rounded-[14px] bg-gradient-to-r from-[#FF6687] to-[#FF456C] text-white font-bold text-[14px] leading-tight flex items-center justify-center text-center whitespace-nowrap shadow-sm transition-transform duration-150 active:scale-[0.96] cursor-pointer hover:opacity-95 disabled:opacity-50 disabled:cursor-not-allowed" > - {isFemaleProfile ? ( - paymentMutation.isPending ? ( - - ) : ( - secondaryActionText - ) + {paymentMutation.isPending || isFetchingContact ? ( + ) : ( -
- {paymentMutation.isPending || isFetchingContact ? ( - - ) : ( - secondaryActionText - )} -
+ secondaryActionText )}