Skip to content

Commit

Permalink
Updated Navbar
Browse files Browse the repository at this point in the history
Check to see if user is Authenticated, which shows a different display of the Navbar
  • Loading branch information
nanodecimeter committed Jul 24, 2024
1 parent 78c7f59 commit fbf2cb4
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions frontend/src/ui/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@
import Link from 'next/link'
import styles from './Navbar.module.css'
import { usePathname } from 'next/navigation';
import { useState } from 'react';

export default function NavBar() {
const pathname = usePathname();
const [isAuthentication, setIsAuthentication] = useState(true);
console.log(pathname)

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

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

return (
<nav className={styles.nav}>
<ul>


<li className={styles.navitem}>
<Link className={`${styles.navlink} ${pathname === "/home" ? styles.currentpage : ""}`} href="/home">
Home
Expand All @@ -26,11 +38,26 @@ export default function NavBar() {
Events
</Link>
</li>
<li className={styles.navitem}>
<Link className={`${styles.navlink} ${pathname === "/home/login" ? styles.currentpage : ""}`} href="/home/login">
Register/Log In
</Link>
</li>
{isAuthentication ? (
<>
<li className={styles.navitem}>
<Link className={`${styles.navlink} ${pathname === "/profile" ? styles.currentpage : ""}`} href="/profile">
Profile
</Link>
</li>
<li className={styles.navitem}>
<button className={styles.navlink} onClick={handleLogout}>
Logout
</button>
</li>
</>
) : (
<li className={styles.navitem}>
<Link className={`${styles.navlink} ${pathname === "/home/login" ? styles.currentpage : ""}`} href="/home/login">
Register/Log In
</Link>
</li>
)}
</ul>
</nav>
)
Expand Down

0 comments on commit fbf2cb4

Please sign in to comment.