forked from fahrPool/fahrPool
45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
import "./globals.css";
|
|
import { loadProfile } from "@/lib/auth/profile";
|
|
import { NavLinks } from "@/components/NavLinks";
|
|
import { LogoutButton } from "@/components/LogoutButton";
|
|
|
|
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">
|
|
<body>
|
|
<main>
|
|
<h1>Profil nicht gefunden</h1>
|
|
<p>Für deinen Account existiert kein Profil. Bitte wende dich an einen Admin.</p>
|
|
</main>
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<html lang="de">
|
|
<body>
|
|
{result.status === "ok" && (
|
|
<header>
|
|
<NavLinks role={result.profile.role} />
|
|
<span>
|
|
{result.profile.name} ({result.profile.role})
|
|
</span>
|
|
<LogoutButton />
|
|
</header>
|
|
)}
|
|
<main>{children}</main>
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|