From 407d86cc1395cd8dfa1d10560b1b6e7167f1e6aa Mon Sep 17 00:00:00 2001 From: prajwalism Date: Thu, 4 Jul 2024 14:02:37 +0545 Subject: [PATCH] feat: navigate to projects sections if user is already logged in --- .../components/LandingPage/SignInOverlay/index.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/components/LandingPage/SignInOverlay/index.tsx b/src/frontend/src/components/LandingPage/SignInOverlay/index.tsx index c7b37a07..ef5add16 100644 --- a/src/frontend/src/components/LandingPage/SignInOverlay/index.tsx +++ b/src/frontend/src/components/LandingPage/SignInOverlay/index.tsx @@ -1,4 +1,5 @@ import { useTypedDispatch } from '@Store/hooks'; +import useAuth from '@Hooks/useAuth'; import { useNavigate } from 'react-router-dom'; import { FlexColumn, FlexRow } from '@Components/common/Layouts'; import { Button } from '@Components/RadixComponents/Button'; @@ -14,6 +15,7 @@ import { slideVariants } from '@Constants/animations'; export default function SignInOverlay() { const dispatch = useTypedDispatch(); const navigate = useNavigate(); + const { isAuthenticated } = useAuth(); return ( { dispatch(setCommonState({ signInAs: 'Project Creator' })); - navigate('/login'); + if (isAuthenticated()) { + navigate('/projects'); + } else { + navigate('/login'); + } }} > I'm a Project Creator @@ -62,7 +68,11 @@ export default function SignInOverlay() { rightIcon="east" onClick={() => { dispatch(setCommonState({ signInAs: 'Drone Operator' })); - navigate('/login'); + if (isAuthenticated()) { + navigate('/projects'); + } else { + navigate('/login'); + } }} > I'm a Drone Operator