lml-main
Version:
This is now a mono repository published into many standalone packages.
40 lines • 1.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var Actions = require("../actions");
exports.initialAllocationDataState = {
byJobId: {},
};
exports.allocationDataReducer = function (state, action) {
if (state === void 0) { state = exports.initialAllocationDataState; }
switch (action.type) {
case Actions.SET_ALLOCATION_BY_ID: {
return setAllocationById(state, action);
}
case Actions.SET_ALLOCATIONS_BY_ID_BATCH: {
return setAllocationsByIdBatch(state, action);
}
case Actions.SET_ALLOCATION_GROUP_BY_ID: {
return setAllocationGroupById(state, action);
}
case Actions.SET_ALLOCATION_GROUPS_BY_ID_BATCH: {
return setAllocationGroupsByIdBatch(state, action);
}
default: {
return state;
}
}
};
var setAllocationById = function (state, action) {
return (tslib_1.__assign({}, state, { byJobId: (_a = {},
_a[action.allocation.job.refId] = action.allocation,
_a) }));
var _a;
};
var setAllocationsByIdBatch = function (state, action) { return (tslib_1.__assign({}, state, { byJobId: tslib_1.__assign({}, state.byJobId, action.allocations) })); };
var setAllocationGroupById = function (state, action) { return (tslib_1.__assign({}, state, { byJobId: tslib_1.__assign({}, state.byJobId, (action.allocationGroup.jobs.reduce(function (previousValue, job) {
previousValue[job.refId] = action.allocationGroup;
return previousValue;
}, {}))) })); };
var setAllocationGroupsByIdBatch = function (state, action) { return (tslib_1.__assign({}, state, { byJobId: tslib_1.__assign({}, state.byJobId, action.allocationGroups) })); };
//# sourceMappingURL=data.js.map