import ReferentielCRUD from "../../../../app/components/admin/referentiels/ReferentielCRUD";
import { getDefaultValues, referentielSchemas } from "../../../../app/config/referentielSchemas";
import { notFound } from "next/navigation";

export default async function ReferentielType({params}: {params: Promise<{ type: string }>}) {
  const { type } = await params;

  const schema = referentielSchemas[type as keyof typeof referentielSchemas];
  if (!schema) {
    return notFound();
  }
  const emptyForm = getDefaultValues(schema);

  return (
    <ReferentielCRUD
      title={schema.title}
      endpoint={schema.endpoint}
      columns={schema.columns}
      emptyForm={emptyForm}
    />
  );
}