diff --git a/src/components/Navbar/Navbar.jsx b/src/components/Navbar/Navbar.jsx index a4513fb..303d205 100644 --- a/src/components/Navbar/Navbar.jsx +++ b/src/components/Navbar/Navbar.jsx @@ -1,12 +1,17 @@ import React, { useState } from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faSignOutAlt } from '@fortawesome/free-solid-svg-icons'; -import { Link } from 'react-router-dom'; +import { Link, useLocation } from 'react-router-dom'; +import useAuth from "../../hooks/useAuth"; const Navbar = () => { + const location = useLocation(); + const isLoginPage = location.pathname === '/login'; + const { setAuth } = useAuth(); + const handleLogout = () => { - - window.location= "/login"; + setAuth({ roles: null, token: null }); + window.location = "/login"; }; const [open, setOpen] = useState(true); @@ -58,11 +63,13 @@ const Navbar = () => { > Contact -