49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
|
import { Metadata } from "next";
|
||
|
import { notFound } from "next/navigation";
|
||
|
|
||
|
import {
|
||
|
Header,
|
||
|
CommunesList,
|
||
|
DepartementsList,
|
||
|
RegionList,
|
||
|
} from "@/components/index";
|
||
|
|
||
|
import departements, {
|
||
|
getSlugFromDepartement,
|
||
|
getDepartementFromSlug,
|
||
|
} from "@/lib/departements";
|
||
|
import { getRegionFromCode } from "@/lib/regions";
|
||
|
|
||
|
export const metadata: Metadata = {
|
||
|
title: "Annuaire",
|
||
|
description: "L'annuaire collaboratif des professionnels de la santé",
|
||
|
};
|
||
|
|
||
|
export async function generateStaticParams() {
|
||
|
return departements.map((departement) => ({
|
||
|
departement: getSlugFromDepartement(departement),
|
||
|
}));
|
||
|
}
|
||
|
|
||
|
export default function DepartementPage({
|
||
|
params,
|
||
|
}: {
|
||
|
params: { regionSlug: string; departementSlug: string };
|
||
|
}) {
|
||
|
const departement = getDepartementFromSlug(params.departementSlug);
|
||
|
if (!departement) return notFound();
|
||
|
const region = getRegionFromCode(departement.region);
|
||
|
if (!region) return notFound();
|
||
|
|
||
|
return (
|
||
|
<>
|
||
|
<Header searchField={true} />
|
||
|
<RegionList selected={region} />
|
||
|
<hr></hr>
|
||
|
<DepartementsList selected={departement} region={region} />
|
||
|
<hr></hr>
|
||
|
<CommunesList departement={departement} />
|
||
|
</>
|
||
|
);
|
||
|
}
|