first commit
This commit is contained in:
27
src/redux/slices/groceryList/toggleSlice.js
Normal file
27
src/redux/slices/groceryList/toggleSlice.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
|
||||
const initialState = {
|
||||
addItemModalVisible: false,
|
||||
addProductModalVisible: false,
|
||||
popupVisibility: false,
|
||||
}
|
||||
const toggleSlice = createSlice({
|
||||
name: 'toggle',
|
||||
initialState,
|
||||
reducers: {
|
||||
toggleVisibility: {
|
||||
reducer(state, action) {
|
||||
state[action.payload] = !state[action.payload];
|
||||
},
|
||||
prepare(toggleAction) {
|
||||
return {
|
||||
payload: toggleAction
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { toggleVisibility } = toggleSlice.actions;
|
||||
|
||||
export default toggleSlice.reducer;
|
||||
Reference in New Issue
Block a user