Skip to content

Commit 48ddea6

Browse files
committed
refactor(shared): drop Object.entries cast, use stable form name on CompanySizeFilter
- Switch to `Object.keys` + single `CompanySizeRange[]` cast, avoiding the unsound tuple cast on `Object.entries` flagged by review. - Decouple the form field `name` ("sizeRange") from the DOM `id` so multiple filter instances on the same page stay addressable.
1 parent 19e9552 commit 48ddea6

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

packages/app/src/modules/shared/CompanySizeFilter.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ type Props = {
1111
};
1212

1313
const ALL_SIZES_LABEL = "Toutes tailles";
14-
const RANGE_ENTRIES = Object.entries(COMPANY_SIZE_RANGES) as Array<
15-
[CompanySizeRange, (typeof COMPANY_SIZE_RANGES)[CompanySizeRange]]
16-
>;
14+
const RANGE_KEYS = Object.keys(COMPANY_SIZE_RANGES) as CompanySizeRange[];
1715

1816
export function CompanySizeFilter({
1917
value,
@@ -34,14 +32,14 @@ export function CompanySizeFilter({
3432
<select
3533
className="fr-select"
3634
id={id}
37-
name={id}
35+
name="sizeRange"
3836
onChange={handleChange}
3937
value={value ?? ""}
4038
>
4139
<option value="">{ALL_SIZES_LABEL}</option>
42-
{RANGE_ENTRIES.map(([range, { label: optionLabel }]) => (
40+
{RANGE_KEYS.map((range) => (
4341
<option key={range} value={range}>
44-
{optionLabel}
42+
{COMPANY_SIZE_RANGES[range].label}
4543
</option>
4644
))}
4745
</select>

0 commit comments

Comments
 (0)