@omegabigdata/honoplay-redux-helper
Version:
honoplay-redux-helper
109 lines (94 loc) • 2.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.updateTrainer = exports.createTrainer = exports.fetchTrainer = exports.fetchTrainersList = void 0;
var _Trainer = require("../helpers/ActionTypes/Trainer");
var _honoplayApiHelperNode = require("@omegabigdata/honoplay-api-helper-node");
var fetchTrainersList = function fetchTrainersList() {
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: _Trainer.FETCHING_TRAINER_LIST
});
_honoplayApiHelperNode.Trainer.getTrainers(skip, take, function (success) {
dispatch({
type: _Trainer.FETCH_TRAINER_LIST_SUCCESS,
data: success.data
});
}, function (error) {
dispatch({
type: _Trainer.FETCH_TRAINER_LIST_FAILED,
data: {
error: error
}
});
});
};
};
exports.fetchTrainersList = fetchTrainersList;
var fetchTrainer = function fetchTrainer(trainerId) {
return function (dispatch) {
dispatch({
type: _Trainer.FETCHING_TRAINER
});
_honoplayApiHelperNode.Trainer.getTrainer(trainerId, function (success) {
dispatch({
type: _Trainer.FETCH_TRAINER_SUCCESS,
data: success.data
});
}, function (error) {
dispatch({
type: _Trainer.FETCH_TRAINER_FAILED,
data: {
error: error
}
});
});
};
};
exports.fetchTrainer = fetchTrainer;
var createTrainer = function createTrainer(trainerModel) {
return function (dispatch) {
dispatch({
type: _Trainer.CREATING_TRAINER
});
_honoplayApiHelperNode.Trainer.postTrainer(trainerModel, function (success) {
dispatch({
type: _Trainer.CREATE_TRAINER_SUCCESS,
data: success.data
});
}, function (error) {
dispatch({
type: _Trainer.CREATE_TRAINER_FAILED,
data: {
error: error
}
});
});
};
};
exports.createTrainer = createTrainer;
var updateTrainer = function updateTrainer(trainerModel) {
return function (dispatch) {
dispatch({
type: _Trainer.UPDATING_TRAINER
});
_honoplayApiHelperNode.Trainer.putTrainer(trainerModel, function (success) {
dispatch({
type: _Trainer.UPDATE_TRAINER_SUCCESS,
data: success.data
});
}, function (error) {
dispatch({
type: _Trainer.UPDATE_TRAINER_FAILED,
data: {
error: error
}
});
});
};
};
exports.updateTrainer = updateTrainer;
//# sourceMappingURL=Trainer.js.map