Skip to content

Commit

Permalink
Merge pull request #77 from isd-sgcu/dev
Browse files Browse the repository at this point in the history
update main
  • Loading branch information
bookpanda authored Jul 15, 2024
2 parents b8301d8 + 3de66a1 commit b8015f6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/context/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ const AuthProvider: React.FC<{ children: ReactNode }> = ({
}, []);

useEffect(() => {
if (path == '/') {
setisReady(true);
return;
}
setisReady(false);

const userStr = localStorage.getItem('user');
if (!userStr) {
setisReady(true);
return router.push('/');
}

Expand All @@ -68,6 +66,10 @@ const AuthProvider: React.FC<{ children: ReactNode }> = ({
const isRegisterPage = path.includes('register');

if (isStaff) {
if (path == '/') {
return router.push('firstdate/staff/home');
}

if (!isRegistered && !isRegisterPage) {
return router.push('/staff/register');
}
Expand All @@ -76,6 +78,10 @@ const AuthProvider: React.FC<{ children: ReactNode }> = ({
return router.push('/firstdate/staff/home');
}
} else {
if (path == '/') {
return router.push('/home');
}

if (!isRegistered && !isRegisterPage) {
return router.push('/register');
}
Expand Down

0 comments on commit b8015f6

Please sign in to comment.