| 1 | import { headers } from "next/headers"; |
| 2 | import { redirect } from "next/navigation"; |
| 3 | import { getAuth } from "@struxa/auth"; |
| 4 | import { checkSetupComplete } from "@/lib/check-setup"; |
| 5 | import { ThemeProvider } from "@/components/theme-provider"; |
| 6 | |
| 7 | export default async function AdminFullscreenLayout({ children }: { children: React.ReactNode }) { |
| 8 | const complete = await checkSetupComplete(); |
| 9 | if (!complete) redirect("/setup"); |
| 10 | |
| 11 | const auth = await getAuth(); |
| 12 | const session = await auth.api.getSession({ headers: await headers() }); |
| 13 | if (!session || session.user.role !== "admin") redirect("/"); |
| 14 | |
| 15 | return ( |
| 16 | <ThemeProvider attribute="class" forcedTheme="dark" disableTransitionOnChange> |
| 17 | <div className="h-svh overflow-hidden bg-background"> |
| 18 | {children} |
| 19 | </div> |
| 20 | </ThemeProvider> |
| 21 | ); |
| 22 | } |