Skip to content

Commit 14c8334

Browse files
elisfainsteincparthur
authored andcommitted
refactor: replace legacy Select component with UI Select (goal: minimize dsfr use)
1 parent 2c2a4df commit 14c8334

File tree

2 files changed

+33
-93
lines changed

2 files changed

+33
-93
lines changed

apps/site/app/stats/RegionAndDeptFilters.tsx

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use client';
22

3-
import { Button } from '@/ui';
3+
import { Button, Field, Select } from '@/ui';
44
import { usePathname, useRouter } from 'next/navigation';
55
import { useEffect, useState } from 'react';
66
import useSWR from 'swr';
7-
import Select from '../../components/inputs/Select';
7+
88
import { supabase } from '../initSupabase';
99

1010
/**
@@ -143,44 +143,37 @@ const RegionAndDeptFilters = ({ onChange }: RegionAndDeptFiltersProps) => {
143143
écologique.
144144
</p>
145145
)}
146-
<div
147-
className="fr-select-group"
148-
style={{
149-
display: 'grid',
150-
gridTemplateColumns: 'repeat(auto-fill, minmax(300px, 1fr))',
151-
columnGap: '50px',
152-
rowGap: '20px',
153-
justifyItems: 'start',
154-
alignItems: 'end',
155-
}}
156-
>
157-
<Select
158-
name="region"
159-
label="Région"
160-
emptyOptionLabel="Toutes les régions"
161-
// @ts-expect-error erreur non gérée
162-
options={regions.map((region) => ({
163-
value: region.code,
164-
name: region.libelle,
165-
}))}
166-
value={selectedRegion}
167-
style={{ width: '100%' }}
168-
onChange={setSelectedRegion}
169-
/>
170-
171-
<Select
172-
name="department"
173-
label="Département"
174-
emptyOptionLabel="Tous les départements"
175-
// @ts-expect-error erreur non gérée
176-
options={departments.map((department) => ({
177-
value: department.code,
178-
name: department.libelle,
179-
}))}
180-
value={selectedDepartment}
181-
style={{ width: '100%' }}
182-
onChange={setSelectedDepartment}
183-
/>
146+
<div className="grid grid-cols-[repeat(auto-fill,minmax(300px,1fr))] gap-x-[50px] gap-y-5 justify-items-start items-end">
147+
<Field title="Région" className="w-full">
148+
<Select
149+
placeholder="Toutes les régions"
150+
options={regions
151+
.filter((region) => region.code && region.libelle)
152+
.map((region) => ({
153+
value: region.code!,
154+
label: region.libelle!,
155+
}))}
156+
values={selectedRegion || undefined}
157+
onChange={(value) =>
158+
setSelectedRegion(value?.toString() || emptyString)
159+
}
160+
/>
161+
</Field>
162+
<Field title="Département" className="w-full">
163+
<Select
164+
placeholder="Tous les départements"
165+
options={departments
166+
.filter((department) => department.code && department.libelle)
167+
.map((department) => ({
168+
value: department.code!,
169+
label: department.libelle!,
170+
}))}
171+
values={selectedDepartment || undefined}
172+
onChange={(value) =>
173+
setSelectedDepartment(value?.toString() || emptyString)
174+
}
175+
/>
176+
</Field>
184177

185178
<Button
186179
variant="outlined"

apps/site/components/inputs/Select.tsx

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)