UNPKG

@omegabigdata/honoplay-redux-helper

Version:
109 lines (94 loc) 2.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.updateQuestion = exports.createQuestion = exports.fetchQuestion = exports.fetchQuestionList = void 0; var _Question = require("../helpers/ActionTypes/Question"); var _honoplayApiHelperNode = require("@omegabigdata/honoplay-api-helper-node"); var fetchQuestionList = function fetchQuestionList() { var skip = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; var take = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; return function (dispatch) { dispatch({ type: _Question.FETCHING_QUESTION_LIST }); _honoplayApiHelperNode.Question.getQuestions(skip, take, function (success) { dispatch({ type: _Question.FETCH_QUESTION_LIST_SUCCESS, data: success.data }); }, function (error) { dispatch({ type: _Question.FETCH_QUESTION_LIST_FAILED, data: { error: error } }); }); }; }; exports.fetchQuestionList = fetchQuestionList; var fetchQuestion = function fetchQuestion(questionId) { return function (dispatch) { dispatch({ type: _Question.FETCHING_QUESTION }); _honoplayApiHelperNode.Question.getQuestion(questionId, function (success) { dispatch({ type: _Question.FETCH_QUESTION_SUCCESS, data: success.data }); }, function (error) { dispatch({ type: _Question.FETCH_QUESTION_FAILED, data: { error: error } }); }); }; }; exports.fetchQuestion = fetchQuestion; var createQuestion = function createQuestion(questionModel) { return function (dispatch) { dispatch({ type: _Question.CREATING_QUESTION }); _honoplayApiHelperNode.Question.postQuestion(questionModel, function (success) { dispatch({ type: _Question.CREATE_QUESTION_SUCCESS, data: success.data }); }, function (error) { dispatch({ type: _Question.CREATE_QUESTION_FAILED, data: { error: error } }); }); }; }; exports.createQuestion = createQuestion; var updateQuestion = function updateQuestion(questionModel) { return function (dispatch) { dispatch({ type: _Question.UPDATING_QUESTION }); _honoplayApiHelperNode.Question.putQuestion(questionModel, function (success) { dispatch({ type: _Question.UPDATE_QUESTION_SUCCESS, data: success.data }); }, function (error) { dispatch({ type: _Question.UPDATE_QUESTION_FAILED, data: { error: error } }); }); }; }; exports.updateQuestion = updateQuestion; //# sourceMappingURL=Question.js.map