UNPKG

lml-main

Version:

This is now a mono repository published into many standalone packages.

35 lines 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const redux_observable_1 = require("redux-observable"); const cosmo_redux_api_1 = require("@lml/cosmo-redux-api"); const cosmoui_1 = require("cosmoui"); const utils_1 = require("../../jobs/utils"); const constants_1 = require("../constants"); const actions_1 = require("../../jobs/actions"); /** * This api call can be used either to create a new job * Or to clone an existing job, but right now it should only support clone * * @param action$ * @param store */ exports.submitJobForm = (action$, store) => action$.ofType(actions_1.SUBMIT_JOB_FORM) .map((action) => { const state = store.getState(); const { formData, jobFormType, baseJob } = action; const job = utils_1.mkJobRequestBody(formData, jobFormType, baseJob); if (jobFormType === actions_1.JOB_FORM_TYPE_CREATE || jobFormType === actions_1.JOB_FORM_TYPE_CLONE) { return cosmo_redux_api_1.postJob(job, action); } else if (jobFormType === actions_1.JOB_FORM_TYPE_EDIT) { return cosmo_redux_api_1.putJob(job, action); } }); exports.hideJobFormModal = (action$, store) => action$.ofType(cosmo_redux_api_1.POST_JOB.SUCCESS, cosmo_redux_api_1.PUT_JOB.SUCCESS) .filter(a => a.args.type === actions_1.SUBMIT_JOB_FORM) .mergeMap((action) => [ cosmoui_1.closeModal(constants_1.JOB_FORM_MODAL_KEY), ]); exports.jobFormEpics = redux_observable_1.combineEpics(exports.submitJobForm, exports.hideJobFormModal); //# sourceMappingURL=job-form.js.map