diff --git a/frontend/src/components/Dropdown.jsx b/frontend/src/components/Dropdown.jsx index a72c39c..9069fdd 100644 --- a/frontend/src/components/Dropdown.jsx +++ b/frontend/src/components/Dropdown.jsx @@ -1,18 +1,21 @@ -import React ,{useState , useEffect}from "react"; +import React, { useState, useEffect } from "react"; import { useRef } from "react"; - +import LogoutModal from "./LogoutModal"; const Dropdown = () => { const [visible, setVisible] = useState(false); + const [modalVisible, setModalVisible] = useState(false); const dropdownRef = useRef(null); - // Function to handle the click event + const handleClick = () => { setVisible(!visible); }; // Function to handle the click outside the dropdown const handleClickOutside = (event) => { - if (dropdownRef.current && !dropdownRef.current.contains(event.target)) - { setVisible(false); } }; + if (dropdownRef.current && !dropdownRef.current.contains(event.target)) { + setVisible(false); + } + }; // useEffect hook to add an event listener when the component mounts useEffect(() => { @@ -20,19 +23,26 @@ const Dropdown = () => { return () => { document.removeEventListener('mousedown', handleClickOutside); }; }, []); + // Function to handle logout click + const handleLogoutClick = () => { + setModalVisible(true); + setVisible(false); + }; + return ( -
- - -
+
+ + + {modalVisible && } {/* Render LogoutModal */} +
) } -export default Dropdown; \ No newline at end of file +export default Dropdown; \ No newline at end of file diff --git a/frontend/src/components/LogoutModal.jsx b/frontend/src/components/LogoutModal.jsx new file mode 100644 index 0000000..82fdd5c --- /dev/null +++ b/frontend/src/components/LogoutModal.jsx @@ -0,0 +1,38 @@ +import React, { useState, useRef } from 'react'; + +const LogoutModal = ({ setVisible }) => { + const modalRef = useRef(null); + + const handleClick = () => { setVisible(false); }; + + const handleLogout = () => { + // Logout logic here + setVisible(false); + } + + return ( + <> + +
+ + ); +} + +export default LogoutModal; \ No newline at end of file