{t.intro.title}
{t.intro.description}
120
{t.intro.userProfile}
14
{t.intro.matches}
14
{t.intro.marriage}
"use client"; import Image from "next/image"; import { useEffect, useState } from "react"; import { useRouter } from "next/navigation"; import Button from "@/components/ui/button"; import NavigationButton from "@/components/ui/navigation-button"; import ReportActionsSheet from "@/components/ui/report-actions-sheet"; import { authBridge } from "@/lib/auth-bridge"; import { useMarriageProfileQuery } from "@/hooks/marriage/use-profile-main"; import type { MarriageProfileResponse } from "@/hooks/marriage/types"; import { localizePath } from "@/i18n/config"; import { useI18n } from "@/i18n/provider"; const REDIRECT_SESSION_KEY = "redirect"; function getSubmitPath(profile: MarriageProfileResponse | undefined) { const isInCase = profile?.status === "in_case"; const isFemaleAcceptedFlow = isInCase && (profile?.active_case?.status === "payment_pending" || profile?.active_case?.status === "female_accepted" || profile?.active_case?.status === "payment_done"); return isFemaleAcceptedFlow ? "/request-accepted" : isInCase && profile?.active_case?.status === "male_accepted" ? "/request-sent" : profile?.status === "pending_onboarding" ? "/terms" : profile?.status === "pending_info" ? "/questions-list" : profile?.status === "waiting" ? "/finding-match" : profile?.status === "in_case" || profile?.status === "matched" ? "/new-match" : "/terms"; } export default function Intro() { const router = useRouter(); const { dictionary: t, locale } = useI18n(); const { data: profile, refetch } = useMarriageProfileQuery({ enabled: false, retry: false, }); const [isReportSheetOpen, setIsReportSheetOpen] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false); const [isCheckingRedirect, setIsCheckingRedirect] = useState(true); useEffect(() => { let isCancelled = false; const redirectIfNeeded = async () => { const shouldRedirect = authBridge.isAuthenticated() && window.sessionStorage.getItem(REDIRECT_SESSION_KEY) === "true"; if (!shouldRedirect) { if (!isCancelled) { setIsCheckingRedirect(false); } return; } const profileResponse = profile ?? (await refetch()).data; const nextPath = localizePath(getSubmitPath(profileResponse), locale); window.sessionStorage.removeItem(REDIRECT_SESSION_KEY); if (!isCancelled) { router.replace(nextPath); } }; void redirectIfNeeded(); return () => { isCancelled = true; }; }, [locale, profile, refetch, router]); const handleSubmit = async () => { if (isSubmitting) { return; } setIsSubmitting(true); try { if (!authBridge.isAuthenticated()) { const token = await authBridge.ensureToken(); if (!token) { return; } } } finally { setIsSubmitting(false); } }; if (isCheckingRedirect) { return null; } return (
{t.intro.description}
120
{t.intro.userProfile}
14
{t.intro.matches}
14
{t.intro.marriage}