feat: initialize CalBook project with comprehensive scheduling, admin, and deployment infrastructure
This commit is contained in:
26
app/(admin)/admin/layout.tsx
Normal file
26
app/(admin)/admin/layout.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { getServerSession } from "next-auth";
|
||||
import { redirect } from "next/navigation";
|
||||
import { authOptions } from "@/lib/auth/options";
|
||||
import { AdminLayoutClientShell } from "@/components/admin/admin-nav";
|
||||
import { SETTING_KEYS } from "@/lib/constants";
|
||||
import { getSetting } from "@/lib/settings";
|
||||
import { AccentColorScript } from "@/components/layout/accent-color";
|
||||
|
||||
export default async function AdminLayout({ children }: { children: React.ReactNode }) {
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user) redirect("/anmelden");
|
||||
if (session.user.role !== "ADMIN") redirect("/anmelden");
|
||||
|
||||
let accentColor = "#4f46e5";
|
||||
try {
|
||||
const color = await getSetting(SETTING_KEYS.BRANDING_ACCENT_COLOR);
|
||||
if (color && /^#[0-9a-fA-F]{6}$/.test(color)) accentColor = color;
|
||||
} catch { /* default */ }
|
||||
|
||||
return (
|
||||
<>
|
||||
<AccentColorScript color={accentColor} />
|
||||
<AdminLayoutClientShell>{children}</AdminLayoutClientShell>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user