mirror of
https://github.com/workhardbekind/workout-challenge.git
synced 2026-07-05 17:53:32 -04:00
first commit
This commit is contained in:
commit
e7f627801f
152 changed files with 35352 additions and 0 deletions
27
src-frontend/src/utils/reducers/modalSlice.js
Normal file
27
src-frontend/src/utils/reducers/modalSlice.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { createSlice } from '@reduxjs/toolkit';
|
||||
|
||||
const modalQueueSlice = createSlice({
|
||||
name: 'modalQueue',
|
||||
initialState: {
|
||||
queue: [], // array of { type, props }
|
||||
currentModal: null,
|
||||
},
|
||||
reducers: {
|
||||
enqueueModal: (state, action) => {
|
||||
state.queue.push(action.payload);
|
||||
if (!state.currentModal) {
|
||||
state.currentModal = state.queue.shift();
|
||||
}
|
||||
},
|
||||
closeModal: (state) => {
|
||||
state.currentModal = state.queue.shift() || null;
|
||||
},
|
||||
clearQueue: (state) => {
|
||||
state.queue = [];
|
||||
state.currentModal = null;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { enqueueModal, closeModal, clearQueue } = modalQueueSlice.actions;
|
||||
export default modalQueueSlice.reducer;
|
||||
Loading…
Add table
Add a link
Reference in a new issue