@open-tender/cloud
Version:
A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our cloud-based Order API.
31 lines (30 loc) • 985 B
JavaScript
;
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.modalReducer = exports.selectModal = exports.closeModal = exports.openModal = void 0;
const toolkit_1 = require("@reduxjs/toolkit");
const initialState = {
loading: false,
type: null,
args: null
};
const modalSlice = (0, toolkit_1.createSlice)({
name: 'modal',
initialState,
reducers: {
openModal: (state, action) => {
document.body.classList.add('has-modal');
const { type, args = null } = action.payload;
state.type = type;
state.args = args;
},
closeModal: state => {
document.body.classList.remove('has-modal');
state.type = null;
}
}
});
_a = modalSlice.actions, exports.openModal = _a.openModal, exports.closeModal = _a.closeModal;
const selectModal = (state) => state.modal;
exports.selectModal = selectModal;
exports.modalReducer = modalSlice.reducer;