Browse Source

feat: add debug logging to profile redirection and initial data synchronization flows

master
mortezaei 2 weeks ago
parent
commit
8708d0dc36
  1. 9
      src/app/finding-match/finding-match-client.tsx
  2. 2
      src/app/new-match/new-match-client.tsx
  3. 5
      src/hooks/marriage/use-profile-main.ts

9
src/app/finding-match/finding-match-client.tsx

@ -47,11 +47,20 @@ export default function FindingMatchClient() {
}); });
useEffect(() => { 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) { if (!profile || !isFetched) {
console.log("⏳ [FindingMatchClient] Skipping redirect because !profile or !isFetched (isFetched=", isFetched, ")");
return; return;
} }
const targetPath = getSubmitPath(profile); const targetPath = getSubmitPath(profile);
if (targetPath !== "/finding-match") { if (targetPath !== "/finding-match") {
console.log("🚀 [FindingMatchClient] Redirecting to:", targetPath);
router.replace(localizePath(targetPath, locale)); router.replace(localizePath(targetPath, locale));
} }
}, [profile, isFetched, locale, router]); }, [profile, isFetched, locale, router]);

2
src/app/new-match/new-match-client.tsx

@ -598,10 +598,12 @@ export default function NewMatchClient() {
}); });
if (!profile || !isFetched) { if (!profile || !isFetched) {
console.log("⏳ [NewMatchClient] Skipping redirect because !profile or !isFetched (isFetched=", isFetched, ")");
return; return;
} }
const targetPath = getSubmitPath(profile); const targetPath = getSubmitPath(profile);
if (targetPath !== "/new-match") { if (targetPath !== "/new-match") {
console.log("🚀 [NewMatchClient] Redirecting to:", targetPath);
router.replace(localizePath(targetPath, locale)); router.replace(localizePath(targetPath, locale));
} }
}, [profile, locale, router, isFetched]); }, [profile, locale, router, isFetched]);

5
src/hooks/marriage/use-profile-main.ts

@ -75,8 +75,13 @@ export function useMarriageProfileQuery<TData = MarriageProfileResponse>(
const handleInitialData = (e: Event) => { const handleInitialData = (e: Event) => {
const customEvent = e as CustomEvent; const customEvent = e as CustomEvent;
const initial = getInitialMarriageProfile(); const initial = getInitialMarriageProfile();
console.log("📥 [Profile Query] Received habib:marriage-initial-data event:", {
detail: customEvent.detail,
parsedInitial: initial,
});
if (initial) { if (initial) {
queryClient.setQueryData(marriageQueryKeys.profile(), (old: any) => { queryClient.setQueryData(marriageQueryKeys.profile(), (old: any) => {
console.log("🔄 [Profile Query] Merging initialData into QueryCache. Old:", old, "New Initial:", initial);
if (!old) return initial; if (!old) return initial;
return { return {
...initial, ...initial,

Loading…
Cancel
Save