import type { Metadata } from "next";
import { notFound } from "next/navigation";
import ReleaseDetailClient from "./ReleaseDetail";
import { getReleaseDetail } from "@/server/repo";

export const revalidate = 3600;

export async function generateMetadata({ params }: { params: Promise<{ entryId: string; releaseSeq: string }> }): Promise<Metadata> {
  const { entryId, releaseSeq } = await params;
  const data = await getReleaseDetail(Number(entryId), Number(releaseSeq));
  if (!data) return { title: "Release Not Found | ZXDB" };
  return { title: `${data.entry.title} #${releaseSeq} | ZXDB Release` };
}

export default async function Page({ params }: { params: Promise<{ entryId: string; releaseSeq: string }> }) {
  const { entryId, releaseSeq } = await params;
  const data = await getReleaseDetail(Number(entryId), Number(releaseSeq));
  if (!data) notFound();
  return <ReleaseDetailClient data={data} />;
}
