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