Set count of current tab validators

This commit is contained in:
Hristo Nedelkov 2023-09-29 20:32:27 +03:00
parent bc05e5e979
commit 17b9c17325
1 changed files with 8 additions and 0 deletions

View File

@ -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])