Eine Leiste für alles: Gruppe "Speiseplan" (Wochenplan, Gerichte, Allergene & Zusatzstoffe) und für Admins zusätzlich Gruppe "Verwaltung" (Benutzer, Design). Aktiver Menüpunkt wird hervorgehoben, die Konto-Seite nutzt denselben Header – kein Hin- und Herspringen mehr zwischen Kantinen-Bereich und Verwaltung.
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { redirect } from "next/navigation";
|
|
import { createClient } from "@/lib/supabase/server";
|
|
import AppHeader from "@/components/AppHeader";
|
|
import AccountManager from "@/components/AccountManager";
|
|
|
|
export default async function KontoPage() {
|
|
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">
|
|
<AppHeader
|
|
role={profile.role}
|
|
displayName={profile.full_name || user.email || ""}
|
|
/>
|
|
<main className="max-w-[1600px] mx-auto w-full px-4 py-6 flex-1">
|
|
<AccountManager
|
|
role={profile.role}
|
|
initialFullName={profile.full_name ?? ""}
|
|
initialEmail={user.email ?? ""}
|
|
/>
|
|
</main>
|
|
</div>
|
|
);
|
|
}
|