Add platform settings (Stage 9)
- Settings key-value table in Prisma with migration - getSettings() / getSetting() helpers in lib/settings.ts - Admin UI at /admin/settings with 6 sections: General, Notifications, Student profile, Legal docs, Curator permissions, Code injection - saveSettings() server action with admin-only guard - Maintenance mode: non-admin users redirected to /maintenance page - schoolName propagated to page metadata and all email templates - headCode / bodyCode injected into root layout <head> and <body> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,12 +4,19 @@ import { redirect } from "next/navigation";
|
||||
import Link from "next/link";
|
||||
import { LogoutButton } from "@/components/layout/logout-button";
|
||||
import { AdminShell } from "@/components/admin/admin-shell";
|
||||
import { getSetting } from "@/lib/settings";
|
||||
|
||||
export default async function CuratorLayout({ children }: { children: React.ReactNode }) {
|
||||
const session = await auth.api.getSession({ headers: await headers() });
|
||||
if (!session) redirect("/login");
|
||||
if (session.user.role !== "curator" && session.user.role !== "admin") redirect("/dashboard");
|
||||
|
||||
// Maintenance mode: curators (non-admin) see the maintenance page
|
||||
if (session.user.role === "curator") {
|
||||
const maintenance = await getSetting("maintenanceMode");
|
||||
if (maintenance === "true") redirect("/maintenance");
|
||||
}
|
||||
|
||||
// Admin uses the admin shell with sidebar
|
||||
if (session.user.role === "admin") {
|
||||
return <AdminShell userName={session.user.name}>{children}</AdminShell>;
|
||||
|
||||
Reference in New Issue
Block a user