|
|
@ -9,6 +9,10 @@ import { |
|
|
hasCompletedMarriageProfileBasics, |
|
|
hasCompletedMarriageProfileBasics, |
|
|
} from "@/lib/get-submit-path"; |
|
|
} from "@/lib/get-submit-path"; |
|
|
import { http } from "@/lib/http"; |
|
|
import { http } from "@/lib/http"; |
|
|
|
|
|
import { |
|
|
|
|
|
getScopedMarriageProfile, |
|
|
|
|
|
saveScopedMarriageProfile, |
|
|
|
|
|
} from "@/lib/user-scoped-storage"; |
|
|
import type { QueryOptions } from "./options"; |
|
|
import type { QueryOptions } from "./options"; |
|
|
import { marriageQueryKeys } from "./query-keys"; |
|
|
import { marriageQueryKeys } from "./query-keys"; |
|
|
import type { MarriageProfileResponse } from "./types"; |
|
|
import type { MarriageProfileResponse } from "./types"; |
|
|
@ -16,7 +20,33 @@ import type { MarriageProfileResponse } from "./types"; |
|
|
export function getInitialMarriageProfile( |
|
|
export function getInitialMarriageProfile( |
|
|
dataOverride?: any, |
|
|
dataOverride?: any, |
|
|
): MarriageProfileResponse | undefined { |
|
|
): MarriageProfileResponse | undefined { |
|
|
const data = dataOverride ?? authBridge.getMarriageData(); |
|
|
|
|
|
|
|
|
if (dataOverride) { |
|
|
|
|
|
const data = dataOverride; |
|
|
|
|
|
return { |
|
|
|
|
|
id: data.id ?? 0, |
|
|
|
|
|
status: data.status, |
|
|
|
|
|
gender: data.gender, |
|
|
|
|
|
age: data.age ?? null, |
|
|
|
|
|
is_registering_for_self: data.is_registering_for_self ?? null, |
|
|
|
|
|
can_edit_profile: data.can_edit_profile ?? true, |
|
|
|
|
|
can_message_expert: data.can_message_expert ?? true, |
|
|
|
|
|
active_subscription: data.active_subscription ?? null, |
|
|
|
|
|
is_ready_for_match: data.is_ready_for_match ?? true, |
|
|
|
|
|
active_case: data.active_case ?? null, |
|
|
|
|
|
needs_subscription: data.needs_subscription ?? false, |
|
|
|
|
|
recommended_plan: data.recommended_plan ?? null, |
|
|
|
|
|
match_summary: data.match_summary ?? null, |
|
|
|
|
|
} as MarriageProfileResponse; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Priority 2: Use locally persisted profile from previous successful server response
|
|
|
|
|
|
const persisted = getScopedMarriageProfile(); |
|
|
|
|
|
if (persisted) { |
|
|
|
|
|
return persisted; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Priority 3: Fallback to Flutter native bridge data
|
|
|
|
|
|
const data = authBridge.getMarriageData(); |
|
|
if (!data) return undefined; |
|
|
if (!data) return undefined; |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
@ -55,6 +85,9 @@ export async function getMarriageProfile() { |
|
|
raw_match_summary: data?.match_summary, |
|
|
raw_match_summary: data?.match_summary, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Persist latest verified profile response locally for instant 0ms hydration
|
|
|
|
|
|
saveScopedMarriageProfile(data); |
|
|
|
|
|
|
|
|
setCachedMarriageEntryPath( |
|
|
setCachedMarriageEntryPath( |
|
|
hasCompletedMarriageProfileBasics(data) ? getSubmitPath(data) : "/intro", |
|
|
hasCompletedMarriageProfileBasics(data) ? getSubmitPath(data) : "/intro", |
|
|
); |
|
|
); |
|
|
|