@omegabigdata/honoplay-redux-helper
Version:
honoplay-redux-helper
156 lines (126 loc) • 5.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.updateQuestionReducers = exports.createQuestionReducers = exports.questionReducers = exports.questionListReducers = void 0;
var _Question = require("../helpers/ActionTypes/Question");
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_LIST_INITIAL_STATE = {
isQuestionListLoading: false,
questionsList: null,
errorQuestionList: null
};
var QUESTION_INITIAL_STATE = {
isQuestionLoading: false,
question: null,
errorQuestion: null
};
var CREATE_QUESTION_INITIAL_STATE = {
isCreateQuestionLoading: false,
createQuestion: null,
errorCreateQuestion: null
};
var UPDATE_QUESTION_INITIAL_STATE = {
isUpdateQuestionLoading: false,
updateQuestion: null,
errorUpdateQuestion: null
};
var questionListReducers = function questionListReducers() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : QUESTION_LIST_INITIAL_STATE;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case _Question.FETCHING_QUESTION_LIST:
return _objectSpread({}, state, {
isQuestionListLoading: true,
errorQuestionList: null
});
case _Question.FETCH_QUESTION_LIST_SUCCESS:
return _objectSpread({}, state, {
isQuestionListLoading: false,
questionsList: action.data
});
case _Question.FETCH_QUESTION_LIST_FAILED:
return _objectSpread({}, state, {
isQuestionListLoading: false,
errorQuestionList: action.data.error
});
default:
return state;
}
};
exports.questionListReducers = questionListReducers;
var questionReducers = function questionReducers() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : QUESTION_INITIAL_STATE;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case _Question.FETCHING_QUESTION:
return _objectSpread({}, state, {
isQuestionLoading: true,
errorQuestion: null
});
case _Question.FETCH_QUESTION_SUCCESS:
return _objectSpread({}, state, {
isQuestionLoading: false,
question: action.data
});
case _Question.FETCH_QUESTION_FAILED:
return _objectSpread({}, state, {
isQuestionLoading: false,
errorQuestion: action.data.error
});
default:
return state;
}
};
exports.questionReducers = questionReducers;
var createQuestionReducers = function createQuestionReducers() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CREATE_QUESTION_INITIAL_STATE;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case _Question.CREATING_QUESTION:
return _objectSpread({}, state, {
isCreateQuestionLoading: true,
errorCreateQuestion: null
});
case _Question.CREATE_QUESTION_SUCCESS:
return _objectSpread({}, state, {
isCreateQuestionLoading: false,
createQuestion: action.data
});
case _Question.CREATE_QUESTION_FAILED:
return _objectSpread({}, state, {
isCreateQuestionLoading: false,
errorCreateQuestion: action.data.error
});
default:
return state;
}
};
exports.createQuestionReducers = createQuestionReducers;
var updateQuestionReducers = function updateQuestionReducers() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : UPDATE_QUESTION_INITIAL_STATE;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case _Question.UPDATING_QUESTION:
return _objectSpread({}, state, {
isUpdateQuestionLoading: true,
errorUpdateQuestion: null
});
case _Question.UPDATE_QUESTION_SUCCESS:
return _objectSpread({}, state, {
isUpdateQuestionLoading: false,
updateQuestion: action.data
});
case _Question.UPDATE_QUESTION_FAILED:
return _objectSpread({}, state, {
isUpdateQuestionLoading: false,
errorUpdateQuestion: action.data.error
});
default:
return state;
}
};
exports.updateQuestionReducers = updateQuestionReducers;
//# sourceMappingURL=Question.js.map