From 0ecc9a830ea5b32d8139ee623d091dd2e60aabce Mon Sep 17 00:00:00 2001 From: Aaron Po Date: Tue, 13 Oct 2026 01:32:28 -0400 Subject: [PATCH] Hide the navbar auth actions on the login and register routes --- .../app/components/ui/navbar/Navbar.tsx | 154 +++++++++--------- 1 file changed, 81 insertions(+), 73 deletions(-) diff --git a/web/frontend/app/components/ui/navbar/Navbar.tsx b/web/frontend/app/components/ui/navbar/Navbar.tsx index a91423a6..491345ba 100644 --- a/web/frontend/app/components/ui/navbar/Navbar.tsx +++ b/web/frontend/app/components/ui/navbar/Navbar.tsx @@ -1,5 +1,5 @@ import { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/react'; -import { Link } from 'react-router'; +import { Link, useLocation } from 'react-router'; import NavLinks from './NavLinks'; import UserMenu from './UserMenu'; @@ -12,85 +12,93 @@ interface NavbarProps { } | null; } -const Navbar = ({ auth }: NavbarProps) => ( - - {({ open }) => ( - <> -
-
- - { + const { pathname } = useLocation(); + const onAuthRoute = pathname === '/login' || pathname === '/register'; + const showAuthActions = !auth && !onAuthRoute; + + return ( + + {({ open }) => ( + <> +
+
+ - {open ? ( - - ) : ( - - )} - - + + {open ? ( + + ) : ( + + )} + + - - The Biergarten App - -
- - - -
- {!auth && ( - - Register User + + The Biergarten App - )} +
- {auth ? ( - <> - - Dashboard + + +
+ {showAuthActions && ( + + Register User + )} - - - ) : ( - - Login - - )} + {auth ? ( + <> + + Dashboard + + + + + ) : ( + !onAuthRoute && ( + + Login + + ) + )} +
-
- - - - - )} - -); + + + + + )} + + ); +}; export default Navbar;