From 037fd303253982109d1ec4b878d182529e7488a6 Mon Sep 17 00:00:00 2001 From: Enguerran Weiss Date: Mon, 9 Dec 2024 14:52:10 +0100 Subject: [PATCH] suppr. Proposal / Option from AppellationAutocomplete --- .../autocomplete/AppellationAutocomplete.tsx | 170 ++++++++---------- 1 file changed, 77 insertions(+), 93 deletions(-) diff --git a/front/src/app/components/forms/autocomplete/AppellationAutocomplete.tsx b/front/src/app/components/forms/autocomplete/AppellationAutocomplete.tsx index e61e7e2917..25ea70aefc 100644 --- a/front/src/app/components/forms/autocomplete/AppellationAutocomplete.tsx +++ b/front/src/app/components/forms/autocomplete/AppellationAutocomplete.tsx @@ -6,21 +6,11 @@ import { AppellationMatchDto, ROME_AND_APPELLATION_MIN_SEARCH_TEXT_LENGTH, } from "shared"; -import { Proposal } from "src/app/components/forms/establishment/Proposal"; import { StringWithHighlights } from "src/app/components/forms/establishment/StringWithHighlights"; import { useDebounce } from "src/app/hooks/useDebounce"; import { outOfReduxDependencies } from "src/config/dependencies"; import { useStyles } from "tss-react/dsfr"; -const romeSearchMatchToProposal = ({ - matchRanges, - appellation, -}: AppellationMatchDto): Option => ({ - value: appellation, - description: appellation.appellationLabel, - matchRanges, -}); - type AppellationAutocompleteProps = { label: React.ReactNode; initialValue?: AppellationAndRomeDto | undefined; @@ -37,8 +27,6 @@ type AppellationAutocompleteProps = { onAfterClearInput?: () => void; }; -type Option = Proposal; - export const AppellationAutocomplete = ({ initialValue, onAppellationSelected, @@ -54,26 +42,24 @@ export const AppellationAutocomplete = ({ shouldClearInput, onAfterClearInput, }: AppellationAutocompleteProps) => { - const initialOption: Option | null = useMemo( + const initialOption: AppellationMatchDto | null = useMemo( () => initialValue ? { - value: initialValue, - description: initialValue?.appellationLabel ?? "", + appellation: initialValue, matchRanges: [], } : null, [initialValue], ); - const [selectedOption, setSelectedOption] = useState