UNPKG

@omegabigdata/honoplay-redux-helper

Version:
156 lines (126 loc) 5.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.updateTrainerReducers = exports.createTrainerReducers = exports.trainerReducers = exports.trainerListReducers = void 0; var _Trainer = require("../helpers/ActionTypes/Trainer"); 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 TRAINER_LIST_INITIAL_STATE = { isTrainerListLoading: false, trainersList: null, errorTrainerList: null }; var TRAINER_INITIAL_STATE = { isTrainerLoading: false, trainer: null, errorTrainer: null }; var CREATE_TRAINER_INITIAL_STATE = { isCreateTrainerLoading: false, createTrainer: null, errorCreateTrainer: null }; var UPDATE_TRAINER_INITIAL_STATE = { isUpdateTrainerLoading: false, updateTrainer: null, errorUpdateTrainer: null }; var trainerListReducers = function trainerListReducers() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : TRAINER_LIST_INITIAL_STATE; var action = arguments.length > 1 ? arguments[1] : undefined; switch (action.type) { case _Trainer.FETCHING_TRAINER_LIST: return _objectSpread({}, state, { isTrainerListLoading: true, errorTrainerList: null }); case _Trainer.FETCH_TRAINER_LIST_SUCCESS: return _objectSpread({}, state, { isTrainerListLoading: false, trainersList: action.data }); case _Trainer.FETCH_TRAINER_LIST_FAILED: return _objectSpread({}, state, { isTrainerListLoading: false, errorTrainerList: action.data.error }); default: return state; } }; exports.trainerListReducers = trainerListReducers; var trainerReducers = function trainerReducers() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : TRAINER_INITIAL_STATE; var action = arguments.length > 1 ? arguments[1] : undefined; switch (action.type) { case _Trainer.FETCHING_TRAINER: return _objectSpread({}, state, { isTrainerLoading: true, errorTrainer: null }); case _Trainer.FETCH_TRAINER_SUCCESS: return _objectSpread({}, state, { isTrainerLoading: false, trainer: action.data }); case _Trainer.FETCH_TRAINER_FAILED: return _objectSpread({}, state, { isTrainerLoading: false, errorTrainer: action.data.error }); default: return state; } }; exports.trainerReducers = trainerReducers; var createTrainerReducers = function createTrainerReducers() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CREATE_TRAINER_INITIAL_STATE; var action = arguments.length > 1 ? arguments[1] : undefined; switch (action.type) { case _Trainer.CREATING_TRAINER: return _objectSpread({}, state, { isCreateTrainerLoading: true, errorCreateTrainer: null }); case _Trainer.CREATE_TRAINER_SUCCESS: return _objectSpread({}, state, { isCreateTrainerLoading: false, createTrainer: action.data }); case _Trainer.CREATE_TRAINER_FAILED: return _objectSpread({}, state, { isCreateTrainerLoading: false, errorCreateTrainer: action.data.error }); default: return state; } }; exports.createTrainerReducers = createTrainerReducers; var updateTrainerReducers = function updateTrainerReducers() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : UPDATE_TRAINER_INITIAL_STATE; var action = arguments.length > 1 ? arguments[1] : undefined; switch (action.type) { case _Trainer.UPDATING_TRAINER: return _objectSpread({}, state, { isUpdateTrainerLoading: true, errorUpdateTrainer: null }); case _Trainer.UPDATE_TRAINER_SUCCESS: return _objectSpread({}, state, { isUpdateTrainerLoading: false, updateTrainer: action.data }); case _Trainer.UPDATE_TRAINER_FAILED: return _objectSpread({}, state, { isUpdateTrainerLoading: false, errorUpdateTrainer: action.data.error }); default: return state; } }; exports.updateTrainerReducers = updateTrainerReducers; //# sourceMappingURL=Trainer.js.map