mirror of
https://github.com/status-im/nimbus-gui.git
synced 2025-01-22 09:19:28 +00:00
feat: separate func for number and address
This commit is contained in:
parent
ab363ec22a
commit
66093a8f9c
@ -70,17 +70,24 @@ const testValidatorStatus = (validatorStatus: string, tabStatus: string) => {
|
||||
return false
|
||||
}
|
||||
|
||||
const testNumberAndAddress = (
|
||||
validatorNumber: number,
|
||||
validatorAddress: string,
|
||||
searchValue: string,
|
||||
) => {
|
||||
if (validatorNumber.toString().includes(searchValue) || validatorAddress.includes(searchValue)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const ManagementTable = ({ tab }: ManagementTableProps) => {
|
||||
const [searchValue, setSearchValue] = useState('')
|
||||
|
||||
const filteredValidators = useMemo(() => {
|
||||
return validators
|
||||
.filter(validator => testValidatorStatus(validator.status, tab))
|
||||
.filter(
|
||||
validator =>
|
||||
validator.number.toString().includes(searchValue) ||
|
||||
validator.address.includes(searchValue),
|
||||
)
|
||||
.filter(validator => testNumberAndAddress(validator.number, validator.address, searchValue))
|
||||
}, [tab, searchValue])
|
||||
|
||||
const changeSearchValue = (value: string) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user