40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
// components/header.tsx
|
|
"use client";
|
|
|
|
import { useAuth } from "@/hooks/use-auth";
|
|
import Link from "next/link";
|
|
import { Button } from "./ui/button";
|
|
import { UserNav } from "./user-nav";
|
|
|
|
export function Header() {
|
|
const { token } = useAuth();
|
|
|
|
return (
|
|
<header className="sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
|
|
<div className="container flex h-14 items-center">
|
|
<div className="mr-4 flex">
|
|
<Link href="/" className="mr-6 flex items-center space-x-2">
|
|
<span className="font-bold">Thoughts</span>
|
|
</Link>
|
|
</div>
|
|
<div className="flex flex-1 items-center justify-end space-x-4">
|
|
<nav className="flex items-center space-x-2">
|
|
{token ? (
|
|
<UserNav />
|
|
) : (
|
|
<>
|
|
<Button asChild variant="ghost">
|
|
<Link href="/login">Login</Link>
|
|
</Button>
|
|
<Button asChild>
|
|
<Link href="/register">Register</Link>
|
|
</Button>
|
|
</>
|
|
)}
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
);
|
|
}
|