feat(left-sidebar-icon-button): wrap with link component

This commit is contained in:
RadoslavDimchev 2024-04-10 16:04:26 +03:00 committed by Radoslav Dimchev
parent 8f112acdb0
commit bf4d8043ce
1 changed files with 24 additions and 25 deletions

View File

@ -1,7 +1,7 @@
import { IconButton } from '@status-im/components' import { IconButton } from '@status-im/components'
import { useDispatch } from 'react-redux' import { useDispatch } from 'react-redux'
import { Stack } from 'tamagui' import { Stack } from 'tamagui'
import { useNavigate } from 'react-router' import { Link } from 'react-router-dom'
import { toggleButtonSelection } from '../../../redux/LeftSidebar/slice' import { toggleButtonSelection } from '../../../redux/LeftSidebar/slice'
@ -23,21 +23,19 @@ const LeftSidebarIconButton = ({
path, path,
}: IconButtonWithDotProps) => { }: IconButtonWithDotProps) => {
const dispatch = useDispatch() const dispatch = useDispatch()
const navigate = useNavigate()
const onClickHandler = () => { const onClickHandler = () => {
isDisabled ? null : dispatch(toggleButtonSelection(id)) isDisabled ? null : dispatch(toggleButtonSelection(id))
navigate(path)
} }
return ( return (
<Link to={path} onClick={onClickHandler}>
<Stack style={{ position: 'relative', display: 'inline-block' }}> <Stack style={{ position: 'relative', display: 'inline-block' }}>
<IconButton <IconButton
icon={iconEl} icon={iconEl}
variant={isDisabled ? 'outline' : 'ghost'} variant={isDisabled ? 'outline' : 'ghost'}
selected={isSelected} selected={isSelected}
disabled={isDisabled} disabled={isDisabled}
onPress={onClickHandler}
/> />
{isDotOn && ( {isDotOn && (
<Stack <Stack
@ -54,6 +52,7 @@ const LeftSidebarIconButton = ({
/> />
)} )}
</Stack> </Stack>
</Link>
) )
} }