import { prisma } from "@/lib/prisma";
import EditHeroForm from "@/app/secure-panel/hero/[id]/edit/EditHeroForm";

export default async function EditHeroPage({
  params,
}: {
  params: Promise<{ id: string }>;
}) {
  const { id } = await params;

  const hero = await prisma.hero.findUnique({
    where: {
      id: Number(id),
    },
    include: {
      heroimage: {
        orderBy: {
          createdAt: "asc",
        },
      },
    },
  });

  if (!hero) {
    return (
      <main className="container py-5">
        <h1 className="fw-bold">Hero tidak ditemukan</h1>
      </main>
    );
  }

  return (
    <main className="container py-5">

      <EditHeroForm hero={hero} />
    </main>
  );
}