MCPcopy Create free account
hub / github.com/Krycha94/fullstack-nextjs-ecommerce / UserPanel

Function UserPanel

components/UserPanel/UserPanel.tsx:7–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5import styles from "./UserPanel.module.scss";
6
7const UserPanel = () => {
8 const [isOpen, setIsOpen] = useState(false);
9 const { user, logout } = useAuthContext();
10
11 const handleLogout = () => {
12 setIsOpen(false);
13 logout();
14 };
15
16 return (
17 <div className={styles.user}>
18 {!user ? (
19 <Link href="auth" className={styles.user__login}>
20 Login
21 </Link>
22 ) : (
23 <div className={styles.user__container}>
24 <div
25 className={styles.user__panel}
26 onClick={() => setIsOpen((prev) => !prev)}
27 >
28 <img
29 src={user?.photoURL || "/default.png"}
30 alt="profile pic"
31 className={styles.user__img}
32 />
33 <p className={styles.user__name}>
34 {user?.displayName?.split(" ")[0] || user?.email}
35 </p>
36 <button className={styles.user__menuBtn}>
37 {isOpen ? <FiChevronUp /> : <FiChevronDown />}
38 </button>
39 </div>
40 {isOpen && (
41 <button
42 type="button"
43 onClick={handleLogout}
44 className={styles.user__logoutBtn}
45 >
46 Logout
47 </button>
48 )}
49 </div>
50 )}
51 </div>
52 );
53};
54export default UserPanel;

Callers

nothing calls this directly

Calls 1

useAuthContextFunction · 0.90

Tested by

no test coverage detected