mirror of
https://github.com/status-im/nimbus-gui.git
synced 2025-01-09 11:11:59 +00:00
feat: add state to every check and effect to check all
This commit is contained in:
parent
d39a1f88a3
commit
751485b700
@ -5,13 +5,18 @@ import ManagementTableRow from './ManagementTableRow'
|
|||||||
|
|
||||||
type ManagementTableBodyProps = {
|
type ManagementTableBodyProps = {
|
||||||
filteredValidators: Validator[]
|
filteredValidators: Validator[]
|
||||||
|
isAllSelected: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const ManagementTableBody = ({ filteredValidators }: ManagementTableBodyProps) => {
|
const ManagementTableBody = ({ filteredValidators, isAllSelected }: ManagementTableBodyProps) => {
|
||||||
return (
|
return (
|
||||||
<tbody>
|
<tbody>
|
||||||
{filteredValidators.map(validator => (
|
{filteredValidators.map(validator => (
|
||||||
<ManagementTableRow key={validator.address} validator={validator} />
|
<ManagementTableRow
|
||||||
|
key={validator.address}
|
||||||
|
validator={validator}
|
||||||
|
isAllSelected={isAllSelected}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
{filteredValidators.length === 0 && (
|
{filteredValidators.length === 0 && (
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -18,5 +18,6 @@ type Story = StoryObj<typeof meta>
|
|||||||
export const Default: Story = {
|
export const Default: Story = {
|
||||||
args: {
|
args: {
|
||||||
validator: VALIDATORS_DATA[0],
|
validator: VALIDATORS_DATA[0],
|
||||||
|
isAllSelected: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { useEffect, useState } from 'react'
|
||||||
import { Checkbox, Text } from '@status-im/components'
|
import { Checkbox, Text } from '@status-im/components'
|
||||||
import { OptionsIcon } from '@status-im/icons'
|
import { OptionsIcon } from '@status-im/icons'
|
||||||
|
|
||||||
@ -6,13 +7,29 @@ import { Validator } from './ManagementTable'
|
|||||||
|
|
||||||
type ManagementTableRowProps = {
|
type ManagementTableRowProps = {
|
||||||
validator: Validator
|
validator: Validator
|
||||||
|
isAllSelected: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const ManagementTableRow = ({ validator }: ManagementTableRowProps) => {
|
const ManagementTableRow = ({ validator, isAllSelected }: ManagementTableRowProps) => {
|
||||||
|
const [isSelected, setIsSelected] = useState(false)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setIsSelected(isAllSelected)
|
||||||
|
}, [isAllSelected])
|
||||||
|
|
||||||
|
const handleChangeIsSelected = () => {
|
||||||
|
setIsSelected(state => !state)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Checkbox id={validator.address} variant="outline" />
|
<Checkbox
|
||||||
|
id={validator.address}
|
||||||
|
variant="outline"
|
||||||
|
selected={isSelected}
|
||||||
|
onCheckedChange={handleChangeIsSelected}
|
||||||
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<ValidatorProfile number={validator.number} address={validator.address} />
|
<ValidatorProfile number={validator.number} address={validator.address} />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user