import type { Metadata } from "next";
import { redirect } from "next/navigation";
import { verifyAdminSession } from "@/lib/admin-auth";
import AdminSidebar from "./AdminSidebar";

// Admin panel — never index.
export const metadata: Metadata = {
  robots: { index: false, follow: false },
};

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

  return <AdminSidebar>{children}</AdminSidebar>;
}
