97f4c1ec24
- Extract AdminShell component (sidebar + wrapper) - admin/layout.tsx uses AdminShell - curator/layout.tsx uses AdminShell for admin role (was rendering children only) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
13 lines
520 B
TypeScript
13 lines
520 B
TypeScript
import { headers } from "next/headers";
|
|
import { auth } from "@/lib/auth";
|
|
import { redirect } from "next/navigation";
|
|
import { AdminShell } from "@/components/admin/admin-shell";
|
|
|
|
export default async function AdminLayout({ children }: { children: React.ReactNode }) {
|
|
const session = await auth.api.getSession({ headers: await headers() });
|
|
if (!session) redirect("/login");
|
|
if (session.user.role !== "admin") redirect("/dashboard");
|
|
|
|
return <AdminShell userName={session.user.name}>{children}</AdminShell>;
|
|
}
|