Create reducers for leftSidebar

This commit is contained in:
Hristo Nedelkov 2023-09-26 12:59:36 +03:00
parent 0de4832993
commit 2f143ccfb1
1 changed files with 10 additions and 0 deletions

View File

@ -28,8 +28,18 @@ const leftSidebarSlice = createSlice({
name: 'leftSidebar',
initialState,
reducers: {
toggleButtonSelection: (state, action: PayloadAction<string>) => {
state.buttons.forEach(button => {
button.isSelected = button.id === action.payload;
});
},
toggleDot: (state, action: PayloadAction<string>) => {
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;