diff --git a/src/app/candidate-contact/page.tsx b/src/app/candidate-contact/page.tsx index 354d77b..471c638 100644 --- a/src/app/candidate-contact/page.tsx +++ b/src/app/candidate-contact/page.tsx @@ -28,8 +28,8 @@ export default function CandidateContactPage() { /> ) : null} -
-
+
+

{t.common.appName}

diff --git a/src/app/finding-match/page.tsx b/src/app/finding-match/page.tsx index ec14a99..fe0ae51 100644 --- a/src/app/finding-match/page.tsx +++ b/src/app/finding-match/page.tsx @@ -6,9 +6,12 @@ import { FaPen } from "react-icons/fa6"; import AdvisorActionsCard from "@/components/ui/advisor-actions-card"; import NavigationButton from "@/components/ui/navigation-button"; import { PageBackground } from "@/components/utils/page-background"; +import { useEffect } from "react"; +import { useRouter } from "next/navigation"; import { useMarriageProfileQuery } from "@/hooks/marriage/use-profile-main"; import { localizePath } from "@/translations/config"; import { useI18n } from "@/translations/provider"; +import { getSubmitPath } from "@/lib/get-submit-path"; const advisorAvatars = [ { id: "advisor-primary", src: "/assets/images/Avatar Image.png" }, @@ -17,8 +20,22 @@ const advisorAvatars = [ ]; export default function FindingMatchPage() { + const router = useRouter(); const { dictionary: t, locale } = useI18n(); - const { data: profile } = useMarriageProfileQuery(); + const { data: profile } = useMarriageProfileQuery({ + refetchInterval: 3000, + }); + + useEffect(() => { + if (!profile) { + return; + } + const targetPath = getSubmitPath(profile); + if (targetPath !== "/finding-match") { + router.replace(localizePath(targetPath, locale)); + } + }, [profile, locale, router]); + const copy = t.findingMatch; const matchImageSrc = profile?.gender === "female" @@ -31,9 +48,9 @@ export default function FindingMatchPage() {
-
+

{t.common.appName}

diff --git a/src/app/intro/page.tsx b/src/app/intro/page.tsx index bc43b78..03d257c 100644 --- a/src/app/intro/page.tsx +++ b/src/app/intro/page.tsx @@ -11,36 +11,10 @@ import { useMarriageProfileQuery } from "@/hooks/marriage/use-profile-main"; import type { MarriageProfileResponse } from "@/hooks/marriage/types"; import { localizePath } from "@/translations/config"; import { useI18n } from "@/translations/provider"; +import { getSubmitPath } from "@/lib/get-submit-path"; const REDIRECT_SESSION_KEY = "redirect"; -function getSubmitPath(profile: MarriageProfileResponse | undefined) { - const isMatchSubmitted = - typeof window !== "undefined" && - localStorage.getItem("match_submitted") === "true"; - - 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" && !isMatchSubmitted - ? "/questions-list" - : profile?.status === "waiting" || isMatchSubmitted - ? "/finding-match" - : profile?.status === "in_case" || profile?.status === "matched" - ? "/new-match" - : "/terms"; -} - export default function Intro() { const router = useRouter(); const { dictionary: t, locale } = useI18n(); @@ -142,11 +116,11 @@ export default function Intro() { } return ( -
+
{isReportSheetOpen && ( setIsReportSheetOpen(false)} /> )} -
+

{t.common.appName}

-
+

{t.common.appName}

diff --git a/src/app/new-match/profile/page.tsx b/src/app/new-match/profile/page.tsx index a6090ae..a48e0a3 100644 --- a/src/app/new-match/profile/page.tsx +++ b/src/app/new-match/profile/page.tsx @@ -2,7 +2,7 @@ import Image from "next/image"; import { useRouter } from "next/navigation"; -import { useState } from "react"; +import { useMemo, useState } from "react"; import Button from "@/components/ui/button"; import DismissReasonSheet from "@/components/ui/dismiss-reason-sheet"; import FemaleConsentSheet from "@/components/ui/female-consent-sheet"; @@ -93,9 +93,51 @@ function MatchField({ field }: { field: MarriageField }) { const label = field.label || titleFromKey(field.key); return ( -
-

{label}

-

{value}

+
+

{label}

+

{value}

+
+ ); +} + +function MatchPublicProfileFields({ + publicInfo, +}: { + publicInfo: MarriageField[] | null | undefined; +}) { + const visibleFields = useMemo(() => { + if (!publicInfo) return []; + return publicInfo.filter((field) => { + if (field.value === null || field.value === "" || isImageField(field)) { + return false; + } + if ((field as any).private === true) { + return false; + } + return true; + }); + }, [publicInfo]); + + if (!visibleFields.length) { + return ( +
+

+ اطلاعات عمومی قابل نمایشی ثبت نشده است. +

+
+ ); + } + + return ( +
+

+ اطلاعات عمومی و مشخصات فردی +

+
+ {visibleFields.map((field) => ( + + ))} +
); } @@ -117,17 +159,32 @@ export default function NewMatchProfilePage() { onSuccess: async (_, variables) => { if (variables.action === "accept") { if (isFemaleProfile) { - router.push(localizePath("/request-accepted", locale)); + router.replace(localizePath("/request-accepted", locale)); } else { - router.push(localizePath("/request-sent", locale)); + router.replace(localizePath("/request-sent", locale)); } return; } - router.push(localizePath("/finding-match", locale)); + router.replace(localizePath("/finding-match", locale)); }, }); + const candidateName = useMemo(() => { + const publicInfo = profile?.match_summary?.public_info ?? []; + const nameField = publicInfo.find( + (f) => + f.key === "q1_full_name" || + f.key.toLowerCase().includes("name") || + f.key.toLowerCase().includes("nam") || + f.label.includes("نام"), + ); + const formatted = formatFieldValue(nameField?.value ?? null); + if (formatted) return formatted; + const firstVal = publicInfo.find((f) => Boolean(f.value))?.value ?? null; + return formatFieldValue(firstVal) || "نامشخص"; + }, [profile?.match_summary?.public_info]); + const isSubmitting = respondMutation.isPending; const isAcceptProfileEnabled = Boolean(caseId) && @@ -280,16 +337,16 @@ export default function NewMatchProfilePage() {
-
+
-

+

{t.match.title}

-
+
@@ -307,27 +364,17 @@ export default function NewMatchProfilePage() { className="text-[25px] leading-none text-white/80" style={{ letterSpacing: "-2.3px", fontWeight: "1000" }} > - {formatFieldValue( - profile?.match_summary?.public_info.find( - (field) => field.key === "q1_full_name", - )?.value ?? null, - ) || "Name not available"} + {candidateName}

- {formatFieldValue( - profile?.match_summary?.public_info.find( - (field) => field.key === "q1_full_name", - )?.value ?? null, - ) || "Name not available"} + {candidateName}

-
- {profile?.match_summary?.public_info.map((field) => ( - - ))} -
+
letter.toUpperCase()); -} - -function formatContactLabel(field: MarriageField) { - const resolvedLabel = (field.label || titleFromKey(field.key)).trim(); - - return resolvedLabel.replace(/\s+Number$/i, "").trim(); -} - -function getContactInfoPhoneItems(fields: MarriageField[] | null | undefined) { - return (fields ?? []).flatMap((field) => { - if (field.type.toLowerCase() !== "phone") { - return []; - } +function getContactInfoPhoneItems( + contactInfoFields: MarriageField[] | null | undefined, +): ContactInfoPhoneItem[] { + if (!contactInfoFields) { + return []; + } - const phoneNumber = sanitizePhoneNumber(field.value); + return contactInfoFields + .map((field) => { + const phoneNumber = sanitizePhoneNumber(field.value); - if (!phoneNumber) { - return []; - } + if (!phoneNumber) { + return null; + } - return [ - { + return { key: field.key, - label: formatContactLabel(field), + label: field.label || field.key, phoneNumber, - }, - ]; - }); + }; + }) + .filter((item): item is ContactInfoPhoneItem => item !== null); } function ContactInfoPhoneCard({ item }: { item: ContactInfoPhoneItem }) { return ( -
-
-

- {item.phoneNumber} -

-

- {item.label} -

+
+
+

{item.label}

+

{item.phoneNumber}

-
+