lml-main
Version:
This is now a mono repository published into many standalone packages.
25 lines • 1.53 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const redux_observable_1 = require("redux-observable");
const ts_utils_1 = require("@lml/ts-utils");
const actions_1 = require("../../frequencies/actions");
const cosmo_ui_auth_1 = require("@lml/cosmo-ui-auth");
const redux_rx_http_1 = require("redux-rx-http");
const cosmoui_1 = require("cosmoui");
exports.getFrequencies = (action$, store) => action$.ofType(cosmo_ui_auth_1.AUTHENTICATED, actions_1.GET_FREQUENCIES_DATA)
.map((action) => redux_rx_http_1.rxHttpGet('/v2/joblabel/regions/flat', actions_1.GET_FREQUENCIES));
exports.getFrequenciesSuccess = (action$, store) => action$.ofType(actions_1.GET_FREQUENCIES.SUCCESS)
.mergeMap((action) => {
const res = action.result;
res.labels = ts_utils_1.arrayToMap(res.labels, 'label');
res.regions = ts_utils_1.arrayToMap(res.regions, 'name');
res.serviceCentres = ts_utils_1.arrayToMap(res.serviceCentres, 'code');
return [
actions_1.setFrequenciesData(res.regions, res.serviceCentres, res.labels, res.autoAllocationGlobal),
actions_1.cleanFrequencyFlags(res.labels),
];
});
exports.getFrequenciesError = (action$, store) => action$.ofType(actions_1.GET_FREQUENCIES.ERROR)
.mapTo(cosmoui_1.notificationError('Failed to load frequencies at start up. Please refresh'));
exports.getFrequencyEpics = redux_observable_1.combineEpics(exports.getFrequencies, exports.getFrequenciesSuccess, exports.getFrequenciesError);
//# sourceMappingURL=get-frequencies.js.map