UNPKG

@omegabigdata/honoplay-redux-helper

Version:
156 lines (126 loc) 5.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.contentFileReducers = exports.contentFileListReducers = exports.updateContentFileReducers = exports.createContentFileReducers = void 0; var _ContentFile = require("../helpers/ActionTypes/ContentFile"); function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var CREATE_CONTENT_FILE_INITIAL_STATE = { isCreateContentFileLoading: false, newContentFile: null, errorCreateContentFile: null }; var UPDATE_CONTENT_FILE_INITIAL_STATE = { isUpdateContentFileLoading: false, updatedContentFile: null, errorUpdateContentFile: null }; var CONTENT_FILE_LIST_INITIAL_STATE = { isContentFileListLoading: false, contentFiles: null, errorContentFileList: null }; var CONTENT_FILE_INITIAL_STATE = { isContentFileLoading: false, contentFile: null, errorContentFile: null }; var createContentFileReducers = function createContentFileReducers() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CREATE_CONTENT_FILE_INITIAL_STATE; var action = arguments.length > 1 ? arguments[1] : undefined; switch (action.type) { case _ContentFile.CREATING_CONTENT_FILE: return _objectSpread({}, state, { isCreateContentFileLoading: true, errorCreateContentFile: null }); case _ContentFile.CREATE_CONTENT_FILE_SUCCESS: return _objectSpread({}, state, { isCreateContentFileLoading: false, newContentFile: action.data }); case _ContentFile.CREATE_CONTENT_FILE_FAILED: return _objectSpread({}, state, { isCreateContentFileLoading: false, errorCreateContentFile: action.data.error }); default: return state; } }; exports.createContentFileReducers = createContentFileReducers; var updateContentFileReducers = function updateContentFileReducers() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : UPDATE_CONTENT_FILE_INITIAL_STATE; var action = arguments.length > 1 ? arguments[1] : undefined; switch (action.type) { case _ContentFile.UPDATING_CONTENT_FILE: return _objectSpread({}, state, { isUpdateContentFileLoading: true, errorUpdateContentFile: null }); case _ContentFile.UPDATE_CONTENT_FILE_SUCCESS: return _objectSpread({}, state, { isUpdateContentFileLoading: false, updatedContentFile: action.data }); case _ContentFile.UPDATE_CONTENT_FILE_FAILED: return _objectSpread({}, state, { isUpdateContentFileLoading: false, errorUpdateContentFile: action.data.error }); default: return state; } }; exports.updateContentFileReducers = updateContentFileReducers; var contentFileListReducers = function contentFileListReducers() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CONTENT_FILE_LIST_INITIAL_STATE; var action = arguments.length > 1 ? arguments[1] : undefined; switch (action.type) { case _ContentFile.FETCHING_CONTENT_FILE_LIST: return _objectSpread({}, state, { isContentFileListLoading: true, errorContentFileList: null }); case _ContentFile.FETCH_CONTENT_FILE_LIST_SUCCESS: return _objectSpread({}, state, { isContentFileListLoading: false, contentFiles: action.data }); case _ContentFile.FETCH_CONTENT_FILE_LIST_FAILED: return _objectSpread({}, state, { isContentFileListLoading: false, errorContentFileList: action.data.error }); default: return state; } }; exports.contentFileListReducers = contentFileListReducers; var contentFileReducers = function contentFileReducers() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CONTENT_FILE_INITIAL_STATE; var action = arguments.length > 1 ? arguments[1] : undefined; switch (action.type) { case _ContentFile.FETCHING_CONTENT_FILE: return _objectSpread({}, state, { isContentFileLoading: true, errorContentFile: null }); case _ContentFile.FETCH_CONTENT_FILE_SUCCESS: return _objectSpread({}, state, { isContentFileLoading: false, contentFile: action.data }); case _ContentFile.FETCH_CONTENT_FILE_FAILED: return _objectSpread({}, state, { isContentFileLoading: false, errorContentFile: action.data.error }); default: return state; } }; exports.contentFileReducers = contentFileReducers; //# sourceMappingURL=ContentFile.js.map