UNPKG

cosmo-ui

Version:
41 lines 1.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var example_actions_1 = require("./example-actions"); var job_1 = require("./job"); var vehicles = [ { id: '1', label: 'Push bike', documentLabel: 'A4', maxWeight: 5, value: 'bicycle', img: 'motorbike', }, { id: '2', label: 'Motor bike', documentLabel: 'A4 Box', maxWeight: 10, value: 'motorbike', img: 'motorbike', }, ]; var initialState = { job: job_1.job, vehicles: vehicles, selectedVehicle: vehicles[1] }; exports.exampleReducer = function (state, action) { if (state === void 0) { state = initialState; } switch (action.type) { case example_actions_1.UPDATE_JOB_FIELD: return updateJobField(state, action); case example_actions_1.UPDATE_VEHICLE_FIELD: return updateVehicleField(state, action); default: return state; } }; var updateJobField = function (state, action) { return (tslib_1.__assign({}, state, { job: tslib_1.__assign({}, state.job, (_a = {}, _a[action.name] = action.field.value, _a)) })); var _a; }; var updateVehicleField = function (state, action) { return (tslib_1.__assign({}, state, { selectedVehicle: action.field.value })); }; //# sourceMappingURL=example-reducer.js.map