48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
'use client';
|
|
|
|
import Link from 'next/link';
|
|
import { useEffect, useState } from 'react';
|
|
|
|
export default function Navbar() {
|
|
const [isLoggedIn, setIsLoggedIn] = useState(false);
|
|
|
|
useEffect(() => {
|
|
const hasAuthCookie = document.cookie
|
|
.split('; ')
|
|
.some((c) => c.startsWith('onlypets-auth=true'));
|
|
|
|
setIsLoggedIn(hasAuthCookie);
|
|
}, []);
|
|
|
|
return (
|
|
<nav
|
|
style={{
|
|
display: 'flex',
|
|
gap: '1.5rem',
|
|
padding: '1rem',
|
|
borderBottom: '1px solid #eee',
|
|
}}
|
|
>
|
|
{/* 🌱 GAST-NAVIGATION */}
|
|
{!isLoggedIn && (
|
|
<>
|
|
<Link href="/">Home</Link>
|
|
<Link href="/login">Login</Link>
|
|
<Link href="/register">Registrierung</Link>
|
|
</>
|
|
)}
|
|
|
|
{/* 🐾 USER-NAVIGATION */}
|
|
{isLoggedIn && (
|
|
<>
|
|
<Link href="/feed">Feed</Link>
|
|
<Link href="/explore">Entdecken</Link>
|
|
<Link href="/pets">Meine Tiere</Link>
|
|
<Link href="/post/new">Posten</Link>
|
|
<Link href="/profile">Profil</Link>
|
|
</>
|
|
)}
|
|
</nav>
|
|
);
|
|
}
|