Skip to content

Commit

Permalink
Added Admin Authentication
Browse files Browse the repository at this point in the history
Changed the Navigation Preview if the user is Admin
  • Loading branch information
nanodecimeter committed Jul 24, 2024
1 parent fbf2cb4 commit 5131f90
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions frontend/src/ui/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import { useState } from 'react';
export default function NavBar() {
const pathname = usePathname();
const [isAuthentication, setIsAuthentication] = useState(true);
const [isAdmin, setIsAdmin] = useState(false)
console.log(pathname)

const handleLogin = () => {
setIsAuthentication(true)
}

const handleLogout = () => {
const handleLogout = () => {
setIsAuthentication(false)
setIsAdmin(false)
}

return (
Expand Down Expand Up @@ -45,6 +47,13 @@ export default function NavBar() {
Profile
</Link>
</li>
{isAdmin && (
<li className={styles.navitem}>
<Link className={`${styles.navlink} ${pathname === "/member-data" ? styles.currentpage : ""}`} href="/member-data">
Member Data
</Link>
</li>
)}
<li className={styles.navitem}>
<button className={styles.navlink} onClick={handleLogout}>
Logout
Expand All @@ -53,7 +62,7 @@ export default function NavBar() {
</>
) : (
<li className={styles.navitem}>
<Link className={`${styles.navlink} ${pathname === "/home/login" ? styles.currentpage : ""}`} href="/home/login">
<Link className={`${styles.navlink} ${pathname === "/home/login" ? styles.currentpage : ""}` } href="/home/login">
Register/Log In
</Link>
</li>
Expand Down

0 comments on commit 5131f90

Please sign in to comment.