prod
This commit is contained in:
+25
-20
@@ -4,38 +4,43 @@ 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-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>
|
||||
<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="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 ? `/${link.page.type.toLowerCase()}/${link.page.slug}` : "/")}><h3>{link.label ?? link.page?.title}</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>
|
||||
{
|
||||
user ? (
|
||||
|
||||
<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>
|
||||
)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user