From 63d82299e20d64355729fd373ae33d2c210a6e06 Mon Sep 17 00:00:00 2001 From: mortezaei Date: Wed, 19 Aug 2026 14:24:46 +0330 Subject: [PATCH] refactor: improve candidate name resolution and enhance SSR fetch logging with dynamic timeouts --- src/app/new-match/profile/page.tsx | 36 +++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/app/new-match/profile/page.tsx b/src/app/new-match/profile/page.tsx index 1731deb..84031f9 100644 --- a/src/app/new-match/profile/page.tsx +++ b/src/app/new-match/profile/page.tsx @@ -404,18 +404,44 @@ export default function NewMatchProfilePage({ const candidateName = useMemo(() => { const publicInfo = profile?.match_summary?.public_info ?? []; + const firstNameIdx = publicInfo.findIndex( + (f) => + f.key === "personal_identity.first_name" || + f.key?.endsWith(".first_name"), + ); + const lastNameIdx = publicInfo.findIndex( + (f) => + f.key === "personal_identity.last_name" || + f.key?.endsWith(".last_name"), + ); + + if (firstNameIdx !== -1 && publicInfo[firstNameIdx].value) { + const firstName = formatFieldValue(publicInfo[firstNameIdx].value); + if (lastNameIdx !== -1 && publicInfo[lastNameIdx].value) { + const lastName = formatFieldValue(publicInfo[lastNameIdx].value); + return `${firstName} ${lastName}`.trim(); + } + return firstName || ""; + } + const nameField = publicInfo.find( (f) => f.key === "q1_full_name" || - f.key.toLowerCase().includes("name") || - f.key.toLowerCase().includes("nam") || - f.label.includes("نام"), + f.key.endsWith(".full_name") || + f.key.toLowerCase().includes("fullname") || + f.key.toLowerCase().includes("display_name"), ); 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]); + return ( + formatFieldValue(firstVal) || + (profile?.match_summary?.id + ? `Profile #${profile.match_summary.id}` + : "Profile") + ); + }, [profile?.match_summary]); const isCandidateFemale = profile?.match_summary?.gender === "female" || profile?.gender === "male";