import { redirect } from "next/navigation";
import { AppShell } from "~/components/layout/AppShell.js";
import { auth } from "~/server/auth.js";

export default async function AppLayout({ children }: { children: React.ReactNode }) {
  const session = await auth();

  if (!session?.user) {
    redirect("/auth/signin");
  }

  const userRole = (session.user as { role?: string } | undefined)?.role ?? "USER";
  return <AppShell userRole={userRole}>{children}</AppShell>;
}
