From cf03dd574f1a1556155a5edc6d4e8a0ccf725592 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 22 Aug 2023 12:42:24 +0300 Subject: [PATCH] feat(FiltersApplied): stateType support --- .../FiltersPanelApplied/FiltersPanelApplied.tsx | 9 +++++++++ src/components/StateFilter.tsx | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/FiltersPanelApplied/FiltersPanelApplied.tsx b/src/components/FiltersPanelApplied/FiltersPanelApplied.tsx index 0032d45dd..f469ca7ff 100644 --- a/src/components/FiltersPanelApplied/FiltersPanelApplied.tsx +++ b/src/components/FiltersPanelApplied/FiltersPanelApplied.tsx @@ -66,6 +66,15 @@ export const FiltersPanelApplied: React.FC = ({ appliedMap[tr('State')] = queryState.state.map((s) => statesMap[s]?.title).filter(Boolean); } + if (queryState.stateType.length && states?.length) { + appliedMap[tr('State')] = states.reduce((acum, { type, title }) => { + if (queryState.stateType.includes(type) && !acum.includes(title)) { + acum.push(title); + } + return acum; + }, appliedMap[tr('State')] || []); + } + if (queryState.issuer.length && issuers?.length) { appliedMap[tr('Issuer')] = queryState.issuer.map((u) => issuersMap[u]?.user?.name).filter(Boolean) as string[]; } diff --git a/src/components/StateFilter.tsx b/src/components/StateFilter.tsx index a1dba0876..7993a87dc 100644 --- a/src/components/StateFilter.tsx +++ b/src/components/StateFilter.tsx @@ -3,7 +3,7 @@ import { StateType } from '@prisma/client'; import { ColorizedFilterDropdown } from './ColorizedFilterDropdown'; -type State = { id: string; title: string; hue: number; type: string }; +type State = { id: string; title: string; hue: number; type: StateType }; export const StateFilter: FC<{ text: string;