lml-main
Version:
This is now a mono repository published into many standalone packages.
39 lines • 1.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var redux_observable_1 = require("redux-observable");
var cosmoui_1 = require("cosmoui");
var actions_1 = require("../actions");
exports.fetchJobByJobNumberSuccess = function (action$, store) {
return action$.ofType(actions_1.FETCH_JOB_BY_JOB_NUMBER.SUCCESS)
.mergeMap(function (action) {
var _a = action.result, job = _a.job, jobStatus = _a.jobStatus, jobAudit = _a.jobAudit, incidents = _a.incidents, jobDelay = _a.jobDelay, scrMatches = _a.scrMatches;
var jobNumber = action.args.jobNumber;
// note the refId comes from the job object
// if it isn't there then we can't really save anything in the state
if (!job)
return [];
var res = [actions_1.setJobById(job)];
if (jobStatus) {
res.push(actions_1.setJobStatusById(jobStatus));
}
if (jobAudit) {
res.push(actions_1.setJobAudit(job.refId, jobAudit));
}
if (incidents) {
res.push(actions_1.setJobIncidents(job.refId, incidents));
}
if (jobDelay) {
res.push(actions_1.setJobDelay(job.refId, jobDelay));
}
if (scrMatches) {
res.push(actions_1.setSmartMatches(job.refId, scrMatches));
}
return res;
});
};
exports.fetchJobByJobNumberError = function (action$, store) {
return action$.ofType(actions_1.FETCH_JOB_BY_JOB_NUMBER.ERROR)
.mapTo(cosmoui_1.notificationError('There was a problem fetching the selected job. Please refresh.'));
};
exports.fetchJobByJobNumberEpics = redux_observable_1.combineEpics(exports.fetchJobByJobNumberSuccess, exports.fetchJobByJobNumberError);
//# sourceMappingURL=fetch-job-by-job-number.js.map