import { Metadata } from "next"; import { notFound } from "next/navigation"; import { Header, CommunesList, DepartementsList, RegionList, } from "@/components/index"; import communes, { Commune, getCommuneFromSlug, getSlugFromCommune, getCodesPostaux, getChefLieu, CommuneDeleguee, } from "@/lib/communes"; import { Content, ContentHeader, ContentBody, ContentFull, ContentHalf, } from "@/components/Content/Content"; import departements, { getSlugFromDepartement, getDepartementFromSlug, } from "@/lib/departements"; import { getRegionFromCode, getSlugFromRegion } from "@/lib/regions"; import Link from "next/link"; import { getMSPFromCodesPostaux } from "@/lib/api-annuaire-sante"; export const metadata: Metadata = { title: "Annuaire", description: "L'annuaire collaboratif des professionnels de la santé", }; export async function generateStaticParams() { return communes.map((commune) => ({ commune: getSlugFromCommune(commune), })); } async function getData(codesPostaux: Array) { const res = await fetch( `http://localhost:8000/fhir/v1/Organization?address-postalcode%3Aexact=${codesPostaux.join( "%2C", )}&_count=5000&type=https://mos.esante.gouv.fr/NOS/TRE_R66-CategorieEtablissement/FHIR/TRE-R66-CategorieEtablissement%7C603`, { cache: "force-cache" }, ); // The return value is *not* serialized // You can return Date, Map, Set, etc. if (!res.ok) { // This will activate the closest `error.js` Error Boundary throw new Error("Failed to fetch data"); } return res.json(); } export default async function CommunePage({ params, }: { params: { regionSlug: string; departementSlug: string; communeSlug: string }; }) { const commune = getCommuneFromSlug(params.communeSlug); if (!commune) return notFound(); const departement = getDepartementFromSlug(params.departementSlug); if (!departement) return notFound(); const region = getRegionFromCode(departement.region); if (!region) return notFound(); let chefLieu: Commune | Boolean = commune.chefLieu ? getChefLieu(commune) : false; const codesPostaux = commune.chefLieu ? [commune.chefLieu] : commune.codesPostaux; const msps = await getMSPFromCodesPostaux(codesPostaux); return ( <>

{commune.nom}

{getCodesPostaux(commune)}

{commune.population && ( )} {chefLieu && ( )}
Région {region.nom}
Département {departement.nom} ({departement.code})
Population {commune.population.toLocaleString("fr-FR")} habiants
Cheflieu {chefLieu.nom}
{msps.entry && (

Informations sur les {msps.total} structures

    {msps.entry.map((msp) => (
  • {msp.resource.name}
  • ))}
)}

Dirigeants et représentants de P4PILLON

test


); }