diff --git a/src/components/LoginAuth.jsx b/src/components/LoginAuth.jsx index edf82e2..85dc070 100644 --- a/src/components/LoginAuth.jsx +++ b/src/components/LoginAuth.jsx @@ -1,7 +1,10 @@ import { Box, HStack, VStack, Image, Button } from "@chakra-ui/react"; import React, { useState } from "react"; +import { useNavigate } from "react-router-dom"; import { DialogBody, + DialogHeader, + DialogTitle, DialogContent, DialogRoot, DialogFooter, @@ -19,6 +22,17 @@ const CardWithForm = ({ isAuthentificated }) => { const [formType, setFormType] = useState("login"); const closeDialogRef = useRef(null); // Ref to programmatically trigger DialogCloseTrigger + const storedAuth = JSON.parse(localStorage.getItem("auth")); + const navigate = useNavigate(); + /*const [isSignedIn, setIsSignedIn] = useState(() => { + return JSON.parse(localStorage.getItem("auth")) || false; + });*/ + + const handleLogout = () => { + localStorage.removeItem("auth"); // Clear auth data the logout api will be call here + navigate("/"); // Redirect to Home + }; + const handleClose = () => { if (closeDialogRef.current) { closeDialogRef.current.click(); // Programmatically trigger close button @@ -44,77 +58,116 @@ const CardWithForm = ({ isAuthentificated }) => { } }; return ( - - - - - User Icon - - - - - - - - - {/* Left section with image */} - + {storedAuth ? ( +
+ + + + User Icon + + + - - Code The Dream Logo + Confirm Logout + + +

+ Are you sure you want to log out? Your session will be ended, + and you’ll need to sign in again to access your account. +

+
+ + + + + + +
+
+
+ ) : ( + + + + User Icon + + + + + + + + + {/* Left section with image */} + + + Code The Dream Logo + + + {/* Right section with form */} + + {renderFormContent()} + + + + + +