export const associationCommuneOptions = [ { value: "all", label: "Toutes" }, { value: "kourou", label: "Kourou" }, { value: "sinnamary", label: "Sinnamary" }, { value: "iracoubo", label: "Iracoubo" }, { value: "saint_elie", label: "Saint-Élie" }, ] as const; export type AssociationCommuneFilter = (typeof associationCommuneOptions)[number]["value"]; const communeVariantMap: Record, string[]> = { kourou: ["Kourou"], sinnamary: ["Sinnamary"], iracoubo: ["Iracoubo"], saint_elie: ["Saint-Élie", "Saint Elie", "ST ELIE", "St Elie", "St-Élie", "Saint-Elie"], }; export function getAssociationCommuneLabel(value: AssociationCommuneFilter) { return associationCommuneOptions.find(option => option.value === value)?.label ?? "Toutes"; } export function normalizeAssociationCommune(value: string | null | undefined): AssociationCommuneFilter { const normalized = (value || "") .normalize("NFD") .replace(/[\u0300-\u036f]/g, "") .replace(/[-_]/g, " ") .replace(/\s+/g, " ") .trim() .toLowerCase(); if (normalized.includes("saint elie") || normalized.includes("st elie")) return "saint_elie"; if (normalized.includes("kourou")) return "kourou"; if (normalized.includes("sinnamary")) return "sinnamary"; if (normalized.includes("iracoubo")) return "iracoubo"; return "all"; } export function getAssociationCommuneVariants(value?: string | null) { if (!value || value === "all") { return []; } return communeVariantMap[value as Exclude] || []; }