import { redirect } from "next/navigation";
import AdminShell from "@/components/admin/AdminShell";
import ContentManager from "@/components/admin/ContentManager";
import { requireAdminSession } from "@/lib/admin/auth";
import { listMediaFiles } from "@/lib/admin/media";
import { getAllContent } from "@/lib/content/service";

export default async function AdminWebsitePage() {
  if (!await requireAdminSession()) redirect("/admin/login");
  const [content, mediaFiles] = await Promise.all([getAllContent(), listMediaFiles()]);

  return (
    <AdminShell>
      <div className="admin-page-head">
        <p className="eyebrow">Website</p>
        <h1>Website-Inhalte</h1>
      </div>
      <ContentManager initialContent={content} mediaFiles={mediaFiles} />
    </AdminShell>
  );
}
