-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNavbar.js
More file actions
34 lines (30 loc) · 1.13 KB
/
Navbar.js
File metadata and controls
34 lines (30 loc) · 1.13 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
import React from "react";
import { Link, useNavigate } from "react-router-dom";
import { useAuth } from "../../contexts/AuthContext";
const Navbar = () => {
const { currentUser, logout } = useAuth();
const navigate = useNavigate();
if (!currentUser) return null;
return (
<nav>
<div>
{currentUser.role === "Manager" ?
<span>Profile (Inactive)</span> :
<Link to="/profile">Profile</Link>} |
{currentUser.role === "Manager" ?
<span>Scorecard (Inactive)</span> :
<Link to="/scorecard">Scorecard</Link>} |
{currentUser.role === "Manager" ?
<Link to="/manager">Manager</Link> :
<span>Manager (Inactive)</span>}
</div>
<div>
<span>{currentUser.name} ({currentUser.role})</span> |
<button onClick={() => { logout(); navigate("/login"); }}>
Logout
</button>
</div>
</nav>
);
};
export default Navbar;