Skip to content

Commit

Permalink
fix redirect logic
Browse files Browse the repository at this point in the history
  • Loading branch information
J164 committed Feb 1, 2025
1 parent be4bced commit a3ada0f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
10 changes: 5 additions & 5 deletions app/closed/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ const Closed: React.FC = () => {
return;
}

if (eventStatus === "registration") {
router.push("/register");
return;
}

if (!isAuthenticated()) {
authenticate(pathname);
return;
Expand All @@ -46,6 +41,11 @@ const Closed: React.FC = () => {
return;
}

if (eventStatus === "registration") {
router.push("/register");
return;
}

setIsLoading(false);
});
}, [eventStatus, pathname, router]);
Expand Down
17 changes: 11 additions & 6 deletions app/register/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,23 @@ const Layout = ({ children }: { children: React.ReactNode }) => {
return;
}

if (eventStatus === "registration") {
setIsLoading(false);
return;
}

if (!isAuthenticated()) {
authenticate(pathname);
return;
}

getRegistrationOrDefault().then(registration => {
router.push(registration.hasSubmitted ? "/profile" : "/closed");
if (registration.hasSubmitted) {
router.push("/profile");
return;
}

if (eventStatus !== "registration") {
router.push("/closed");
return;
}

setIsLoading(false);
});
}, [eventStatus, router, pathname]);

Expand Down

0 comments on commit a3ada0f

Please sign in to comment.