From de99e296b8dab7174371bb6a51412936261cbade Mon Sep 17 00:00:00 2001 From: ALi Josheghani Date: Sat, 14 Sep 2024 22:02:36 +0330 Subject: [PATCH] refactor: add useLocation hook to Navbar component --- src/components/header/components/navbar/Navbar.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/header/components/navbar/Navbar.tsx b/src/components/header/components/navbar/Navbar.tsx index fca6d00..1ae9cad 100644 --- a/src/components/header/components/navbar/Navbar.tsx +++ b/src/components/header/components/navbar/Navbar.tsx @@ -5,12 +5,13 @@ import MobileMenu from "./MobileMenu"; import NavbarLink from "./NavbarLink"; import router from "../../../../routes/routes"; import Button from "../../../button"; -import { useNavigate } from "react-router-dom"; +import { useLocation, useNavigate } from "react-router-dom"; import { Route } from "../../../../types/props"; import { IsAuthenticated } from "../../../../utils/auth"; -const Navbar = ({extra}:{extra?:string}) => { +const Navbar = ({ extra }: { extra?: string }) => { const [isOpen, setIsOpen] = useState(false); + const location = useLocation(); const auth = IsAuthenticated(); const [routes] = useState(router); const navigate = useNavigate(); @@ -29,7 +30,9 @@ const Navbar = ({extra}:{extra?:string}) => { return (
-
- {auth ? ( + {location?.pathname === "/profile" ? ( + + ) : auth ? ( ) : (