Improve profile completion state handling
cgen-ce04864443294c19816a5e7df4b45d86
This commit is contained in:
parent
0cdd7bd7d6
commit
9a0e135ce4
1 changed files with 19 additions and 4 deletions
|
|
@ -479,10 +479,25 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
||||||
}));
|
}));
|
||||||
}, [user]);
|
}, [user]);
|
||||||
|
|
||||||
const computedComplete =
|
const profileCompletedByData = useMemo(
|
||||||
checkProfileComplete(profile) ||
|
() => checkProfileComplete(profile),
|
||||||
(typeof window !== "undefined" &&
|
[profile],
|
||||||
window.localStorage.getItem("onboarding_complete") === "1");
|
);
|
||||||
|
|
||||||
|
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 = {
|
const value = {
|
||||||
user,
|
user,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue