diff --git a/src/app/api/proxy-flag-commune/[codeCommune]/route.ts b/src/app/api/proxy-flag-commune/[codeCommune]/route.ts new file mode 100644 index 000000000..b79d610e6 --- /dev/null +++ b/src/app/api/proxy-flag-commune/[codeCommune]/route.ts @@ -0,0 +1,9 @@ +import { getCommuneFlag } from '@/lib/api-blasons-communes' +import { NextRequest, NextResponse } from 'next/server' + +export async function GET(request: NextRequest, { params }: { params: { codeCommune: string } }) { + const { codeCommune } = params + const flagUrl = await getCommuneFlag(codeCommune) + + return NextResponse.json(flagUrl) +} diff --git a/src/app/commune/[codeCommune]/page.styles.tsx b/src/app/commune/[codeCommune]/page.styles.tsx index cdc9613bf..f0b598e23 100644 --- a/src/app/commune/[codeCommune]/page.styles.tsx +++ b/src/app/commune/[codeCommune]/page.styles.tsx @@ -13,6 +13,7 @@ export const StyledCommunePage = styled.div<{ $certificationPercentage: number } margin-bottom: 2rem; .commune-general-info { + line-height: normal; display: flex; flex-direction: column; align-items: center; diff --git a/src/app/commune/[codeCommune]/page.tsx b/src/app/commune/[codeCommune]/page.tsx index 2b230d0e5..ab1897f4f 100644 --- a/src/app/commune/[codeCommune]/page.tsx +++ b/src/app/commune/[codeCommune]/page.tsx @@ -5,7 +5,6 @@ import { Table } from '@codegouvfr/react-dsfr/Table' import CardWrapper from '@/components/CardWrapper' import Section from '@/components/Section' import { - getBanItem, getDistrict, getCommune as getBANCommune, assemblageSources, @@ -14,7 +13,7 @@ import { formatFr } from '@/lib/array' import { getRevisionDetails, getRevisions } from '@/lib/api-depot' import { getMairiePageURL } from '@/lib/api-etablissement-public' import { getCommune as getAPIGeoCommune, getEPCI } from '@/lib/api-geo' -import { getCommuneFlag } from '@/lib/api-wikidata' +import { getCommuneFlag } from '@/lib/api-blasons-communes' import { CommuneDownloadSection } from '../../../components/Commune/CommuneDownloadSection' import { CommuneNavigation } from '../../../components/Commune/CommuneNavigation' diff --git a/src/app/deploiement-bal/page.tsx b/src/app/deploiement-bal/page.tsx index 7ccd53232..32922ae2f 100644 --- a/src/app/deploiement-bal/page.tsx +++ b/src/app/deploiement-bal/page.tsx @@ -1,39 +1,21 @@ -import { getDepartements, getEPCI } from '@/lib/api-geo' -import departementCenterMap from '@/data/departement-center.json' +import { getEPCI } from '@/lib/api-geo' +import departements from '@/data/departement-center.json' import { getStats } from '@/lib/api-ban' import DeploiementBALDashboard from '../../components/DeploiementBAL/DeploiementBALDashboard' import Section from '@/components/Section' import { mapToSearchResult } from '@/lib/deploiement-stats' - -export type DeploiementBALSearchResultEPCI = { - type: 'EPCI' - code: string - nom: string - center: { type: string, coordinates: [number, number] } - contour: { type: string, coordinates: number[][][] } -} - -export type DeploiementBALSearchResultDepartement = { - type: 'Département' - code: string - nom: string - center: { type: string, coordinates: [number, number] } -} - -export type DeploiementBALSearchResult = DeploiementBALSearchResultEPCI | DeploiementBALSearchResultDepartement +import { DeploiementBALSearchResult } from '@/hooks/useStatsDeploiement' +import { Departement } from '@/types/api-geo.types' export default async function DeploiementBALPage({ searchParams }: { searchParams: Record }) { const stats = await getStats() - const departements = await getDepartements() - const departementsWithCenter = departements.map(({ code, ...rest }) => { - const { geometry } = (departementCenterMap as any)[code] - + const departementsWithCenter = Object.values(departements).map(({ properties, geometry }) => { return { - ...rest, - code, + ...properties, + type: 'Département', centre: geometry, } - }) + }) as (Departement & { centre: { type: string, coordinates: number[] } })[] let initialFilter: DeploiementBALSearchResult | null = null if (searchParams.departement) { diff --git a/src/app/outils/formulaire-de-publication/page.tsx b/src/app/outils/formulaire-de-publication/page.tsx index 5bb96e85c..086a93c41 100644 --- a/src/app/outils/formulaire-de-publication/page.tsx +++ b/src/app/outils/formulaire-de-publication/page.tsx @@ -1,7 +1,7 @@ import Loader from '@/components/Loader' import dynamic from 'next/dynamic' import { getCommune } from '@/lib/api-geo' -import { getCommuneFlag } from '@/lib/api-wikidata' +import { getCommuneFlag } from '@/lib/api-blasons-communes' import { getHabilitation, getRevision } from '@/lib/api-depot' import { Habilitation, Revision } from '@/types/api-depot.types' import { Commune } from '@/types/api-geo.types' diff --git a/src/app/outils/page.tsx b/src/app/outils/page.tsx index 145f325cb..a54dbfa96 100644 --- a/src/app/outils/page.tsx +++ b/src/app/outils/page.tsx @@ -1,5 +1,4 @@ import { Suspense } from 'react' -import { CallOut } from '@codegouvfr/react-dsfr/CallOut' import Button from '@codegouvfr/react-dsfr/Button' import Card from '@codegouvfr/react-dsfr/Card' diff --git a/src/components/DeploiementBAL/DeploiementBALDashboard.tsx b/src/components/DeploiementBAL/DeploiementBALDashboard.tsx index 1dc5ecc65..91ebac969 100644 --- a/src/components/DeploiementBAL/DeploiementBALDashboard.tsx +++ b/src/components/DeploiementBAL/DeploiementBALDashboard.tsx @@ -1,7 +1,7 @@ 'use client' import AutocompleteInput from '@/components/Autocomplete/AutocompleteInput' -import { useStatsDeploiement } from '@/hooks/useStatsDeploiement' +import { DeploiementBALSearchResult, useStatsDeploiement } from '@/hooks/useStatsDeploiement' import { getEpcis } from '@/lib/api-geo' import { BANStats } from '@/types/api-ban.types' import { Departement } from '@/types/api-geo.types' @@ -12,7 +12,6 @@ import { StyledDeploiementBALDashboard } from './DeploiementBALDashboard.styles' import { Tabs } from '@codegouvfr/react-dsfr/Tabs' import TabMesAdresses from './TabMesAdresses' import DeploiementMap, { getStyle } from './DeploiementMap' -import { DeploiementBALSearchResult } from '@/app/deploiement-bal/page' import { usePathname, useRouter, useSearchParams } from 'next/navigation' import { mapToSearchResult } from '@/lib/deploiement-stats' import { FullScreenControl } from '../Map/FullScreenControl' @@ -20,7 +19,7 @@ import { FullScreenControl } from '../Map/FullScreenControl' interface DeploiementBALMapProps { initialStats: BANStats initialFilter: DeploiementBALSearchResult | null - departements: (Departement & { centre: { type: string, coordinates: [number, number] } })[] + departements: (Departement & { centre: { type: string, coordinates: number[] } })[] } export default function DeploiementBALMap({ initialStats, initialFilter, departements }: DeploiementBALMapProps) { diff --git a/src/components/DeploiementBAL/DeploiementMap.tsx b/src/components/DeploiementBAL/DeploiementMap.tsx index cbe02a43e..97d86619d 100644 --- a/src/components/DeploiementBAL/DeploiementMap.tsx +++ b/src/components/DeploiementBAL/DeploiementMap.tsx @@ -2,7 +2,6 @@ import React, { useCallback, useEffect, useState } from 'react' import styled from 'styled-components' import { MapMouseEvent, Popup, useMap } from 'react-map-gl/maplibre' import { toolsColors } from '@/theme/theme' -import Link from 'next/link' const StyledWrapper = styled.div` .legend-wrapper { @@ -288,7 +287,7 @@ export default function DeploiementMap({ center, zoom, filteredCodesCommmune, se
Nombre d’adresses : {popup.properties.nbNumeros}
{`${popup.properties.certificationPercentage ? `Taux de certification : ${popup.properties.certificationPercentage}%` : 'Aucune adresse n’est certifiée par la commune'}`}
{popup.properties.hasBAL ?
Déposé via : {popup.properties.nomClient}
:
Ne dispose pas d'une BAL
} - Voir la page commune + Voir la page commune )} diff --git a/src/components/DeploiementBAL/TabDeploiementBAL.tsx b/src/components/DeploiementBAL/TabDeploiementBAL.tsx index d8b9b753f..1142ad4f9 100644 --- a/src/components/DeploiementBAL/TabDeploiementBAL.tsx +++ b/src/components/DeploiementBAL/TabDeploiementBAL.tsx @@ -1,7 +1,7 @@ 'use client' -import { DeploiementBALSearchResult } from '@/app/deploiement-bal/page' import DoughnutCounter from '@/components/ChartJS/DoughnutCounter' +import { DeploiementBALSearchResult } from '@/hooks/useStatsDeploiement' import { customFetch } from '@/lib/fetch' import { BANStats } from '@/types/api-ban.types' import { numFormater } from '@/utils/number' diff --git a/src/components/Events/EventCard.styles.ts b/src/components/Events/EventCard.styles.ts index d3686a653..430d80ace 100644 --- a/src/components/Events/EventCard.styles.ts +++ b/src/components/Events/EventCard.styles.ts @@ -2,10 +2,11 @@ import styled from 'styled-components' -export const StyledEventCard = styled.div<{ $isPassed?: boolean }>` +export const StyledEventCard = styled.div<{ $isPassed?: boolean, $backgroundColor?: string }>` padding: 32px; border: 1px solid ${({ theme }) => theme.colors.grey.border}; ${({ $isPassed }) => $isPassed && 'opacity: 0.5;'} + ${({ $backgroundColor }) => $backgroundColor && `background-color: ${$backgroundColor};`} .event-details { color: ${({ theme }) => theme.colors.primary.main}; diff --git a/src/components/Events/EventCard.tsx b/src/components/Events/EventCard.tsx index c54380293..09f30991d 100644 --- a/src/components/Events/EventCard.tsx +++ b/src/components/Events/EventCard.tsx @@ -1,6 +1,6 @@ 'use client' -import { EventType } from '@/types/events.types' +import { EventType, EventTypeTypeEnum } from '@/types/events.types' import { StyledEventCard } from './EventCard.styles' import Badge from '@codegouvfr/react-dsfr/Badge' import { getFullDate } from '@/utils/date' @@ -12,12 +12,18 @@ interface EventCardProps { isPassed?: boolean } +const backgroundColors: Record = { + [EventTypeTypeEnum.FORMATION]: 'rgba(136, 213, 156, 0.1)', + [EventTypeTypeEnum.FORMATION_LVL2]: 'rgba(136, 213, 156, 0.25)', +} + export default function EventCard({ event, isPassed, tagToColor }: EventCardProps) { - const { tags, title, description, startHour, endHour, date, address, isOnlineOnly, isSubscriptionClosed, href } = event + const { tags, title, description, startHour, endHour, date, address, isSubscriptionClosed, href, type } = event - const hasLargeDescription = description.length > 200 + const hasLargeDescription = description.length > 100 const [showAllDescription, setShowAllDescription] = useState(!hasLargeDescription) - const actualDescription = showAllDescription ? description : description.slice(0, 200) + '...' + const actualDescription = showAllDescription ? description : description.slice(0, 100) + '...' + const backgroundColor = backgroundColors[type] const getAdressToString = (adress: EventType['address']) => { if (!adress) return '' @@ -25,7 +31,7 @@ export default function EventCard({ event, isPassed, tagToColor }: EventCardProp } return ( - +
<>{tags.map(tag => {tag})}
@@ -34,7 +40,7 @@ export default function EventCard({ event, isPassed, tagToColor }: EventCardProp {getFullDate(new Date(date))} {' | '} {startHour} - {endHour} - {isOnlineOnly ? | En ligne : address ? | {getAdressToString(address)} : null} + {address?.commune ? | {getAdressToString(address)} : null}

{title}

diff --git a/src/components/FormulaireDePublication/index.tsx b/src/components/FormulaireDePublication/index.tsx index d48b730d7..6146c54eb 100644 --- a/src/components/FormulaireDePublication/index.tsx +++ b/src/components/FormulaireDePublication/index.tsx @@ -12,7 +12,7 @@ import { Commune } from '@/types/api-geo.types' import { validateHabilitationPinCode, createHabilitation, createRevision, getHabilitation, sendHabilitationPinCode, getCurrentRevision, publishRevision } from '@/lib/api-depot' import Alert from '@codegouvfr/react-dsfr/Alert' import Image from 'next/image' -import { getCommuneFlag } from '@/lib/api-wikidata' +import { getCommuneFlag } from '@/lib/api-blasons-communes' import { HabilitationMethod } from './steps/HablitationMethod' import { Habilitation, HabilitationStatus, Revision } from '@/types/api-depot.types' import { PinCodeValidation } from './steps/PinCodeValidation' diff --git a/src/data/departement-center.json b/src/data/departement-center.json index 6169af364..2cb4dc603 100644 --- a/src/data/departement-center.json +++ b/src/data/departement-center.json @@ -4,7 +4,7 @@ "properties": { "code": "01", "nom": "Ain", - "region": "84" + "codeRegion": "84" }, "geometry": { "type": "Point", @@ -16,7 +16,7 @@ "properties": { "code": "02", "nom": "Aisne", - "region": "32" + "codeRegion": "32" }, "geometry": { "type": "Point", @@ -28,7 +28,7 @@ "properties": { "code": "03", "nom": "Allier", - "region": "84" + "codeRegion": "84" }, "geometry": { "type": "Point", @@ -40,7 +40,7 @@ "properties": { "code": "04", "nom": "Alpes-de-Haute-Provence", - "region": "93" + "codeRegion": "93" }, "geometry": { "type": "Point", @@ -52,7 +52,7 @@ "properties": { "code": "05", "nom": "Hautes-Alpes", - "region": "93" + "codeRegion": "93" }, "geometry": { "type": "Point", @@ -64,7 +64,7 @@ "properties": { "code": "06", "nom": "Alpes-Maritimes", - "region": "93" + "codeRegion": "93" }, "geometry": { "type": "Point", @@ -76,7 +76,7 @@ "properties": { "code": "07", "nom": "Ardèche", - "region": "84" + "codeRegion": "84" }, "geometry": { "type": "Point", @@ -88,7 +88,7 @@ "properties": { "code": "08", "nom": "Ardennes", - "region": "44" + "codeRegion": "44" }, "geometry": { "type": "Point", @@ -100,7 +100,7 @@ "properties": { "code": "09", "nom": "Ariège", - "region": "76" + "codeRegion": "76" }, "geometry": { "type": "Point", @@ -112,7 +112,7 @@ "properties": { "code": "10", "nom": "Aube", - "region": "44" + "codeRegion": "44" }, "geometry": { "type": "Point", @@ -124,7 +124,7 @@ "properties": { "code": "11", "nom": "Aude", - "region": "76" + "codeRegion": "76" }, "geometry": { "type": "Point", @@ -136,7 +136,7 @@ "properties": { "code": "12", "nom": "Aveyron", - "region": "76" + "codeRegion": "76" }, "geometry": { "type": "Point", @@ -148,7 +148,7 @@ "properties": { "code": "13", "nom": "Bouches-du-Rhône", - "region": "93" + "codeRegion": "93" }, "geometry": { "type": "Point", @@ -160,7 +160,7 @@ "properties": { "code": "14", "nom": "Calvados", - "region": "28" + "codeRegion": "28" }, "geometry": { "type": "Point", @@ -172,7 +172,7 @@ "properties": { "code": "15", "nom": "Cantal", - "region": "84" + "codeRegion": "84" }, "geometry": { "type": "Point", @@ -184,7 +184,7 @@ "properties": { "code": "16", "nom": "Charente", - "region": "75" + "codeRegion": "75" }, "geometry": { "type": "Point", @@ -196,7 +196,7 @@ "properties": { "code": "17", "nom": "Charente-Maritime", - "region": "75" + "codeRegion": "75" }, "geometry": { "type": "Point", @@ -208,7 +208,7 @@ "properties": { "code": "18", "nom": "Cher", - "region": "24" + "codeRegion": "24" }, "geometry": { "type": "Point", @@ -220,7 +220,7 @@ "properties": { "code": "19", "nom": "Corrèze", - "region": "75" + "codeRegion": "75" }, "geometry": { "type": "Point", @@ -232,7 +232,7 @@ "properties": { "code": "21", "nom": "Côte-d'Or", - "region": "27" + "codeRegion": "27" }, "geometry": { "type": "Point", @@ -244,7 +244,7 @@ "properties": { "code": "22", "nom": "Côtes-d'Armor", - "region": "53" + "codeRegion": "53" }, "geometry": { "type": "Point", @@ -256,7 +256,7 @@ "properties": { "code": "23", "nom": "Creuse", - "region": "75" + "codeRegion": "75" }, "geometry": { "type": "Point", @@ -268,7 +268,7 @@ "properties": { "code": "24", "nom": "Dordogne", - "region": "75" + "codeRegion": "75" }, "geometry": { "type": "Point", @@ -280,7 +280,7 @@ "properties": { "code": "25", "nom": "Doubs", - "region": "27" + "codeRegion": "27" }, "geometry": { "type": "Point", @@ -292,7 +292,7 @@ "properties": { "code": "26", "nom": "Drôme", - "region": "84" + "codeRegion": "84" }, "geometry": { "type": "Point", @@ -304,7 +304,7 @@ "properties": { "code": "27", "nom": "Eure", - "region": "28" + "codeRegion": "28" }, "geometry": { "type": "Point", @@ -316,7 +316,7 @@ "properties": { "code": "28", "nom": "Eure-et-Loir", - "region": "24" + "codeRegion": "24" }, "geometry": { "type": "Point", @@ -328,7 +328,7 @@ "properties": { "code": "29", "nom": "Finistère", - "region": "53" + "codeRegion": "53" }, "geometry": { "type": "Point", @@ -340,7 +340,7 @@ "properties": { "code": "2A", "nom": "Corse-du-Sud", - "region": "94" + "codeRegion": "94" }, "geometry": { "type": "Point", @@ -352,7 +352,7 @@ "properties": { "code": "2B", "nom": "Haute-Corse", - "region": "94" + "codeRegion": "94" }, "geometry": { "type": "Point", @@ -364,7 +364,7 @@ "properties": { "code": "30", "nom": "Gard", - "region": "76" + "codeRegion": "76" }, "geometry": { "type": "Point", @@ -376,7 +376,7 @@ "properties": { "code": "31", "nom": "Haute-Garonne", - "region": "76" + "codeRegion": "76" }, "geometry": { "type": "Point", @@ -388,7 +388,7 @@ "properties": { "code": "32", "nom": "Gers", - "region": "76" + "codeRegion": "76" }, "geometry": { "type": "Point", @@ -400,7 +400,7 @@ "properties": { "code": "33", "nom": "Gironde", - "region": "75" + "codeRegion": "75" }, "geometry": { "type": "Point", @@ -412,7 +412,7 @@ "properties": { "code": "34", "nom": "Hérault", - "region": "76" + "codeRegion": "76" }, "geometry": { "type": "Point", @@ -424,7 +424,7 @@ "properties": { "code": "35", "nom": "Ille-et-Vilaine", - "region": "53" + "codeRegion": "53" }, "geometry": { "type": "Point", @@ -436,7 +436,7 @@ "properties": { "code": "36", "nom": "Indre", - "region": "24" + "codeRegion": "24" }, "geometry": { "type": "Point", @@ -448,7 +448,7 @@ "properties": { "code": "37", "nom": "Indre-et-Loire", - "region": "24" + "codeRegion": "24" }, "geometry": { "type": "Point", @@ -460,7 +460,7 @@ "properties": { "code": "38", "nom": "Isère", - "region": "84" + "codeRegion": "84" }, "geometry": { "type": "Point", @@ -472,7 +472,7 @@ "properties": { "code": "39", "nom": "Jura", - "region": "27" + "codeRegion": "27" }, "geometry": { "type": "Point", @@ -484,7 +484,7 @@ "properties": { "code": "40", "nom": "Landes", - "region": "75" + "codeRegion": "75" }, "geometry": { "type": "Point", @@ -496,7 +496,7 @@ "properties": { "code": "41", "nom": "Loir-et-Cher", - "region": "24" + "codeRegion": "24" }, "geometry": { "type": "Point", @@ -508,7 +508,7 @@ "properties": { "code": "42", "nom": "Loire", - "region": "84" + "codeRegion": "84" }, "geometry": { "type": "Point", @@ -520,7 +520,7 @@ "properties": { "code": "43", "nom": "Haute-Loire", - "region": "84" + "codeRegion": "84" }, "geometry": { "type": "Point", @@ -532,7 +532,7 @@ "properties": { "code": "44", "nom": "Loire-Atlantique", - "region": "52" + "codeRegion": "52" }, "geometry": { "type": "Point", @@ -544,7 +544,7 @@ "properties": { "code": "45", "nom": "Loiret", - "region": "24" + "codeRegion": "24" }, "geometry": { "type": "Point", @@ -556,7 +556,7 @@ "properties": { "code": "46", "nom": "Lot", - "region": "76" + "codeRegion": "76" }, "geometry": { "type": "Point", @@ -568,7 +568,7 @@ "properties": { "code": "47", "nom": "Lot-et-Garonne", - "region": "75" + "codeRegion": "75" }, "geometry": { "type": "Point", @@ -580,7 +580,7 @@ "properties": { "code": "48", "nom": "Lozère", - "region": "76" + "codeRegion": "76" }, "geometry": { "type": "Point", @@ -592,7 +592,7 @@ "properties": { "code": "49", "nom": "Maine-et-Loire", - "region": "52" + "codeRegion": "52" }, "geometry": { "type": "Point", @@ -604,7 +604,7 @@ "properties": { "code": "50", "nom": "Manche", - "region": "28" + "codeRegion": "28" }, "geometry": { "type": "Point", @@ -616,7 +616,7 @@ "properties": { "code": "51", "nom": "Marne", - "region": "44" + "codeRegion": "44" }, "geometry": { "type": "Point", @@ -628,7 +628,7 @@ "properties": { "code": "52", "nom": "Haute-Marne", - "region": "44" + "codeRegion": "44" }, "geometry": { "type": "Point", @@ -640,7 +640,7 @@ "properties": { "code": "53", "nom": "Mayenne", - "region": "52" + "codeRegion": "52" }, "geometry": { "type": "Point", @@ -652,7 +652,7 @@ "properties": { "code": "54", "nom": "Meurthe-et-Moselle", - "region": "44" + "codeRegion": "44" }, "geometry": { "type": "Point", @@ -664,7 +664,7 @@ "properties": { "code": "55", "nom": "Meuse", - "region": "44" + "codeRegion": "44" }, "geometry": { "type": "Point", @@ -676,7 +676,7 @@ "properties": { "code": "56", "nom": "Morbihan", - "region": "53" + "codeRegion": "53" }, "geometry": { "type": "Point", @@ -688,7 +688,7 @@ "properties": { "code": "57", "nom": "Moselle", - "region": "44" + "codeRegion": "44" }, "geometry": { "type": "Point", @@ -700,7 +700,7 @@ "properties": { "code": "58", "nom": "Nièvre", - "region": "27" + "codeRegion": "27" }, "geometry": { "type": "Point", @@ -712,7 +712,7 @@ "properties": { "code": "59", "nom": "Nord", - "region": "32" + "codeRegion": "32" }, "geometry": { "type": "Point", @@ -724,7 +724,7 @@ "properties": { "code": "60", "nom": "Oise", - "region": "32" + "codeRegion": "32" }, "geometry": { "type": "Point", @@ -736,7 +736,7 @@ "properties": { "code": "61", "nom": "Orne", - "region": "28" + "codeRegion": "28" }, "geometry": { "type": "Point", @@ -748,7 +748,7 @@ "properties": { "code": "62", "nom": "Pas-de-Calais", - "region": "32" + "codeRegion": "32" }, "geometry": { "type": "Point", @@ -760,7 +760,7 @@ "properties": { "code": "63", "nom": "Puy-de-Dôme", - "region": "84" + "codeRegion": "84" }, "geometry": { "type": "Point", @@ -772,7 +772,7 @@ "properties": { "code": "64", "nom": "Pyrénées-Atlantiques", - "region": "75" + "codeRegion": "75" }, "geometry": { "type": "Point", @@ -784,7 +784,7 @@ "properties": { "code": "65", "nom": "Hautes-Pyrénées", - "region": "76" + "codeRegion": "76" }, "geometry": { "type": "Point", @@ -796,7 +796,7 @@ "properties": { "code": "66", "nom": "Pyrénées-Orientales", - "region": "76" + "codeRegion": "76" }, "geometry": { "type": "Point", @@ -808,7 +808,7 @@ "properties": { "code": "67", "nom": "Bas-Rhin", - "region": "44" + "codeRegion": "44" }, "geometry": { "type": "Point", @@ -820,7 +820,7 @@ "properties": { "code": "68", "nom": "Haut-Rhin", - "region": "44" + "codeRegion": "44" }, "geometry": { "type": "Point", @@ -832,7 +832,7 @@ "properties": { "code": "69", "nom": "Rhône", - "region": "84" + "codeRegion": "84" }, "geometry": { "type": "Point", @@ -844,7 +844,7 @@ "properties": { "code": "70", "nom": "Haute-Saône", - "region": "27" + "codeRegion": "27" }, "geometry": { "type": "Point", @@ -856,7 +856,7 @@ "properties": { "code": "71", "nom": "Saône-et-Loire", - "region": "27" + "codeRegion": "27" }, "geometry": { "type": "Point", @@ -868,7 +868,7 @@ "properties": { "code": "72", "nom": "Sarthe", - "region": "52" + "codeRegion": "52" }, "geometry": { "type": "Point", @@ -880,7 +880,7 @@ "properties": { "code": "73", "nom": "Savoie", - "region": "84" + "codeRegion": "84" }, "geometry": { "type": "Point", @@ -892,7 +892,7 @@ "properties": { "code": "74", "nom": "Haute-Savoie", - "region": "84" + "codeRegion": "84" }, "geometry": { "type": "Point", @@ -904,7 +904,7 @@ "properties": { "code": "75", "nom": "Paris", - "region": "11" + "codeRegion": "11" }, "geometry": { "type": "Point", @@ -916,7 +916,7 @@ "properties": { "code": "76", "nom": "Seine-Maritime", - "region": "28" + "codeRegion": "28" }, "geometry": { "type": "Point", @@ -928,7 +928,7 @@ "properties": { "code": "77", "nom": "Seine-et-Marne", - "region": "11" + "codeRegion": "11" }, "geometry": { "type": "Point", @@ -940,7 +940,7 @@ "properties": { "code": "78", "nom": "Yvelines", - "region": "11" + "codeRegion": "11" }, "geometry": { "type": "Point", @@ -952,7 +952,7 @@ "properties": { "code": "79", "nom": "Deux-Sèvres", - "region": "75" + "codeRegion": "75" }, "geometry": { "type": "Point", @@ -964,7 +964,7 @@ "properties": { "code": "80", "nom": "Somme", - "region": "32" + "codeRegion": "32" }, "geometry": { "type": "Point", @@ -976,7 +976,7 @@ "properties": { "code": "81", "nom": "Tarn", - "region": "76" + "codeRegion": "76" }, "geometry": { "type": "Point", @@ -988,7 +988,7 @@ "properties": { "code": "82", "nom": "Tarn-et-Garonne", - "region": "76" + "codeRegion": "76" }, "geometry": { "type": "Point", @@ -1000,7 +1000,7 @@ "properties": { "code": "83", "nom": "Var", - "region": "93" + "codeRegion": "93" }, "geometry": { "type": "Point", @@ -1012,7 +1012,7 @@ "properties": { "code": "84", "nom": "Vaucluse", - "region": "93" + "codeRegion": "93" }, "geometry": { "type": "Point", @@ -1024,7 +1024,7 @@ "properties": { "code": "85", "nom": "Vendée", - "region": "52" + "codeRegion": "52" }, "geometry": { "type": "Point", @@ -1036,7 +1036,7 @@ "properties": { "code": "86", "nom": "Vienne", - "region": "75" + "codeRegion": "75" }, "geometry": { "type": "Point", @@ -1048,7 +1048,7 @@ "properties": { "code": "87", "nom": "Haute-Vienne", - "region": "75" + "codeRegion": "75" }, "geometry": { "type": "Point", @@ -1060,7 +1060,7 @@ "properties": { "code": "88", "nom": "Vosges", - "region": "44" + "codeRegion": "44" }, "geometry": { "type": "Point", @@ -1072,7 +1072,7 @@ "properties": { "code": "89", "nom": "Yonne", - "region": "27" + "codeRegion": "27" }, "geometry": { "type": "Point", @@ -1084,7 +1084,7 @@ "properties": { "code": "90", "nom": "Territoire de Belfort", - "region": "27" + "codeRegion": "27" }, "geometry": { "type": "Point", @@ -1096,7 +1096,7 @@ "properties": { "code": "91", "nom": "Essonne", - "region": "11" + "codeRegion": "11" }, "geometry": { "type": "Point", @@ -1108,7 +1108,7 @@ "properties": { "code": "92", "nom": "Hauts-de-Seine", - "region": "11" + "codeRegion": "11" }, "geometry": { "type": "Point", @@ -1120,7 +1120,7 @@ "properties": { "code": "93", "nom": "Seine-Saint-Denis", - "region": "11" + "codeRegion": "11" }, "geometry": { "type": "Point", @@ -1132,7 +1132,7 @@ "properties": { "code": "94", "nom": "Val-de-Marne", - "region": "11" + "codeRegion": "11" }, "geometry": { "type": "Point", @@ -1144,7 +1144,7 @@ "properties": { "code": "95", "nom": "Val-d'Oise", - "region": "11" + "codeRegion": "11" }, "geometry": { "type": "Point", @@ -1156,7 +1156,7 @@ "properties": { "code": "971", "nom": "Guadeloupe", - "region": "01" + "codeRegion": "01" }, "geometry": { "type": "Point", @@ -1168,7 +1168,7 @@ "properties": { "code": "972", "nom": "Martinique", - "region": "02" + "codeRegion": "02" }, "geometry": { "type": "Point", @@ -1180,7 +1180,7 @@ "properties": { "code": "973", "nom": "Guyane", - "region": "03" + "codeRegion": "03" }, "geometry": { "type": "Point", @@ -1192,7 +1192,7 @@ "properties": { "code": "974", "nom": "La Réunion", - "region": "04" + "codeRegion": "04" }, "geometry": { "type": "Point", @@ -1204,7 +1204,7 @@ "properties": { "code": "976", "nom": "Mayotte", - "region": "06" + "codeRegion": "06" }, "geometry": { "type": "Point", @@ -1216,7 +1216,7 @@ "properties": { "code": "975", "nom": "Saint-Pierre-et-Miquelon", - "region": "975" + "codeRegion": "975" }, "geometry": { "type": "Point", @@ -1228,7 +1228,7 @@ "properties": { "code": "977", "nom": "Saint-Barthélemy", - "region": "977" + "codeRegion": "977" }, "geometry": { "type": "Point", @@ -1240,7 +1240,7 @@ "properties": { "code": "978", "nom": "Saint-Martin", - "region": "978" + "codeRegion": "978" }, "geometry": { "type": "Point", @@ -1252,7 +1252,7 @@ "properties": { "code": "984", "nom": "Terres australes et antarctiques françaises", - "region": "984" + "codeRegion": "984" }, "geometry": { "type": "Point", @@ -1264,7 +1264,7 @@ "properties": { "code": "986", "nom": "Wallis et Futuna", - "region": "986" + "codeRegion": "986" }, "geometry": { "type": "Point", @@ -1276,7 +1276,7 @@ "properties": { "code": "987", "nom": "Polynésie française", - "region": "987" + "codeRegion": "987" }, "geometry": { "type": "Point", @@ -1288,7 +1288,7 @@ "properties": { "code": "988", "nom": "Nouvelle-Calédonie", - "region": "988" + "codeRegion": "988" }, "geometry": { "type": "Point", @@ -1300,7 +1300,7 @@ "properties": { "code": "989", "nom": "Île de Clipperton", - "region": "989" + "codeRegion": "989" }, "geometry": { "type": "Point", diff --git a/src/hooks/useStatsDeploiement.ts b/src/hooks/useStatsDeploiement.ts index bb216a6a2..dc18e06ae 100644 --- a/src/hooks/useStatsDeploiement.ts +++ b/src/hooks/useStatsDeploiement.ts @@ -4,7 +4,23 @@ import { getEpciCommunes, getDepartementCommunes, getCommunes } from '@/lib/api- import { BANStats } from '@/types/api-ban.types' import { Commune } from '@/types/api-geo.types' import { DEFAULT_CENTER, DEFAULT_ZOOM } from '@/components/Map/map.config' -import { DeploiementBALSearchResult } from '@/app/deploiement-bal/page' + +export type DeploiementBALSearchResultEPCI = { + type: 'EPCI' + code: string + nom: string + center: { type: string, coordinates: [number, number] } + contour: { type: string, coordinates: number[][][] } +} + +export type DeploiementBALSearchResultDepartement = { + type: 'Département' + code: string + nom: string + center: { type: string, coordinates: [number, number] } +} + +export type DeploiementBALSearchResult = DeploiementBALSearchResultEPCI | DeploiementBALSearchResultDepartement const communesWithArrondissements = { 75056: 'Paris', 69123: 'Lyon', 13055: 'Marseille' } diff --git a/src/lib/api-blasons-communes.ts b/src/lib/api-blasons-communes.ts new file mode 100644 index 000000000..d6e3b8ae7 --- /dev/null +++ b/src/lib/api-blasons-communes.ts @@ -0,0 +1,24 @@ +const BASE_URL = 'https://base-adresse-locale-prod-blasons-communes.s3.fr-par.scw.cloud' + +const DEFAULT_URL_DISTRICT_FLAG = '/commune/default-logo.svg' + +// Fetch the commune flag from a proxy for front-end to avoid CORS issues +export const getCommuneFlagProxy = async (codeCommune: string): Promise => { + const response = await fetch(`/api/proxy-flag-commune/${codeCommune}`) + + return response.json() +} + +export const getCommuneFlag = async (codeCommune: string): Promise => { + const url = `${BASE_URL}/${codeCommune}.svg` + + const response = await fetch(url, { + method: 'HEAD', + }) + + if (!response.ok) { + return DEFAULT_URL_DISTRICT_FLAG + } + + return url +} diff --git a/src/lib/deploiement-stats.ts b/src/lib/deploiement-stats.ts index 19a688c10..a72fe1e25 100644 --- a/src/lib/deploiement-stats.ts +++ b/src/lib/deploiement-stats.ts @@ -1,7 +1,7 @@ import { customFetch } from './fetch' import { keyBy, groupBy } from 'lodash' import { getContourCommune } from '../utils/contours-communes' -import { DeploiementBALSearchResult } from '@/app/deploiement-bal/page' +import { DeploiementBALSearchResult } from '@/hooks/useStatsDeploiement' if (!process.env.NEXT_PUBLIC_API_BAN_URL) { throw new Error('NEXT_PUBLIC_API_BAN_URL is not defined in the environment') @@ -136,4 +136,4 @@ export async function computeStats({ currentRevisions, communesSummary, bals }: } } -export const mapToSearchResult = (values: any[], type: 'EPCI' | 'Département'): DeploiementBALSearchResult[] => values.map(({ code, nom, centre, contour }) => ({ code, type, nom, center: centre, contour })) +export const mapToSearchResult = (values: any[], type: DeploiementBALSearchResult['type']): DeploiementBALSearchResult[] => values.map(({ code, nom, centre, contour }) => ({ code, type, nom, center: centre, contour })) diff --git a/src/utils/events.ts b/src/utils/events.ts index c39b24d73..bd3332c37 100644 --- a/src/utils/events.ts +++ b/src/utils/events.ts @@ -11,7 +11,7 @@ export function mapEvents(events: EventType[], typeFilter?: string) { const [hourB, minuteB] = b.startHour.split(':') dateB.setHours(parseInt(hourB), parseInt(minuteB)) - return dateB.getTime() - dateA.getTime() + return dateA.getTime() - dateB.getTime() }) if (typeFilter) {