feat: separate table body into component
This commit is contained in:
parent
fc9d9c1f3e
commit
fc57025d31
|
@ -1,13 +1,11 @@
|
|||
import { Checkbox, Text } from '@status-im/components'
|
||||
import { OptionsIcon } from '@status-im/icons'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { YStack, XStack } from 'tamagui'
|
||||
|
||||
import { VALIDATORS_DATA, VALIDATOR_TABS_MANAGEMENT } from '../../../constants'
|
||||
import ValidatorProfile from '../../../components/General/ValidatorProfile'
|
||||
import SearchManagement from './SearchManagement'
|
||||
import DropdownFilter from './DropdownFilter'
|
||||
import ManagementTableHeader from './ManagementTableHeader'
|
||||
import ManagementTableBody from './ManagementTableBody'
|
||||
import './ManagementTable.css'
|
||||
|
||||
type ManagementTableProps = {
|
||||
|
@ -16,7 +14,7 @@ type ManagementTableProps = {
|
|||
changeSearchValue: (value: string) => void
|
||||
}
|
||||
|
||||
type Validator = {
|
||||
export type Validator = {
|
||||
number: number
|
||||
address: string
|
||||
balance: number
|
||||
|
@ -69,60 +67,7 @@ const ManagementTable = ({ tab, searchValue, changeSearchValue }: ManagementTabl
|
|||
</XStack>
|
||||
<table>
|
||||
<ManagementTableHeader validatorsAmount={filteredValidators.length} />
|
||||
<tbody>
|
||||
{filteredValidators.map((validator, index) => (
|
||||
<tr key={index}>
|
||||
<td>
|
||||
<Checkbox id={index.toString()} variant="outline" />
|
||||
</td>
|
||||
<td>
|
||||
<ValidatorProfile number={validator.number} address={validator.address} />
|
||||
</td>
|
||||
<td>
|
||||
<Text size={15} color={'#647084'} weight={'semibold'}>
|
||||
{validator.balance}
|
||||
</Text>
|
||||
</td>
|
||||
<td>
|
||||
<Text size={15} color={'#647084'} weight={'semibold'}>
|
||||
{validator.income}
|
||||
</Text>
|
||||
</td>
|
||||
<td>
|
||||
<Text size={15} color={'#647084'}>
|
||||
{validator.proposals}
|
||||
</Text>
|
||||
</td>
|
||||
<td>
|
||||
<Text size={15} color={'#647084'}>
|
||||
{validator.attestations}
|
||||
</Text>
|
||||
</td>
|
||||
<td>
|
||||
<Text size={15} color={'#647084'}>
|
||||
{validator.effectiveness}%
|
||||
</Text>
|
||||
</td>
|
||||
<td>
|
||||
<Text size={15} color={'#2F80ED'} weight={'semibold'}>
|
||||
{validator.status}
|
||||
</Text>
|
||||
</td>
|
||||
<td>
|
||||
<OptionsIcon size={20} color="#647084" style={{ cursor: 'pointer' }} />
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
{filteredValidators.length === 0 && (
|
||||
<tr>
|
||||
<td colSpan={11}>
|
||||
<Text size={15} color={'#647084'} weight={'semibold'}>
|
||||
No validators
|
||||
</Text>
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
<ManagementTableBody filteredValidators={filteredValidators} />
|
||||
</table>
|
||||
</YStack>
|
||||
)
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
import { Checkbox, Text } from '@status-im/components'
|
||||
import { OptionsIcon } from '@status-im/icons'
|
||||
|
||||
import ValidatorProfile from '../../../components/General/ValidatorProfile'
|
||||
import { Validator } from './ManagementTable'
|
||||
|
||||
type ManagementTableBodyProps = {
|
||||
filteredValidators: Validator[]
|
||||
}
|
||||
|
||||
const ManagementTableBody = ({ filteredValidators }: ManagementTableBodyProps) => {
|
||||
return (
|
||||
<tbody>
|
||||
{filteredValidators.map((validator, index) => (
|
||||
<tr key={index}>
|
||||
<td>
|
||||
<Checkbox id={index.toString()} variant="outline" />
|
||||
</td>
|
||||
<td>
|
||||
<ValidatorProfile number={validator.number} address={validator.address} />
|
||||
</td>
|
||||
<td>
|
||||
<Text size={15} color={'#647084'} weight={'semibold'}>
|
||||
{validator.balance}
|
||||
</Text>
|
||||
</td>
|
||||
<td>
|
||||
<Text size={15} color={'#647084'} weight={'semibold'}>
|
||||
{validator.income}
|
||||
</Text>
|
||||
</td>
|
||||
<td>
|
||||
<Text size={15} color={'#647084'}>
|
||||
{validator.proposals}
|
||||
</Text>
|
||||
</td>
|
||||
<td>
|
||||
<Text size={15} color={'#647084'}>
|
||||
{validator.attestations}
|
||||
</Text>
|
||||
</td>
|
||||
<td>
|
||||
<Text size={15} color={'#647084'}>
|
||||
{validator.effectiveness}%
|
||||
</Text>
|
||||
</td>
|
||||
<td>
|
||||
<Text size={15} color={'#2F80ED'} weight={'semibold'}>
|
||||
{validator.status}
|
||||
</Text>
|
||||
</td>
|
||||
<td>
|
||||
<OptionsIcon size={20} color="#647084" style={{ cursor: 'pointer' }} />
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
{filteredValidators.length === 0 && (
|
||||
<tr>
|
||||
<td colSpan={11}>
|
||||
<Text size={15} color={'#647084'} weight={'semibold'}>
|
||||
No validators
|
||||
</Text>
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
)
|
||||
}
|
||||
|
||||
export default ManagementTableBody
|
Loading…
Reference in New Issue