diff --git a/app/annuaire/[regionSlug]/[departementSlug]/[communeSlug]/page.tsx b/app/annuaire/[regionSlug]/[departementSlug]/[communeSlug]/page.tsx new file mode 100644 index 0000000..7bd9c84 --- /dev/null +++ b/app/annuaire/[regionSlug]/[departementSlug]/[communeSlug]/page.tsx @@ -0,0 +1,179 @@ +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 +
+
+ +
+ +
+ + + ); +} diff --git a/app/annuaire/[regionSlug]/[departementSlug]/page.tsx b/app/annuaire/[regionSlug]/[departementSlug]/page.tsx new file mode 100644 index 0000000..a874867 --- /dev/null +++ b/app/annuaire/[regionSlug]/[departementSlug]/page.tsx @@ -0,0 +1,48 @@ +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 ( + <> +
+ +
+ +
+ + + ); +} diff --git a/app/annuaire/[regionSlug]/page.tsx b/app/annuaire/[regionSlug]/page.tsx new file mode 100644 index 0000000..270a0de --- /dev/null +++ b/app/annuaire/[regionSlug]/page.tsx @@ -0,0 +1,85 @@ +import { Metadata } from "next"; +import { notFound } from "next/navigation"; +import regionsCpts from "../../../regions_cpts.json"; + +import regions, { getRegionFromSlug, getSlugFromRegion } from "@/lib/regions"; +import { Header, DepartementsList, RegionList } from "@/components/index"; +import { + Content, + ContentHeader, + ContentBody, + ContentFull, + ContentHalf, +} from "@/components/Content/Content"; +import { getCommuneFromCodePostal } from "@/lib/communes"; +import Link from "next/link"; + +export const metadata: Metadata = { + title: "Annuaire", + description: "L'annuaire collaboratif des professionnels de la santé", +}; + +export async function generateStaticParams() { + return regions.map((region) => ({ + region: getSlugFromRegion(region), + })); +} + +export default function RegionPage({ + params, +}: { + params: { regionSlug: string }; +}) { + const region = getRegionFromSlug(params.regionSlug); + if (!region) return notFound(); + // const nbHabitants = getCommuesFromRegion() + + return ( + <> +
+ + +
+

{region.nom}

+

+ {getCommuneFromCodePostal(region.chefLieu).nom} +

+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Nombre de départements
Nombre d'habitants
Nombre de SISA
Nombre de CPTS
Nombre de SISA
+
+
+ + yep + +
+ +
+ +
+ + ); +} diff --git a/app/annuaire/page.tsx b/app/annuaire/page.tsx new file mode 100644 index 0000000..131a288 --- /dev/null +++ b/app/annuaire/page.tsx @@ -0,0 +1,19 @@ +import { Metadata } from "next"; + +import { Header, Hero, RegionList } from "@/components/index"; + +export const metadata: Metadata = { + title: "Annuaire", + description: "L'annuaire collaboratif des professionnels de la santé", +}; + +export default function DashboardPage() { + return ( + <> +
+ + +
+ + ); +} diff --git a/app/blog/[slug]/page.tsx b/app/blog/[slug]/page.tsx new file mode 100644 index 0000000..2022524 --- /dev/null +++ b/app/blog/[slug]/page.tsx @@ -0,0 +1,123 @@ +import { notFound } from 'next/navigation' +import { CustomMDX } from '@/components/Mdx' +import { formatDate, getBlogPosts } from '@/app/blog/utils' +import { baseUrl } from '@/app/sitemap' + +export async function generateStaticParams() { + let posts = getBlogPosts() + + return posts.map((post) => ({ + slug: post.slug, + })) +} + +export function generateMetadata({ params }) { + let post = getBlogPosts().find((post) => post.slug === params.slug) + if (!post) { + return + } + + let { + title, + publishedAt: publishedTime, + summary: description, + image, + } = post.metadata + let ogImage = image ? image : `${baseUrl}/og?title=${encodeURIComponent(title)}` + + return { + title, + description, + openGraph: { + title, + description, + type: 'article', + publishedTime, + url: `${baseUrl}/blog/${post.slug}`, + images: [ + { + url: ogImage, + }, + ], + }, + twitter: { + card: 'summary_large_image', + title, + description, + images: [ogImage], + }, + } +} + +export default function Blog({ params }) { + let post = getBlogPosts().find((post) => post.slug === params.slug) + + if (!post) { + notFound() + } + + return ( +
+