From 17b9c1732549431aa1ad77b9ee1e9c4ce3b2ef0a Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Fri, 29 Sep 2023 20:32:27 +0300 Subject: [PATCH] Set count of current tab validators --- src/pages/Dashboard/RightSideBar/ValidatorsList.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pages/Dashboard/RightSideBar/ValidatorsList.tsx b/src/pages/Dashboard/RightSideBar/ValidatorsList.tsx index 0b139785..cbea423a 100644 --- a/src/pages/Dashboard/RightSideBar/ValidatorsList.tsx +++ b/src/pages/Dashboard/RightSideBar/ValidatorsList.tsx @@ -2,8 +2,13 @@ import { Stack, YStack } from 'tamagui' import ValidatorListItem from './ValidatorListItem' import InputSearch from './SearchInput' import { useState, useEffect } from 'react' +import { useDispatch } from 'react-redux' +import { setCountOfValidators } from '../../../redux/RightSidebar/slice' + const ValidatorsList = () => { + const dispatch = useDispatch() + const [searchValue, setSearchValue] = useState('') const validators = [ { @@ -25,8 +30,11 @@ const ValidatorsList = () => { const filtered = validators.filter(validator => validator.name.toLowerCase().includes(searchValue.toLowerCase()), ) + const filteredCount = filtered.length + dispatch(setCountOfValidators(filteredCount)) setFilteredValidators(filtered) } else { + dispatch(setCountOfValidators(validators.length)) setFilteredValidators(validators) } }, [searchValue, validators])