feat(validator info): create handlers for change of interval

This commit is contained in:
Hristo Nedelkov 2024-03-27 23:13:52 +02:00
parent 8250429bcd
commit 3220e3b6c0
1 changed files with 13 additions and 0 deletions

View File

@ -10,6 +10,17 @@ const ValidatorInfo = () => {
const intervalsOfTime = ['Day', 'Week', 'Month', 'Year']
const [currentInterval, setCurrentInterval] = useState(0)
const toggleIntervalChange = () => {
setCurrentInterval(
prevInterval => (prevInterval + 1) % intervalsOfTime.length,
)
}
const togglePreviousInterval = () => {
setCurrentInterval(
prevInterval => (prevInterval - 1 + intervalsOfTime.length) % intervalsOfTime.length,
)
}
return (
<XStack space={'$2'} justifyContent="space-between">
<XStack space="$2">
@ -55,11 +66,13 @@ const ValidatorInfo = () => {
size={16}
style={{ cursor: 'pointer' }}
onClick={() => {
togglePreviousInterval()
}}
/>
<ChevronRightIcon
size={16}
onClick={() => {
toggleIntervalChange()
}}
style={{ cursor: 'pointer' }}
/>