UNPKG

lml-main

Version:

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

105 lines 4.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var redux_rx_http_1 = require("redux-rx-http"); exports.POST_ALLOCATION = redux_rx_http_1.createRxHttpActionTypes('POST_ALLOCATION'); exports.POST_REALLOCATION = redux_rx_http_1.createRxHttpActionTypes('POST_REALLOCATION'); exports.POST_DEALLOCATION = redux_rx_http_1.createRxHttpActionTypes('POST_DEALLOCATION'); exports.POST_TAG = redux_rx_http_1.createRxHttpActionTypes('POST_TAG'); exports.POST_UNTAG = redux_rx_http_1.createRxHttpActionTypes('POST_UNTAG'); exports.POST_ALLOCATION_GROUP = redux_rx_http_1.createRxHttpActionTypes('POST_ALLOCATION_GROUP'); exports.POST_REALLOCATION_GROUP = redux_rx_http_1.createRxHttpActionTypes('POST_REALLOCATION_GROUP'); exports.POST_DEALLOCATION_GROUP = redux_rx_http_1.createRxHttpActionTypes('POST_DEALLOCATION_GROUP'); exports.POST_TAG_GROUP = redux_rx_http_1.createRxHttpActionTypes('POST_TAG_GROUP'); exports.POST_UNTAG_GROUP = redux_rx_http_1.createRxHttpActionTypes('POST_UNTAG_GROUP'); exports.SET_ALLOCATION_BY_ID = 'SET_ALLOCATION_BY_ID'; exports.SET_ALLOCATIONS_BY_ID_BATCH = 'SET_ALLOCATIONS_BY_ID_BATCH'; exports.SET_ALLOCATION_GROUP_BY_ID = 'SET_ALLOCATION_GROUP_BY_ID'; exports.SET_ALLOCATION_GROUPS_BY_ID_BATCH = 'SET_ALLOCATION_GROUPS_BY_ID_BATCH'; exports.postAllocation = function (job, courier, callsign, allocationType, username, args) { if (args === void 0) { args = {}; } var allocationAction = getAllocationAction(allocationType); var config = { args: tslib_1.__assign({ job: job, courier: courier, callsign: callsign, username: username, allocationType: allocationType }, args), }; var body = { courier: { refId: courier.refId, callsign: callsign, }, job: { refId: job.refId, }, user: username, type: allocationType, }; return redux_rx_http_1.rxHttpPost('/v2/allocation', allocationAction, body, config); }; exports.postAllocationGroup = function (jobs, courier, allocationType, username, args) { if (args === void 0) { args = {}; } var allocationAction = getAllocationGroupAction(allocationType); var config = { args: tslib_1.__assign({ jobs: jobs, courier: courier, username: username, allocationType: allocationType }, args), }; var body = { courier: { refId: courier.refId, }, jobs: jobs.map(function (job) { return ({ refId: job.refId }); }), user: username, type: allocationType, }; return redux_rx_http_1.rxHttpPost('/v2/allocation/batch', allocationAction, body, config); }; var getAllocationAction = function (allocationType) { switch (allocationType) { case 'ACTUAL': return exports.POST_ALLOCATION; case 'DEALLOCATION': return exports.POST_DEALLOCATION; case 'REALLOCATION': return exports.POST_REALLOCATION; case 'TAG': return exports.POST_TAG; case 'UNTAG': return exports.POST_UNTAG; default: throw new Error("Invalid allocation type: " + allocationType); } }; var getAllocationGroupAction = function (allocationType) { switch (allocationType) { case 'ACTUAL': return exports.POST_ALLOCATION_GROUP; case 'DEALLOCATION': return exports.POST_DEALLOCATION_GROUP; case 'REALLOCATION': return exports.POST_REALLOCATION_GROUP; case 'TAG': return exports.POST_TAG_GROUP; case 'UNTAG': return exports.POST_UNTAG_GROUP; default: throw new Error("Invalid allocation type: " + allocationType); } }; exports.setAllocationById = function (allocation) { return ({ type: exports.SET_ALLOCATION_BY_ID, allocation: allocation }); }; exports.setAllocationsByIdBatch = function (allocations) { return ({ type: exports.SET_ALLOCATIONS_BY_ID_BATCH, allocations: allocations }); }; exports.setAllocationGroupById = function (allocationGroup) { return ({ type: exports.SET_ALLOCATION_GROUP_BY_ID, allocationGroup: allocationGroup }); }; exports.setAllocationGroupByIdBatch = function (allocationGroups) { return ({ type: exports.SET_ALLOCATION_GROUPS_BY_ID_BATCH, allocationGroups: allocationGroups }); }; //# sourceMappingURL=allocation.js.map