Files
eu/components/header.tsx
T
2026-07-11 21:20:57 +03:00

46 lines
1.7 KiB
TypeScript

import Image from "next/image";
import { Button } from "./ui/button";
import { login } from "@/lib/user/actions";
import { getCurrentUser } from "@/lib/user";
import Link from "next/link";
import { getNavLinks } from "@/lib/navlinks/repository";
import { MobileNav } from "./mobile-nav";
export default async function Header() {
const user = await getCurrentUser();
const links = await getNavLinks();
const navLinks = links.map((link) => ({
id: link.id,
href: link.href || (link.page ? `/${link.page.type.toLowerCase()}/${link.page.slug}` : "/"),
label: link.label ?? link.page?.title ?? "",
}));
return (
<header className="relative flex items-center justify-between w-full h-16 px-4 sm:px-8 bg-white sm:bg-gray-100">
<Link href="/" className="flex items-center gap-4 shrink-0">
<Image src="/emblem.png" width={28} height={28} alt="Emblem of the European Federation" />
<h3 className="hidden sm:block">European Federation</h3>
</Link>
<div className="hidden md:flex absolute left-1/2 -translate-x-1/2 items-center gap-6">
{navLinks.map((link) => (
<Link className="hover:underline underline-offset-8 decoration-2 duration-200" key={link.id} href={link.href}>
<h3>{link.label}</h3>
</Link>
))}
</div>
<div className="hidden md:block">
{user ? (
<Link href="/account"><Button>Account</Button></Link>
) : (
<form action={login}>
<Button size="lg" type="submit">Sign in with Kotosoft ID</Button>
</form>
)}
</div>
<MobileNav links={navLinks} isAuthenticated={!!user} />
</header>
);
}