From 7370d9b6315bf525ae6a7d171158e599f0c1fd66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Fri, 2 Feb 2024 17:37:25 +0100 Subject: [PATCH] fix: department with 0 --- .../components/filters/Departments.tsx | 4 +-- webapp-next/utils/map/props.ts | 4 +-- webapp-next/utils/tools.ts | 34 +++++++++---------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/webapp-next/components/filters/Departments.tsx b/webapp-next/components/filters/Departments.tsx index 1ae6d3d..635639a 100644 --- a/webapp-next/components/filters/Departments.tsx +++ b/webapp-next/components/filters/Departments.tsx @@ -76,9 +76,7 @@ export const FiltersDepartments = (props: Props) => { departmentRefs[ department.label as keyof typeof departmentRefs ] - } (${department.label.toString().length > 1 ? '' : `0`}${ - department.label - })` + } (${department.label})` : `Inconnu (${department.label})`} diff --git a/webapp-next/utils/map/props.ts b/webapp-next/utils/map/props.ts index c38c39d..66516bb 100644 --- a/webapp-next/utils/map/props.ts +++ b/webapp-next/utils/map/props.ts @@ -134,8 +134,8 @@ export const getMapProps = ( }; } = {}; departments.forEach(d => { - states[departmentsCodes[d.toString()]] = { - name: `${departmentRefs[d.toString()]} (${getPercentage(d)})`, + states[departmentsCodes[d]] = { + name: `${departmentRefs[d]} (${getPercentage(d)})`, description: getFullDescription(d), color: getColorFromPercentage(d, 'initial'), hover_color: getColorFromPercentage(d, 'hover') diff --git a/webapp-next/utils/tools.ts b/webapp-next/utils/tools.ts index e7f5edb..b2fd49a 100644 --- a/webapp-next/utils/tools.ts +++ b/webapp-next/utils/tools.ts @@ -11,15 +11,15 @@ export const viewRefs: { label: string; value: View }[] = [ ]; export const departmentRefs: { [key: string]: string } = { - '1': 'Ain', - '2': 'Aisne', - '3': 'Allier', - '4': 'Alpes-de-Haute-Provence', - '5': 'Hautes-Alpes', - '6': 'Alpes-Maritimes', - '7': 'Ardèche', - '8': 'Ardennes', - '9': 'Ariège', + '01': 'Ain', + '02': 'Aisne', + '03': 'Allier', + '04': 'Alpes-de-Haute-Provence', + '05': 'Hautes-Alpes', + '06': 'Alpes-Maritimes', + '07': 'Ardèche', + '08': 'Ardennes', + '09': 'Ariège', '10': 'Aube', '11': 'Aude', '12': 'Aveyron', @@ -108,14 +108,14 @@ export const departmentRefs: { [key: string]: string } = { }; export const departmentsCodes: { [key: string]: string } = { - '1': 'FRA5262', // Ain - '2': 'FRA5263', // Aisne - '3': 'FRA5264', // Allier - '4': 'FRA5265', // Alpes-de-Haute-Provence - '6': 'FRA5266', // Alpes-Maritimes - '7': 'FRA5267', // Ardèche - '8': 'FRA5268', // Ardennes - '9': 'FRA5269', // Ariège + '01': 'FRA5262', // Ain + '02': 'FRA5263', // Aisne + '03': 'FRA5264', // Allier + '04': 'FRA5265', // Alpes-de-Haute-Provence + '06': 'FRA5266', // Alpes-Maritimes + '07': 'FRA5267', // Ardèche + '08': 'FRA5268', // Ardennes + '09': 'FRA5269', // Ariège '10': 'FRA5270', // Aube '11': 'FRA5271', // Aude '12': 'FRA5272', // Aveyron