From aaa31224f73139eca9d26bccc8129ed48cd1021e Mon Sep 17 00:00:00 2001 From: Meryem Yanar Date: Sat, 30 Mar 2024 12:26:19 +0000 Subject: [PATCH] Fix bug with filtering --- pages/search/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pages/search/index.tsx b/pages/search/index.tsx index 4e09ecf..3e790b0 100644 --- a/pages/search/index.tsx +++ b/pages/search/index.tsx @@ -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()) || @@ -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 }))