diff --git a/src/Components/Menu.js b/src/Components/Menu.js index c493dd47..ce734bc1 100644 --- a/src/Components/Menu.js +++ b/src/Components/Menu.js @@ -22,6 +22,7 @@ function Menu() { const [sidebarOpen, setSidebarOpen] = useState(false); const [isMobile, setIsMobile] = useState(window.innerWidth < 524); const [showStopwatch, setShowStopwatch] = useState(false); // State to handle stopwatch visibility + const [isUserLoggedIn, setIsUserLoggedIn] = useState(localStorage.getItem('user') ? true : false); useEffect(() => { const handleResize = () => { @@ -30,10 +31,12 @@ function Menu() { window.addEventListener("resize", handleResize); + const user = localStorage.getItem('user'); + setIsUserLoggedIn(user ? true : false); return () => { window.removeEventListener("resize", handleResize); }; - }, []); + }, [isUserLoggedIn]); const toggleSidebar = () => { setSidebarOpen(!sidebarOpen); @@ -44,10 +47,8 @@ function Menu() { }; const handleSignOut = () => { - console.log("User signed out"); - setTimeout(() => { - // Handle any additional sign-out logic here - }, 3000); + localStorage.removeItem('user'); + setIsUserLoggedIn(false); }; const { theme } = useContext(ThemeContext) @@ -122,12 +123,14 @@ function Menu() { Settings -