From ce597b4899aa3cc067c5057acd2bf73b5765a9bb Mon Sep 17 00:00:00 2001 From: Alexander Ryck Date: Tue, 6 Feb 2024 11:42:13 +0100 Subject: [PATCH] Bug: no and search possible CHANGED: - SearchInputAdvanced.tsx: Changed the handleAddChip func filter, that it doesn't affect date fields - .gitignore: added /.nx folder REFS: 4056 --- .gitignore | 1 + .../SearchBar/SearchInputAdvanced.tsx | 43 +++++++++++-------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 4c78d62..6adc7c7 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ yarn-error.log testem.log /typings .env +/.nx # System Files .DS_Store diff --git a/src/components/SearchApp/SearchBar/SearchInputAdvanced.tsx b/src/components/SearchApp/SearchBar/SearchInputAdvanced.tsx index ad2919f..192a50d 100644 --- a/src/components/SearchApp/SearchBar/SearchInputAdvanced.tsx +++ b/src/components/SearchApp/SearchBar/SearchInputAdvanced.tsx @@ -52,17 +52,17 @@ export function SearchInputAdvanced({ Criteria | undefined >(undefined); const [selectedOption, setSelectedOption] = useState( - null, + null ); const [inputType, setInputType] = useState('text'); const [operatorValue, setOperatorValue] = useState('LIKE'); const handlePropertyOptionClick = ( - selected: DropdownOptions | null, + selected: DropdownOptions | null ): void => { setSelectedOption(selected); if (criteria && selected) { const selectedProperties = criteria.find( - (e: Criteria) => e.property === selected.value, + (e: Criteria) => e.property === selected.value ); setSelectedIndexProperties(selectedProperties); @@ -79,7 +79,7 @@ export function SearchInputAdvanced({ const disabled = (operator: string): boolean => { const isOperator = selectedIndexProperties?.operator.find( - (e: string) => e === operator, + (e: string) => e === operator ); if (!isOperator) { return true; @@ -90,7 +90,7 @@ export function SearchInputAdvanced({ const handleAddChip = ( newOperator: string, newProperty: string, - value: string, + value: string ): void => { const filters = produce<(state: Filter[]) => Filter[]>((draft) => { if ( @@ -98,7 +98,7 @@ export function SearchInputAdvanced({ (filterOptions: Filter) => filterOptions.value === value && filterOptions.operator === newOperator && - filterOptions.property === newProperty, + filterOptions.property === newProperty ) ) { draft.push({ @@ -109,13 +109,18 @@ export function SearchInputAdvanced({ } }); - const updateIndexAttributes = filter( - data, - (item: string) => item !== selectedOption?.value, - ); + const isDateProperty = newProperty.toLowerCase().includes('date'); + if (!isDateProperty) { + const updateIndexAttributes = filter( + data, + (item: string) => item !== selectedOption?.value + ); + onReducedIndexAttributes(updateIndexAttributes); + } else { + onReducedIndexAttributes(data); + } onSetSelectFilters(filters); - onReducedIndexAttributes(updateIndexAttributes); }; const addFilter = (): void => { @@ -123,7 +128,7 @@ export function SearchInputAdvanced({ handleAddChip( operatorValue, selectedIndexProperties.property, - searchValue, + searchValue ); setSelectedIndexProperties(undefined); @@ -142,7 +147,7 @@ export function SearchInputAdvanced({ return ( - - + + onSetSearchValue(e.target.value)} @@ -171,14 +176,14 @@ export function SearchInputAdvanced({ {operatorValue && selectedIndexProperties && searchValue && ( )}