Spaces:
Runtime error
Runtime error
feat: Implement admin moderation history, audit logging for detection actions, and a new admin navigation and opportunity hub.
5480d48 | import { redirect } from "next/navigation"; | |
| import { auth } from "@/lib/auth"; | |
| import { headers } from "next/headers"; | |
| import Link from "next/link"; | |
| import { Shield, BarChart3, ListFilter, Scissors, ArrowLeft } from "lucide-react"; | |
| import { Button } from "@/components/ui/button"; | |
| import { AdminNav } from "./admin-nav"; | |
| import { UserNav } from "@/components/auth/user-nav"; | |
| export default async function AdminLayout({ | |
| children, | |
| }: { | |
| children: React.ReactNode; | |
| }) { | |
| const session = await auth.api.getSession({ | |
| headers: await headers() | |
| }); | |
| const adminEmails = process.env.ADMIN_EMAILS?.split(",") || []; | |
| if (!session?.user?.email || !adminEmails.includes(session.user.email)) { | |
| redirect("/login?callbackUrl=/admin/dashboard"); | |
| } | |
| return ( | |
| <div className="flex min-h-screen flex-col bg-background"> | |
| <header className="sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60"> | |
| <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 flex h-16 items-center gap-4"> | |
| <Link href="/admin/dashboard" className="flex items-center gap-2 font-bold hover:opacity-80 transition-opacity"> | |
| <Shield className="h-5 w-5 text-primary" /> | |
| <span className="hidden sm:inline-block">Vault Admin</span> | |
| </Link> | |
| <AdminNav /> | |
| <div className="ml-auto flex items-center gap-4"> | |
| <Button variant="ghost" size="sm" asChild className="text-muted-foreground hover:text-foreground"> | |
| <Link href="/dashboard"> | |
| <ArrowLeft className="mr-2 h-4 w-4" /> | |
| Exit Admin | |
| </Link> | |
| </Button> | |
| <UserNav /> | |
| </div> | |
| </div> | |
| </header> | |
| <main className="flex-1 max-w-7xl mx-auto w-full px-4 sm:px-6 lg:px-8 py-8"> | |
| {children} | |
| </main> | |
| </div> | |
| ); | |
| } | |