|
|
|
@ -489,7 +489,8 @@ export default function NewMatchClient() { |
|
|
|
useMarriageAdvisorsOverlay(); |
|
|
|
const { isProfileOpen, openProfile, closeProfile } = useMatchProfileOverlay(); |
|
|
|
const [isOpeningProfile, setIsOpeningProfile] = useState(false); |
|
|
|
const { data: profile, isError, isLoading } = useMarriageProfileQuery(); |
|
|
|
const { data: profile, isError, isLoading, isFetched } = |
|
|
|
useMarriageProfileQuery(); |
|
|
|
const [isPaymentSheetOpen, setIsPaymentSheetOpen] = useState(false); |
|
|
|
const [isDeclineConfirmOpen, setIsDeclineConfirmOpen] = useState(false); |
|
|
|
const [paymentError, setPaymentError] = useState<string | null>(null); |
|
|
|
@ -523,8 +524,7 @@ export default function NewMatchClient() { |
|
|
|
}); |
|
|
|
|
|
|
|
const handlePayment = async () => { |
|
|
|
const recommendedPlanId = profile?.recommended_plan?.id; |
|
|
|
if (!recommendedPlanId) return; |
|
|
|
const recommendedPlanId = profile?.recommended_plan?.id ?? 1; |
|
|
|
|
|
|
|
try { |
|
|
|
setPaymentError(null); |
|
|
|
@ -539,9 +539,13 @@ export default function NewMatchClient() { |
|
|
|
} catch (err: any) { |
|
|
|
console.error("Payment failed", err); |
|
|
|
const msg = |
|
|
|
err?.response?.data?.error || err?.message || "Payment failed"; |
|
|
|
err?.response?.data?.error || |
|
|
|
err?.response?.data?.detail || |
|
|
|
err?.response?.data?.message || |
|
|
|
err?.message || |
|
|
|
"Payment failed"; |
|
|
|
const modalT = (t as any).paymentModal || {}; |
|
|
|
if (msg === "Not enough coins") { |
|
|
|
if (msg === "Not enough coins" || msg?.includes?.("Not enough coins")) { |
|
|
|
setIsInsufficientCoins(true); |
|
|
|
setPaymentError( |
|
|
|
modalT.insufficientCoins || |
|
|
|
@ -575,6 +579,7 @@ export default function NewMatchClient() { |
|
|
|
useEffect(() => { |
|
|
|
console.log("🔍 [NewMatchClient] Current React Query Profile State:", { |
|
|
|
isLoading, |
|
|
|
isFetched, |
|
|
|
isError, |
|
|
|
hasProfile: Boolean(profile), |
|
|
|
profileId: profile?.id, |
|
|
|
@ -589,11 +594,16 @@ export default function NewMatchClient() { |
|
|
|
if (!profile) { |
|
|
|
return; |
|
|
|
} |
|
|
|
// Don't redirect based on stale native-injected initialData that may be
|
|
|
|
// missing active_case; wait for the first real server response.
|
|
|
|
if (!isFetched && profile.status === "in_case" && !profile.active_case) { |
|
|
|
return; |
|
|
|
} |
|
|
|
const targetPath = getSubmitPath(profile); |
|
|
|
if (targetPath !== "/new-match") { |
|
|
|
router.replace(localizePath(targetPath, locale)); |
|
|
|
} |
|
|
|
}, [profile, locale, router, isLoading, isError]); |
|
|
|
}, [profile, locale, router, isLoading, isFetched, isError]); |
|
|
|
|
|
|
|
// Signal Flutter to lift its loading cover immediately with 0ms latency.
|
|
|
|
useHabibWebReady(true); |
|
|
|
|