lml-main
Version:
This is now a mono repository published into many standalone packages.
26 lines • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const redux_observable_1 = require("redux-observable");
const cosmo_ui_auth_1 = require("@lml/cosmo-ui-auth");
const constants_1 = require("../../jobs/constants");
const cosmoui_1 = require("cosmoui");
const actions_1 = require("../../jobs/actions");
const cosmo_redux_api_1 = require("@lml/cosmo-redux-api");
exports.postJobIncidentEpic = (action$, store) => action$.ofType(actions_1.SUBMIT_JOB_INCIDENT_FORM)
.map((action) => {
const state = store.getState();
return cosmo_redux_api_1.postJobIncident(action.jobRefId, action.impact, action.reason, action.comment, cosmo_ui_auth_1.getUsername(state), action);
});
exports.postJobIncidentSuccess = (action$, store) => action$.ofType(cosmo_redux_api_1.POST_JOB_INCIDENT.SUCCESS)
.filter(a => a.args.type === actions_1.SUBMIT_JOB_INCIDENT_FORM)
.mergeMap(action => {
const res = [
cosmoui_1.resetForm(constants_1.JOB_INCIDENT_FORM_KEY),
];
if (action.result.jobId) {
res.push(cosmo_redux_api_1.fetchJobById(action.result.jobId, 'incidents'));
}
return res;
});
exports.postJobIncidentEpics = redux_observable_1.combineEpics(exports.postJobIncidentEpic, exports.postJobIncidentSuccess);
//# sourceMappingURL=post-job-incident.js.map