-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProfileMenu.jsx
More file actions
54 lines (48 loc) · 1.41 KB
/
ProfileMenu.jsx
File metadata and controls
54 lines (48 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import "./styles.css";
import { useState } from "react";
import { Link } from "react-router-dom";
import { useLogout } from "../../../Hooks/useLogoutHook";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
faSignOutAlt,
faUser,
faChevronDown,
} from "@fortawesome/free-solid-svg-icons";
const ProfileMenu = () => {
const [isOpen, setIsOpen] = useState(false);
const logout = useLogout();
const handleToggle = () => {
setIsOpen((prev) => !prev);
};
const handleLogout = async () => {
try {
await logout();
} catch (error) {
console.error("Logout failed:", error);
}
};
return (
<div className="profile-menu-container">
<div className="profile-summary" onClick={handleToggle}>
<span className="username">Profile Menu</span>
<FontAwesomeIcon
icon={faChevronDown}
className={`arrow-icon ${isOpen ? "open" : ""}`}
/>
</div>
{isOpen && (
<div className="dropdown-menu">
<Link to="/provider/profile" className="dropdown-item">
<FontAwesomeIcon icon={faUser} className="item-icon" />
Profile
</Link>
<button onClick={handleLogout} className="dropdown-item logout">
<FontAwesomeIcon icon={faSignOutAlt} className="item-icon" />
Logout
</button>
</div>
)}
</div>
);
};
export default ProfileMenu;