UNPKG

kitchen-simulator

Version:

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

45 lines 2.2 kB
import { Line } from "../class/export"; import { history } from "../utils/export"; import { SELECT_TOOL_DRAWING_LINE, BEGIN_DRAWING_LINE, UPDATE_DRAWING_LINE, END_DRAWING_LINE, BEGIN_DRAGGING_LINE, UPDATE_DRAGGING_LINE, END_DRAGGING_LINE, SELECT_LINE, STOP_DRAWING_LINE, SET_RELATED_LINE } from "../constants"; export default function (state, action) { switch (action.type) { case SELECT_TOOL_DRAWING_LINE: sessionStorage.setItem('hintTextShow', true); setTimeout(function () { sessionStorage.setItem('hintTextShow', false); }, 500); return Line.selectToolDrawingLine(state, action.sceneComponentType).updatedState; case BEGIN_DRAWING_LINE: state = state.merge({ sceneHistory: history.historyPush(state.sceneHistory, state.scene) }); return Line.beginDrawingLine(state, action.layerID, action.x, action.y).updatedState; case UPDATE_DRAWING_LINE: return Line.updateDrawingLine(state, action.x, action.y, action.relatedLines).updatedState; case STOP_DRAWING_LINE: return Line.stopDrawingLine(state).updatedState; case END_DRAWING_LINE: state = state.merge({ sceneHistory: history.historyPush(state.sceneHistory, state.scene) }); return Line.endDrawingLine(state, action.x, action.y).updatedState; case BEGIN_DRAGGING_LINE: state = state.merge({ sceneHistory: history.historyPush(state.sceneHistory, state.scene) }); return Line.beginDraggingLine(state, action.layerID, action.lineID, action.x, action.y).updatedState; case UPDATE_DRAGGING_LINE: return Line.updateDraggingLine(state, action.x, action.y, action.relatedLines).updatedState; case END_DRAGGING_LINE: state = state.merge({ sceneHistory: history.historyPush(state.sceneHistory, state.scene) }); return Line.endDraggingLine(state, action.x, action.y, action.relatedLines).updatedState; case SELECT_LINE: return Line.select(state, action.layerID, action.lineID).updatedState; case SET_RELATED_LINE: return Line.setRelatedLine(state, action.layerID, action.lineID, action.intersection).updatedState; default: return state; } }