From df1a10294ca622ad4031caead48e403a48e1701a Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 19 Apr 2024 14:54:51 -0600 Subject: [PATCH] Use existing switch component for general filter content --- .../components/filter/ReviewFilterGroup.tsx | 48 +++++++------------ 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/web/src/components/filter/ReviewFilterGroup.tsx b/web/src/components/filter/ReviewFilterGroup.tsx index e4eafb8df..2248835a2 100644 --- a/web/src/components/filter/ReviewFilterGroup.tsx +++ b/web/src/components/filter/ReviewFilterGroup.tsx @@ -593,40 +593,26 @@ export function GeneralFilterContent({
{allLabels.map((item) => ( -
- - { - if (isChecked) { - const updatedLabels = currentLabels - ? [...currentLabels] - : []; + { + if (isChecked) { + const updatedLabels = currentLabels ? [...currentLabels] : []; - updatedLabels.push(item); + updatedLabels.push(item); + setCurrentLabels(updatedLabels); + } else { + const updatedLabels = currentLabels ? [...currentLabels] : []; + + // can not deselect the last item + if (updatedLabels.length > 1) { + updatedLabels.splice(updatedLabels.indexOf(item), 1); setCurrentLabels(updatedLabels); - } else { - const updatedLabels = currentLabels - ? [...currentLabels] - : []; - - // can not deselect the last item - if (updatedLabels.length > 1) { - updatedLabels.splice(updatedLabels.indexOf(item), 1); - setCurrentLabels(updatedLabels); - } } - }} - /> -
+ } + }} + /> ))}