UNPKG

@omegabigdata/honoplay-redux-helper

Version:
86 lines (68 loc) 3.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.questionTypeReducers = exports.questionTypeListReducers = void 0; var _QuestionType = require("../helpers/ActionTypes/QuestionType"); 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 QUESTION_TYPE_LIST_INITIAL_STATE = { isQuestionTypeListLoading: false, questionTypes: null, errorQuestionTypeList: null }; var QUESTION_TYPE_INITIAL_STATE = { isQuestionTypeLoading: false, questionType: null, errorQuestionType: null }; var questionTypeListReducers = function questionTypeListReducers() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : QUESTION_TYPE_LIST_INITIAL_STATE; var action = arguments.length > 1 ? arguments[1] : undefined; switch (action.type) { case _QuestionType.FETCHING_QUESTION_TYPE_LIST: return _objectSpread({}, state, { isQuestionTypeListLoading: true, errorQuestionTypeList: null }); case _QuestionType.FETCH_QUESTION_TYPE_LIST_SUCCESS: return _objectSpread({}, state, { isQuestionTypeListLoading: false, questionTypes: action.data }); case _QuestionType.FETCH_QUESTION_TYPE_LIST_FAILED: return _objectSpread({}, state, { isQuestionTypeListLoading: false, errorQuestionTypeList: action.data.error }); default: return state; } }; exports.questionTypeListReducers = questionTypeListReducers; var questionTypeReducers = function questionTypeReducers() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : QUESTION_TYPE_INITIAL_STATE; var action = arguments.length > 1 ? arguments[1] : undefined; switch (action.type) { case _QuestionType.FETCHING_QUESTION_TYPE: return _objectSpread({}, state, { isQuestionTypeLoading: true, errorQuestionType: null }); case _QuestionType.FETCH_QUESTION_TYPE_SUCCESS: return _objectSpread({}, state, { isQuestionTypeLoading: false, questionType: action.data }); case _QuestionType.FETCH_QUESTION_TYPE_FAILED: return _objectSpread({}, state, { isQuestionTypeLoading: false, errorQuestionType: action.data.error }); default: return state; } }; exports.questionTypeReducers = questionTypeReducers; //# sourceMappingURL=QuestionType.js.map