UNPKG

@e-group/redux-modules

Version:

eGroup team react-redux modules that share across projects.

74 lines (59 loc) 1.76 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.dialogs = void 0; var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); var _reduxActions = require("redux-actions"); var _immutable = require("@e-group/immutable"); var _dialogs = require("../../dialogs"); const initialState = (0, _immutable.fromJS)({}); /** * Reducer */ const dialogs = (0, _reduxActions.handleActions)({ [_dialogs.INITIALIZE_DIALOG]: (state, action) => { if (action.payload) { const name = String(action.payload); return state.update(name, dialogState => { if ((0, _immutable.isImmutable)(dialogState)) { return dialogState; } return (0, _immutable.Map)({ isOpen: false }); }); } return state; }, [_dialogs.OPEN_DIALOG]: (state, action) => { if (action.payload) { return state.setIn([action.payload, 'isOpen'], true); } return state; }, [_dialogs.CLOSE_DIALOG]: (state, action) => { if (action.payload) { return state.setIn([action.payload, 'isOpen'], false); } return state; }, [_dialogs.SET_DIALOG_DATA]: (state, action) => { if (action.payload) { const _ref = action.payload, name = _ref.name, other = (0, _objectWithoutProperties2.default)(_ref, ["name"]); if (name) { return state.update(name, el => { if (el) { return (0, _immutable.merge)(el, other); } return el; }); } } return state; } }, initialState); exports.dialogs = dialogs;