import Link from "next/link"; import { redirect } from "next/navigation"; import { Inter } from "next/font/google"; import "./globals.css"; import { loadProfile } from "@/lib/auth/profile"; import { ladeEigeneFirma } from "@/lib/firma/eigene-firma"; import { themeVariablen } from "@/lib/firma/farben"; import { FirmenLogo } from "@/components/FirmenLogo"; 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(); const firmaErgebnis = await ladeEigeneFirma(); if (result.status === "ok" && firmaErgebnis.status === "keine-firma") { redirect("/abmelden?grund=firma"); } const firma = firmaErgebnis.status === "ok" ? firmaErgebnis.firma : null; const themeStyle = firma ? (themeVariablen(firma) as React.CSSProperties) : undefined; if (result.status === "missing-profile") { return (

Profil nicht gefunden

Für deinen Account existiert kein Profil. Bitte wende dich an einen Admin.

); } return ( {result.status === "ok" && (
{result.profile.name} ({result.profile.role})
{result.profile.name} ({result.profile.role})
)}
{children}
); }