From 395f28219d89e278560a159fc985d61f347b0feb Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Tue, 26 Sep 2023 13:44:35 +0300 Subject: [PATCH] Add handler on each sidebar button --- src/pages/Dashboard/IconButtonWithDot.tsx | 65 +++++++++++++---------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/src/pages/Dashboard/IconButtonWithDot.tsx b/src/pages/Dashboard/IconButtonWithDot.tsx index 271b7f96..db0acfb1 100644 --- a/src/pages/Dashboard/IconButtonWithDot.tsx +++ b/src/pages/Dashboard/IconButtonWithDot.tsx @@ -1,40 +1,47 @@ import { IconButton } from '@status-im/components' +import { useDispatch } from 'react-redux' import { Stack } from 'tamagui' +import { toggleButtonSelection } from '../../redux/Sidebars/slice' type IconButtonWithDotProps = { - iconEl: any - variant: 'ghost' | 'outline' - isDotOn: boolean - selected?: boolean - disabled?: boolean + iconEl: any + variant: 'ghost' | 'outline' + isDotOn: boolean + selected?: boolean + disabled?: boolean + id: string } const IconButtonWithDot = ({ - iconEl, - variant, - isDotOn, - selected, - disabled, + iconEl, + variant, + isDotOn, + selected, + disabled, + id }: IconButtonWithDotProps) => { - return ( - - - {isDotOn && ( - - )} - - ) + const dispatch = useDispatch() + const onClickHandler = (id) => { if (!disabled) dispatch(toggleButtonSelection(id)) } + + return ( + + onClickHandler(id)} /> + {isDotOn && ( + + )} + + ) } export default IconButtonWithDot