import { getAdminSession } from "@/lib/admin-session";
import { redirect } from "next/navigation";
import AdminSidebar from "./AdminSidebar";

export default async function AdminLayout({ children }: { children: React.ReactNode }) {
  const session = await getAdminSession();
  if (!session) {
    redirect("/admin/login");
  }

  return (
    <div className="flex min-h-screen bg-stone-100">
      <AdminSidebar username={session.username} role={session.role} />
      <main className="flex-1 p-8">{children}</main>
    </div>
  );
}
