From ab363ec22a3416e6740e850964812043374ad60a Mon Sep 17 00:00:00 2001 From: RadoslavDimchev Date: Wed, 15 Nov 2023 21:45:02 +0200 Subject: [PATCH] feat: filter by all status and make util func --- .../ManagementTable/ManagementTable.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pages/ValidatorManagement/ManagementTable/ManagementTable.tsx b/src/pages/ValidatorManagement/ManagementTable/ManagementTable.tsx index a7d9e850..b57a1b66 100644 --- a/src/pages/ValidatorManagement/ManagementTable/ManagementTable.tsx +++ b/src/pages/ValidatorManagement/ManagementTable/ManagementTable.tsx @@ -6,6 +6,7 @@ import { YStack, XStack, Stack } from 'tamagui' import ValidatorProfile from '../../../components/General/ValidatorProfile' import SearchManagement from './SearchManagement' import './ManagementTable.css' +import { VALIDATOR_TABS } from '../../../constants' const validators = [ { @@ -62,12 +63,19 @@ type ManagementTableProps = { tab: string } +const testValidatorStatus = (validatorStatus: string, tabStatus: string) => { + if (validatorStatus === tabStatus || tabStatus === VALIDATOR_TABS[VALIDATOR_TABS.length - 1]) { + return true + } + return false +} + const ManagementTable = ({ tab }: ManagementTableProps) => { const [searchValue, setSearchValue] = useState('') const filteredValidators = useMemo(() => { return validators - .filter(validator => validator.status === tab) + .filter(validator => testValidatorStatus(validator.status, tab)) .filter( validator => validator.number.toString().includes(searchValue) ||