Skip to content

Commit

Permalink
Fix bug with filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Marjona6 committed Mar 30, 2024
1 parent 00d3a52 commit aaa3122
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pages/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ const SearchPage = () => {
}
}

const performTextSearch = (val) => {
if (val === '') setCases(allCases)
const performTextSearch = (val, availableCases) => {
if (val === '') setCases(availableCases)
else {
const filteredCases = cases.filter(
const filteredCases = availableCases.filter(
(c) =>
c.case_summary?.toLowerCase().includes(val?.toLowerCase()) ||
c.party_names?.toLowerCase().includes(val?.toLowerCase()) ||
Expand All @@ -129,8 +129,8 @@ const SearchPage = () => {
}

useEffect(() => {
performTextSearch(searchValue)
}, [searchValue])
performTextSearch(searchValue, allCases)
}, [searchValue, allCases])

const createOptions = (arr) =>
arr.map((item) => ({ label: item, value: item }))
Expand Down

0 comments on commit aaa3122

Please sign in to comment.