From 2f143ccfb1f5fb8315ab7f624d8fe82aee5cc827 Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Tue, 26 Sep 2023 12:59:36 +0300 Subject: [PATCH] Create reducers for leftSidebar --- src/redux/Sidebars/slice.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/redux/Sidebars/slice.ts b/src/redux/Sidebars/slice.ts index d660bd17..3d4bd3eb 100644 --- a/src/redux/Sidebars/slice.ts +++ b/src/redux/Sidebars/slice.ts @@ -28,8 +28,18 @@ const leftSidebarSlice = createSlice({ name: 'leftSidebar', initialState, reducers: { + toggleButtonSelection: (state, action: PayloadAction) => { + state.buttons.forEach(button => { + button.isSelected = button.id === action.payload; + }); + }, + toggleDot: (state, action: PayloadAction) => { + const button = state.buttons.find(button => button.id === action.payload); + if (button) button.isDotOn = !button.isDotOn; + }, }, }); export const { toggleButtonSelection, toggleDot } = leftSidebarSlice.actions; +export default leftSidebarSlice.reducer;