import { redirect } from "next/navigation";
import { getAdminFromSession } from "@/lib/auth";
import { isSeedInstalled } from "@/lib/seed";
import { AdminShell } from "@/app/adminx/AdminShell";

export const dynamic = "force-dynamic";

export const metadata = {
  title: "Dashboard — Admin",
  robots: "noindex, nofollow",
};

export default async function DashboardPage() {
  if (!(await isSeedInstalled())) redirect("/install");
  const admin = await getAdminFromSession();
  if (!admin) redirect("/adminx");

  return (
    <AdminShell
      section="dashboard"
      admin={{
        id: admin.id,
        username: admin.username,
        email: admin.email,
        mustChangePassword: admin.mustChangePassword,
      }}
    />
  );
}
