@omegabigdata/honoplay-redux-helper
Version:
honoplay-redux-helper
86 lines (68 loc) • 3.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.questionDifficultyReducers = exports.questionDifficultyListReducers = void 0;
var _QuestionDifficulty = require("../helpers/ActionTypes/QuestionDifficulty");
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_DIFFICULTY_LIST_INITIAL_STATE = {
isQuestionDifficultyListLoading: false,
questionDifficulties: null,
errorQuestionDifficultyList: null
};
var QUESTION_DIFFICULTY_INITIAL_STATE = {
isQuestionDifficultyLoading: false,
questionDifficulty: null,
errorQuestionDifficulty: null
};
var questionDifficultyListReducers = function questionDifficultyListReducers() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : QUESTION_DIFFICULTY_LIST_INITIAL_STATE;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case _QuestionDifficulty.FETCHING_QUESTION_DIFFICULTY_LIST:
return _objectSpread({}, state, {
isQuestionDifficultyListLoading: true,
errorQuestionDifficultyList: null
});
case _QuestionDifficulty.FETCH_QUESTION_DIFFICULTY_LIST_SUCCESS:
return _objectSpread({}, state, {
isQuestionDifficultyListLoading: false,
questionDifficulties: action.data
});
case _QuestionDifficulty.FETCH_QUESTION_DIFFICULTY_LIST_FAILED:
return _objectSpread({}, state, {
isQuestionDifficultyListLoading: false,
errorQuestionDifficultyList: action.data.error
});
default:
return state;
}
};
exports.questionDifficultyListReducers = questionDifficultyListReducers;
var questionDifficultyReducers = function questionDifficultyReducers() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : QUESTION_DIFFICULTY_INITIAL_STATE;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case _QuestionDifficulty.FETCHING_QUESTION_DIFFICULTY:
return _objectSpread({}, state, {
isQuestionDifficultyLoading: true,
errorQuestionDifficulty: null
});
case _QuestionDifficulty.FETCH_QUESTION_DIFFICULTY_SUCCESS:
return _objectSpread({}, state, {
isQuestionDifficultyLoading: false,
questionDifficulty: action.data
});
case _QuestionDifficulty.FETCH_QUESTION_DIFFICULTY_FAILED:
return _objectSpread({}, state, {
isQuestionDifficultyLoading: false,
errorQuestionDifficulty: action.data.error
});
default:
return state;
}
};
exports.questionDifficultyReducers = questionDifficultyReducers;
//# sourceMappingURL=QuestionDifficulty.js.map