1
0
Fork 0
fahrPool/web/app/layout.tsx

71 lines
2.4 KiB
TypeScript

import Image from "next/image";
import Link from "next/link";
import { Inter } from "next/font/google";
import "./globals.css";
import { loadProfile } from "@/lib/auth/profile";
import { NavLinks } from "@/components/NavLinks";
import { LogoutButton } from "@/components/LogoutButton";
import { MobileNav } from "@/components/MobileNav";
const inter = Inter({ subsets: ["latin"], variable: "--font-inter" });
export const metadata = {
title: "Aushilfsfahrer",
};
export default async function RootLayout({
children,
}: Readonly<{ children: React.ReactNode }>) {
const result = await loadProfile();
if (result.status === "missing-profile") {
return (
<html lang="de" className={inter.variable}>
<body className="flex min-h-screen flex-col font-sans">
<main className="flex flex-1 items-center justify-center p-4">
<div>
<h1 className="text-xl font-semibold text-asphalt-grey">Profil nicht gefunden</h1>
<p className="mt-2 text-asphalt-grey">
Für deinen Account existiert kein Profil. Bitte wende dich an einen Admin.
</p>
</div>
</main>
</body>
</html>
);
}
return (
<html lang="de" className={inter.variable}>
<body className="flex min-h-screen flex-col font-sans">
{result.status === "ok" && (
<header className="flex h-16 items-center justify-between border-b border-aluminium-grey px-4 lg:px-8">
<Link href="/dashboard" className="flex items-center">
<Image src="/brand/widmann-logo.svg" alt="Widmann" width={140} height={21} priority />
</Link>
<div className="hidden items-center gap-6 lg:flex">
<NavLinks role={result.profile.role} orientation="horizontal" />
<span className="text-sm text-asphalt-grey">
{result.profile.name} ({result.profile.role})
</span>
<LogoutButton />
</div>
<MobileNav>
<div className="mb-6 text-sm text-asphalt-grey">
{result.profile.name} ({result.profile.role})
</div>
<NavLinks role={result.profile.role} orientation="vertical" />
<div className="mt-6">
<LogoutButton />
</div>
</MobileNav>
</header>
)}
<main className="flex-1">{children}</main>
</body>
</html>
);
}