From 7f041611f74b14ac84b2fc6e2bd42079654f78be Mon Sep 17 00:00:00 2001 From: stampaaaron Date: Tue, 17 Dec 2024 08:32:15 +0000 Subject: [PATCH] chore: rename property --- apps/frontend/src/components/EntitySelect.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/frontend/src/components/EntitySelect.tsx b/apps/frontend/src/components/EntitySelect.tsx index 51d75d3..8a3243d 100644 --- a/apps/frontend/src/components/EntitySelect.tsx +++ b/apps/frontend/src/components/EntitySelect.tsx @@ -24,7 +24,7 @@ const messages = i18n("entitySelect", { actionCreateNew: params('Create new "{value}"'), }); -export function EntitySelect({ value, onChange, data, labelKey: inputKey, onAddNew, ...rest }: Props) { +export function EntitySelect({ value, onChange, data, labelKey, onAddNew, ...rest }: Props) { const t = useStore(messages); const combobox = useCombobox({ @@ -33,15 +33,15 @@ export function EntitySelect({ value, onChange, data, const [searchValue, setSearchValue] = useState(""); - const shouldFilterOptions = !data?.some((item) => item[inputKey] === searchValue); + const shouldFilterOptions = !data?.some((item) => item[labelKey] === searchValue); const filteredOptions = (shouldFilterOptions - ? data?.filter((item) => (item[inputKey] as string)?.toLowerCase().includes(searchValue.toLowerCase().trim())) + ? data?.filter((item) => (item[labelKey] as string)?.toLowerCase().includes(searchValue.toLowerCase().trim())) : data) ?? []; const options = filteredOptions?.map((item) => ( - {item[inputKey] as string} + {item[labelKey] as string} )); @@ -49,7 +49,7 @@ export function EntitySelect({ value, onChange, data, if (value && data) { const index = data.findIndex((item) => item.id === value); if (index !== -1) { - setSearchValue(data[index][inputKey] as string); + setSearchValue(data[index][labelKey] as string); combobox.selectOption(index); } }