From 0eda83395d715b9fd348c2268dd9b087acab088e Mon Sep 17 00:00:00 2001 From: Mike Decker Date: Fri, 16 Aug 2024 11:01:21 -0700 Subject: [PATCH] Fix on click handlers --- .../sul-people/sul-people-table-view.tsx | 39 ++++++------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/src/components/views/sul-people/sul-people-table-view.tsx b/src/components/views/sul-people/sul-people-table-view.tsx index 24b9e9f2..e7187461 100644 --- a/src/components/views/sul-people/sul-people-table-view.tsx +++ b/src/components/views/sul-people/sul-people-table-view.tsx @@ -33,35 +33,17 @@ const SulPeopleTableView = ({items, hasHeading}: Props) => { const id = useId() const keywordRef = useRef(null) - const [typeFilter, setTypeFilter] = useState([]) + const [typeFilter, setTypeFilter] = useState("") const [keywordFilter, setKeywordFilter] = useState("") let displayedItems = items - if (typeFilter.length >= 1) { + if (typeFilter) { displayedItems = items.filter( - item => !!item.types?.map(type => type.toLowerCase()).filter(value => typeFilter.includes(value)).length + item => !!item.types?.map(type => type.toLowerCase()).filter(value => typeFilter === value).length ) } - const updateTypeFilter = (type?: string) => { - if (!type) { - return setTypeFilter([]) - } - setTypeFilter(prevState => { - const newState = [...prevState] - const existingIndex = newState.indexOf(type) - if (existingIndex >= 0) { - newState.splice(existingIndex, 1) - console.log("newState splice line") - } else { - newState.push(type) - console.log("newState push (type) line") - } - return newState - }) - } - if (keywordFilter) { displayedItems = displayedItems.filter( item => @@ -121,9 +103,10 @@ const SulPeopleTableView = ({items, hasHeading}: Props) => {