diff --git a/frontend/src/Components/app-bar/AppBar.jsx b/frontend/src/Components/app-bar/AppBar.jsx index beb7161..1916a5c 100644 --- a/frontend/src/Components/app-bar/AppBar.jsx +++ b/frontend/src/Components/app-bar/AppBar.jsx @@ -32,7 +32,7 @@ const NavBarImage = () => ( ); export default function DrawerAppBar() { - const { ROUTES, currentRoute, setCurrentRoute } = useConfig(); + const { ROUTES, currentRoute, setCurrentRoute, accessToken, refreshToken } = useConfig(); const [mobileOpen, setMobileOpen] = React.useState(false); const { getVariant } = useNavItem(); @@ -43,6 +43,25 @@ export default function DrawerAppBar() { setMobileOpen((prevState) => !prevState); }; + const shouldShowRoute = (route) => { + if (route.title === 'My Account') { + if (accessToken || refreshToken) { + return true; + } + console.log('not signed in'); + return false; + } + + if (route.title === 'Signup') { + if (accessToken || refreshToken) { + return false; + } + return true; + } + + return true; + }; + const drawer = ( setCurrentRoute(ROUTES.home)}> @@ -50,15 +69,19 @@ export default function DrawerAppBar() { - {appBarPaths.map((name, index) => ( - - - - - - - - ))} + {appBarPaths.map((name, index) => { + return ( + shouldShowRoute(ROUTES[name]) && ( + + + + + + + + ) + ); + })} ); @@ -80,20 +103,25 @@ export default function DrawerAppBar() { - {appBarPaths.map((name, index) => ( - - - - ))} + {appBarPaths.map((name, index) => { + console.log(shouldShowRoute(name) === false); + return ( + shouldShowRoute(ROUTES[name]) && ( + + ) + ); + })}