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; const isLoading = !profileProp && isQueryLoading;
useEffect(() => { useEffect(() => {
if (!profile) {
// If rendered as an overlay (onClose is passed), NEVER redirect away from current page
if (!profile || Boolean(onClose)) {
return; return;
} }
const targetPath = getSubmitPath(profile); const targetPath = getSubmitPath(profile);
const caseStatus = profile?.active_case?.status; const caseStatus = profile?.active_case?.status;
const isProfileMatched = profile?.status === "matched"; const isProfileMatched = profile?.status === "matched";
const isViewingAllowed = const isViewingAllowed =
caseStatus === "female_accepted" ||
caseStatus === "payment_pending" ||
caseStatus === "payment_done" || caseStatus === "payment_done" ||
caseStatus === "contacted" || caseStatus === "contacted" ||
caseStatus === "finalized" || caseStatus === "finalized" ||
@ -289,11 +292,12 @@ export default function NewMatchProfilePage({
if ( if (
targetPath !== "/new-match" && targetPath !== "/new-match" &&
targetPath !== "/request-sent" && targetPath !== "/request-sent" &&
targetPath !== "/request-accepted" &&
!isViewingAllowed !isViewingAllowed
) { ) {
router.replace(localizePath(targetPath, locale)); router.replace(localizePath(targetPath, locale));
} }
}, [profile, locale, router]);
}, [profile, locale, router, onClose]);
const caseId = profile?.active_case?.case_id; const caseId = profile?.active_case?.case_id;
const caseStatus = profile?.active_case?.status; 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 // Signal Flutter to lift its loading cover immediately on mount
useHabibWebReady(true); useHabibWebReady(true);
const handleOpenProfile = async () => {
if (!isFetched || isFetching) {
setIsOpeningProfile(true);
try {
await refetchProfile();
} finally {
setIsOpeningProfile(false);
const handleOpenProfile = () => {
openProfile(); openProfile();
if (!isFetched || isFetching) {
refetchProfile().catch(() => {});
} }
return;
}
openProfile();
}; };
const isRedirecting = useMemo(() => { const isRedirecting = useMemo(() => {
@ -411,11 +404,6 @@ export default function RequestAcceptedClient() {
return; return;
} }
if (caseStatus === "female_accepted" || caseStatus === "payment_pending") {
setIsSubscriptionSheetOpen(true);
return;
}
if (caseStatus === "payment_done" || caseStatus === "contacted") { if (caseStatus === "payment_done" || caseStatus === "contacted") {
if (!caseId) { if (!caseId) {
return; return;
@ -433,7 +421,11 @@ export default function RequestAcceptedClient() {
setIsFetchingContact(false); setIsFetchingContact(false);
} }
} }
return;
} }
// Always fallback to opening subscription/payment sheet for any pending or introduced match
setIsSubscriptionSheetOpen(true);
}; };
const handlePayment = async () => { const handlePayment = async () => {
@ -658,7 +650,7 @@ export default function RequestAcceptedClient() {
}} }}
planId={recommendedPlanId} planId={recommendedPlanId}
onPayment={handlePayment} onPayment={handlePayment}
isPaymentPending={!recommendedPlanId || paymentMutation.isPending}
isPaymentPending={paymentMutation.isPending}
errorMessage={paymentError} errorMessage={paymentError}
showBuyCoins={isInsufficientCoins} showBuyCoins={isInsufficientCoins}
/> />
@ -934,27 +926,13 @@ export default function RequestAcceptedClient() {
paymentMutation.isPending || paymentMutation.isPending ||
isFetchingContact 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 ? ( {paymentMutation.isPending || isFetchingContact ? (
<LoadingThreeDot className="text-white" /> <LoadingThreeDot className="text-white" />
) : ( ) : (
secondaryActionText secondaryActionText
)} )}
</div>
)}
</button> </button>
</div> </div>
</div> </div>

Loading…
Cancel
Save