Browse Source

fix(request-accepted): resolve overlay dismissal route guard and secondary action sheet triggers on mobile

staging
Muhammad A. Ghorbani 2 weeks ago
parent
commit
48335e518f
  1. 8
      src/app/new-match/profile/page.tsx
  2. 40
      src/app/request-accepted/request-accepted-client.tsx

8
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;

40
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 () => {
if (!isFetched || isFetching) {
setIsOpeningProfile(true);
try {
await refetchProfile();
} finally {
setIsOpeningProfile(false);
const handleOpenProfile = () => {
openProfile();
if (!isFetched || isFetching) {
refetchProfile().catch(() => {});
}
return;
}
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,27 +926,13 @@ 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 ? (
<LoadingThreeDot className="text-white" />
) : (
secondaryActionText
)
) : (
<div className="w-full h-full 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 hover:opacity-95 active:shadow-inner">
{paymentMutation.isPending || isFetchingContact ? (
<LoadingThreeDot className="text-white" />
) : (
secondaryActionText
)}
</div>
)}
</button>
</div>
</div>

Loading…
Cancel
Save