Skip to content

Commit 9a803f5

Browse files
committed
Include profile and logout menu in header component
1 parent d473232 commit 9a803f5

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

apps/frontend/src/components/Header/header.tsx

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
import { Menu } from "antd";
1+
import {
2+
Avatar,
3+
Button,
4+
Divider,
5+
Dropdown,
6+
Menu,
7+
MenuProps,
8+
Space,
9+
} from "antd";
210
import { Header as AntdHeader } from "antd/es/layout/layout";
311
import { useRouter } from "next/navigation";
412
import "./styles.scss";
13+
import DropdownButton from "antd/es/dropdown/dropdown-button";
14+
import { LogoutOutlined, UserOutlined } from "@ant-design/icons";
515

616
const Header = (): JSX.Element => {
717
const { push } = useRouter();
@@ -18,13 +28,43 @@ const Header = (): JSX.Element => {
1828
},
1929
];
2030

31+
const profileItems: MenuProps["items"] = [
32+
{
33+
key: 0,
34+
label: (
35+
<div className="profile-menu-items">
36+
<UserOutlined className="profile-menu-icon" /> Profile
37+
</div>
38+
),
39+
onClick: () => push("/profile"),
40+
},
41+
{
42+
type: "divider",
43+
},
44+
{
45+
key: 2,
46+
label: (
47+
<div className="profile-menu-items">
48+
<LogoutOutlined className="profile-menu-icon" /> Logout
49+
</div>
50+
),
51+
onClick: () => {
52+
// Clear away the previously stored jwt token in localstorage
53+
localStorage.clear();
54+
// Redirect user to login page
55+
push("/login");
56+
},
57+
},
58+
];
59+
2160
return (
2261
// Header Component
2362
<AntdHeader className="header">
2463
<div className="logo-container">
2564
<div className="logo1">Peer</div>
2665
<div className="logo2">Prep</div>
2766
</div>
67+
{/* Left Menu Pages Component */}
2868
<Menu
2969
mode="horizontal"
3070
defaultSelectedKeys={["0"]}
@@ -34,6 +74,16 @@ const Header = (): JSX.Element => {
3474
push("/");
3575
}}
3676
/>
77+
<Dropdown
78+
menu={{ items: profileItems }}
79+
placement="bottom"
80+
overlayClassName="dropdown"
81+
>
82+
<a onClick={(e) => e.preventDefault()}>
83+
{/* Fetch and replace with first letter of user's name */}
84+
<Avatar>A</Avatar>
85+
</a>
86+
</Dropdown>
3787
</AntdHeader>
3888
);
3989
};

apps/frontend/src/components/Header/styles.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ $secondary-color: #463f3a;
66
align-items: center;
77
background: white !important;
88
border-bottom: 1px solid #f3f3f3;
9+
padding-right: 20px !important;
910
}
1011

1112
.logo {
@@ -34,3 +35,16 @@ $secondary-color: #463f3a;
3435
flex-direction: row;
3536
padding: 0 16px 0 0;
3637
}
38+
39+
.profile-menu-items {
40+
width: 6rem;
41+
padding: 2px 8px;
42+
}
43+
44+
.profile-menu-icon {
45+
margin-right: 8px;
46+
}
47+
48+
.dropdown {
49+
padding-right: 10px !important;
50+
}

0 commit comments

Comments
 (0)