import { redirect } from "next/navigation";
import { auth } from "@/auth";

export default async function AdminRootLayout({
  children,
  params
}: {
  children: React.ReactNode;
  params: Promise<{ lang: string }>;
}) {
  const session = await auth();
  const resolvedParams = await params;

  // Check if user is logged in and is an admin
  if (!session?.user || (session.user as any).role !== "admin") {
    redirect(`/${resolvedParams.lang}/login`);
  }

  return <>{children}</>;
}
