@omegabigdata/honoplay-redux-helper
Version:
honoplay-redux-helper
121 lines (97 loc) • 4.94 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.questionCategoryListReducers = exports.updateQuestionCategoryReducers = exports.createQuestionCategoryReducers = void 0;
var _QuestionCategory = require("../helpers/ActionTypes/QuestionCategory");
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_QUESTİON_CATEGORY_INITIAL_STATE = {
isCreateQuestionCategoryLoading: false,
newQuestionCategory: null,
errorCreateQuestionCategory: null
};
var UPDATE_QUESTİON_CATEGORY_INITIAL_STATE = {
isUpdateQuestionCategoryLoading: false,
updatedQuestionCategory: null,
errorUpdateQuestionCategory: null
};
var QUESTİON_CATEGORY_LIST_INITIAL_STATE = {
isQuestionCategoryListLoading: false,
questionCategories: null,
errorQuestionCategoryList: null
};
var createQuestionCategoryReducers = function createQuestionCategoryReducers() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CREATE_QUESTİON_CATEGORY_INITIAL_STATE;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case _QuestionCategory.CREATING_QUESTİON_CATEGORY:
return _objectSpread({}, state, {
isCreateQuestionCategoryLoading: true,
errorCreateQuestionCategory: null
});
case _QuestionCategory.CREATE__QUESTİON_CATEGORY_SUCCESS:
return _objectSpread({}, state, {
isCreateQuestionCategoryLoading: false,
newQuestionCategory: action.data
});
case _QuestionCategory.CREATE_QUESTİON_CATEGORY_FAILED:
return _objectSpread({}, state, {
isCreateQuestionCategoryLoading: false,
errorCreateQuestionCategory: action.data.error
});
default:
return state;
}
};
exports.createQuestionCategoryReducers = createQuestionCategoryReducers;
var updateQuestionCategoryReducers = function updateQuestionCategoryReducers() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : UPDATE_QUESTİON_CATEGORY_INITIAL_STATE;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case _QuestionCategory.UPDATING_QUESTİON_CATEGORY:
return _objectSpread({}, state, {
isUpdateQuestionCategoryLoading: true,
errorUpdateQuestionCategory: null
});
case _QuestionCategory.UPDATE_QUESTİON_CATEGORY_SUCCESS:
return _objectSpread({}, state, {
isUpdateQuestionCategoryLoading: false,
updatedQuestionCategory: action.data
});
case _QuestionCategory.UPDATE_QUESTİON_CATEGORY_FAILED:
return _objectSpread({}, state, {
isUpdateQuestionCategoryLoading: false,
errorUpdateQuestionCategory: action.data.error
});
default:
return state;
}
};
exports.updateQuestionCategoryReducers = updateQuestionCategoryReducers;
var questionCategoryListReducers = function questionCategoryListReducers() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : QUESTİON_CATEGORY_LIST_INITIAL_STATE;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case _QuestionCategory.FETCHING_QUESTİON_CATEGORY_LIST:
return _objectSpread({}, state, {
isQuestionCategoryListLoading: true,
errorQuestionCategoryList: null
});
case _QuestionCategory.FETCH_QUESTİON_CATEGORY_LIST_SUCCESS:
return _objectSpread({}, state, {
isQuestionCategoryListLoading: false,
questionCategories: action.data
});
case _QuestionCategory.FETCH_QUESTİON_CATEGORY_LIST_FAILED:
return _objectSpread({}, state, {
isQuestionCategoryListLoading: false,
errorQuestionCategoryList: action.data.error
});
default:
return state;
}
};
exports.questionCategoryListReducers = questionCategoryListReducers;
//# sourceMappingURL=QuestionCategory.js.map