@open-tender/store
Version:
A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our in-store POS API
26 lines (25 loc) • 849 B
JavaScript
var _a;
import { createSlice } from '@reduxjs/toolkit';
import { ReducerType } from './types';
var initialState = {
type: null,
args: null
};
var modalSlice = createSlice({
name: ReducerType.Modal,
initialState: initialState,
reducers: {
openModal: function (state, action) {
var _a = action.payload, type = _a.type, _b = _a.args, args = _b === void 0 ? null : _b;
state.type = type;
state.args = args;
},
closeModal: function (state) {
state.type = null;
}
}
});
export var openModal = (_a = modalSlice.actions, _a.openModal), closeModal = _a.closeModal;
export var selectModal = function (state) { return state.modal; };
export var selectModalType = function (state) { return state.modal.type; };
export var modalReducer = modalSlice.reducer;