From 8708d0dc36658887ba7a4b4bc835723ef9cc8836 Mon Sep 17 00:00:00 2001 From: mortezaei Date: Sun, 30 Aug 2026 07:24:34 +0330 Subject: [PATCH] feat: add debug logging to profile redirection and initial data synchronization flows --- src/app/finding-match/finding-match-client.tsx | 9 +++++++++ src/app/new-match/new-match-client.tsx | 2 ++ src/hooks/marriage/use-profile-main.ts | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/src/app/finding-match/finding-match-client.tsx b/src/app/finding-match/finding-match-client.tsx index 2d7b85f..4b44acb 100644 --- a/src/app/finding-match/finding-match-client.tsx +++ b/src/app/finding-match/finding-match-client.tsx @@ -47,11 +47,20 @@ export default function FindingMatchClient() { }); useEffect(() => { + console.log("🔍 [FindingMatchClient] State Evaluation:", { + hasProfile: Boolean(profile), + isFetched, + status: profile?.status, + active_case: profile?.active_case, + calculatedPath: profile ? getSubmitPath(profile) : null, + }); if (!profile || !isFetched) { + console.log("⏳ [FindingMatchClient] Skipping redirect because !profile or !isFetched (isFetched=", isFetched, ")"); return; } const targetPath = getSubmitPath(profile); if (targetPath !== "/finding-match") { + console.log("🚀 [FindingMatchClient] Redirecting to:", targetPath); router.replace(localizePath(targetPath, locale)); } }, [profile, isFetched, locale, router]); diff --git a/src/app/new-match/new-match-client.tsx b/src/app/new-match/new-match-client.tsx index 4db945e..dc11c76 100644 --- a/src/app/new-match/new-match-client.tsx +++ b/src/app/new-match/new-match-client.tsx @@ -598,10 +598,12 @@ export default function NewMatchClient() { }); if (!profile || !isFetched) { + console.log("⏳ [NewMatchClient] Skipping redirect because !profile or !isFetched (isFetched=", isFetched, ")"); return; } const targetPath = getSubmitPath(profile); if (targetPath !== "/new-match") { + console.log("🚀 [NewMatchClient] Redirecting to:", targetPath); router.replace(localizePath(targetPath, locale)); } }, [profile, locale, router, isFetched]); diff --git a/src/hooks/marriage/use-profile-main.ts b/src/hooks/marriage/use-profile-main.ts index abf433b..0c5725c 100644 --- a/src/hooks/marriage/use-profile-main.ts +++ b/src/hooks/marriage/use-profile-main.ts @@ -75,8 +75,13 @@ export function useMarriageProfileQuery( const handleInitialData = (e: Event) => { const customEvent = e as CustomEvent; const initial = getInitialMarriageProfile(); + console.log("📥 [Profile Query] Received habib:marriage-initial-data event:", { + detail: customEvent.detail, + parsedInitial: initial, + }); if (initial) { queryClient.setQueryData(marriageQueryKeys.profile(), (old: any) => { + console.log("🔄 [Profile Query] Merging initialData into QueryCache. Old:", old, "New Initial:", initial); if (!old) return initial; return { ...initial,