From 9a0e135ce414375f7d55cf0424c00336cd7a2f05 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Tue, 30 Sep 2025 21:24:02 +0000 Subject: [PATCH] Improve profile completion state handling cgen-ce04864443294c19816a5e7df4b45d86 --- client/contexts/AuthContext.tsx | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/client/contexts/AuthContext.tsx b/client/contexts/AuthContext.tsx index 3fa1ec57..a6dd7d5a 100644 --- a/client/contexts/AuthContext.tsx +++ b/client/contexts/AuthContext.tsx @@ -479,10 +479,25 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ })); }, [user]); - const computedComplete = - checkProfileComplete(profile) || - (typeof window !== "undefined" && - window.localStorage.getItem("onboarding_complete") === "1"); + const profileCompletedByData = useMemo( + () => checkProfileComplete(profile), + [profile], + ); + + const localOnboardingComplete = + typeof window !== "undefined" && + window.localStorage.getItem("onboarding_complete") === "1"; + + useEffect(() => { + if (typeof window === "undefined") return; + if (profileCompletedByData) { + window.localStorage.setItem("onboarding_complete", "1"); + } else if (window.localStorage.getItem("onboarding_complete") === "1") { + window.localStorage.removeItem("onboarding_complete"); + } + }, [profileCompletedByData]); + + const computedComplete = profileCompletedByData || localOnboardingComplete; const value = { user,