Kantinen-Bereich: Wochenplan-Editor, Gerichte, Kennzeichnungen, Passkey-Verwaltung
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
import { createClient } from "@/lib/supabase/server";
|
||||
|
||||
export default async function InternLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const supabase = await createClient();
|
||||
const {
|
||||
data: { user },
|
||||
} = await supabase.auth.getUser();
|
||||
if (!user) redirect("/login");
|
||||
|
||||
const { data: profile } = await supabase
|
||||
.from("profiles")
|
||||
.select("role, full_name")
|
||||
.eq("id", user.id)
|
||||
.single();
|
||||
if (!profile || !["staff", "admin"].includes(profile.role)) redirect("/");
|
||||
|
||||
return (
|
||||
<div className="flex-1 flex flex-col">
|
||||
<header className="bg-[var(--c-primary-dark)] text-white">
|
||||
<div className="max-w-[1600px] mx-auto w-full px-4 py-3 flex flex-wrap items-center gap-x-5 gap-y-2">
|
||||
<span className="font-bold">Kantinen-Bereich</span>
|
||||
<nav className="flex flex-wrap gap-x-4 gap-y-1 text-sm">
|
||||
<Link href="/intern" className="hover:underline">
|
||||
Wochenplan
|
||||
</Link>
|
||||
<Link href="/intern/gerichte" className="hover:underline">
|
||||
Gerichte
|
||||
</Link>
|
||||
<Link href="/intern/kennzeichnung" className="hover:underline">
|
||||
Allergene & Zusatzstoffe
|
||||
</Link>
|
||||
<Link href="/intern/konto" className="hover:underline">
|
||||
Passkeys
|
||||
</Link>
|
||||
{profile.role === "admin" && (
|
||||
<Link href="/admin" className="hover:underline">
|
||||
Verwaltung
|
||||
</Link>
|
||||
)}
|
||||
<Link href="/" className="hover:underline">
|
||||
Zur Speisekarte
|
||||
</Link>
|
||||
</nav>
|
||||
<div className="ml-auto flex items-center gap-3 text-sm">
|
||||
<span className="text-white/70">
|
||||
{profile.full_name || user.email}
|
||||
</span>
|
||||
<form action="/logout" method="post">
|
||||
<button type="submit" className="btn btn-del">
|
||||
Abmelden
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<main className="max-w-[1600px] mx-auto w-full px-4 py-6 flex-1">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user