UNPKG

kitchen-simulator

Version:

It is a kitchen simulator (self-contained micro-frontend).

82 lines (81 loc) 2.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = _default; var _constants = require("../constants"); var _convertUnitsLite = require("../utils/convert-units-lite"); function _default(state, action) { var _state = state, scene = _state.scene; switch (action.type) { case _constants.UPDATE_CEIL_HEIGHT_UNIT: { var _state2 = state, _scene = _state2.scene; var selectedLayer = _scene.selectedLayer; var layer = _scene.layers.get(selectedLayer); var newLayer = layer.merge({ unit: action.value }); state = state.mergeIn(['scene', 'layers', selectedLayer], newLayer); return state; } case _constants.UPDATE_CEIL_HEIGHT: { var _selectedLayer = scene.selectedLayer; var _layer = scene.layers.get(_selectedLayer); var _newLayer = _layer.merge({ ceilHeight: action.value }); state = state.mergeIn(['scene', 'layers', _selectedLayer], _newLayer); var items = state.scene.layers.get(state.scene.selectedLayer).items; var newItems = items.map(function (item) { if (item.type.includes('Light')) { var height = item.properties.getIn(['height', '_length']); var heightUnit = item.properties.getIn(['height', '_unit']); var newAltitude = action.value - (0, _convertUnitsLite.convert)(height).from(heightUnit).to('in'); item = item.setIn(['properties', 'altitude', '_length'], (0, _convertUnitsLite.convert)(newAltitude).from('in').to(_layer.unit)); } return item; }); state = state.mergeIn(['scene', 'layers', _selectedLayer, 'items'], newItems); return state; } case _constants.UPDATE_2D_CAMERA: return state.merge({ viewer2D: action.value }); case _constants.CHANGE_WALL_LENGTH_MEASURE: return state.merge({ scene: scene.merge({ showWallLengthMeasure: action.value }) }); case _constants.CHANGE_BASE_CABINET_MEASURE: return state.merge({ scene: scene.merge({ showBaseCabinetMeasure: action.value }) }); case _constants.CHANGE_WALL_CABINET_MEASURE: return state.merge({ scene: scene.merge({ showWallCabinetMeasure: action.value }) }); case _constants.CHANGE_WINDOW_DOOR_MEASURE: return state.merge({ scene: scene.merge({ showWindowDoorMeasure: action.value }) }); case _constants.SELECT_TOOL_PAN: return state.set('mode', _constants.MODE_2D_PAN); case _constants.SELECT_TOOL_ZOOM_IN: return state.set('mode', _constants.MODE_2D_ZOOM_IN); case _constants.SELECT_TOOL_ZOOM_OUT: return state.set('mode', _constants.MODE_2D_ZOOM_OUT); } } module.exports = exports.default;