import type { Metadata } from "next";
import { notFound } from "next/navigation";

import CdcIssueMatrixViewDetailScreen from "@/features/cdc/cdc-issue-matrix/components/view-detail/cdc-issue-matrix-view-detail-screen";

export const metadata: Metadata = {
  title: "CEFP Issue Detail",
};

type PageProps = {
  params: Promise<{
    issueId: string;
  }>;
};

// The same detail screen CDC uses. Its Back button reads the section from the
// address, so it returns to the CEFP list.
export default async function CefpIssueMatrixDetailPage({ params }: PageProps) {
  const { issueId } = await params;
  const id = Number(issueId);

  if (!Number.isFinite(id) || id <= 0) {
    notFound();
  }

  return <CdcIssueMatrixViewDetailScreen issueId={id} />;
}
