Skip to content

Commit 733ce83

Browse files
authored
Merge pull request #3104 from Voyager-Ship/voyager-ship/T1_Fixes
Voyager ship/t1 fixes
2 parents dc89375 + 6c68b64 commit 733ce83

File tree

27 files changed

+1143
-280
lines changed

27 files changed

+1143
-280
lines changed

app/(home)/ambassador-dao/onboard/layout.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,36 @@ const AmbasssadorDaoOnboardLayout = ({
1515

1616
useEffect(() => {
1717
if (!isLoading && !user) {
18-
router.push("/ambassador-dao");
18+
// Check if the error is due to token acquisition failure
19+
const tokenError = typeof window !== "undefined"
20+
? localStorage.getItem("t1_token_error")
21+
: null;
22+
23+
if (tokenError === "user_not_found") {
24+
// User doesn't exist in Ambassador DAO - stay on onboard page to create profile
25+
console.log("User not found in Ambassador DAO, staying on onboard page");
26+
return;
27+
} else if (tokenError === "server_error") {
28+
// Server error - redirect to home to avoid loop
29+
toast.error("Cannot connect to Ambassador DAO. Please try again later.");
30+
return;
31+
} else {
32+
// Normal case: user not authenticated, redirect to main ambassador-dao page
33+
router.push("/ambassador-dao");
34+
}
1935
}
2036
}, [user, isLoading, router]);
2137

2238
if (isLoading) {
2339
return <FullScreenLoader />;
2440
}
25-
return <main>{user && children}</main>;
41+
42+
// Allow rendering even without user if error is user_not_found (to show onboarding form)
43+
const tokenError = typeof window !== "undefined"
44+
? localStorage.getItem("t1_token_error")
45+
: null;
46+
47+
return <main>{(user || tokenError === "user_not_found") && children}</main>;
2648
};
2749

2850
export default AmbasssadorDaoOnboardLayout;

0 commit comments

Comments
 (0)