From 4d200181a6a97c8143d0843f07d90072ef35e25c Mon Sep 17 00:00:00 2001 From: ditoaugusta Date: Wed, 25 Mar 2020 00:26:02 +0700 Subject: delete actions and reducers folder --- modern/src/actions/index.js | 19 ------------------- modern/src/reducers/index.js | 35 ----------------------------------- 2 files changed, 54 deletions(-) delete mode 100644 modern/src/actions/index.js delete mode 100644 modern/src/reducers/index.js diff --git a/modern/src/actions/index.js b/modern/src/actions/index.js deleted file mode 100644 index 5527810..0000000 --- a/modern/src/actions/index.js +++ /dev/null @@ -1,19 +0,0 @@ -export const updateDevices = devices => ({ - type: 'UPDATE_DEVICES', - devices -}) - -export const updatePositions = positions => ({ - type: 'UPDATE_POSITIONS', - positions -}); - -export const updateEvents = events => ({ - type: 'UPDATE_EVENTS', - events -}) - -export const selectDevice = device => ({ - type: 'SELECT_DEVICE', - device -}) diff --git a/modern/src/reducers/index.js b/modern/src/reducers/index.js deleted file mode 100644 index 752a4c3..0000000 --- a/modern/src/reducers/index.js +++ /dev/null @@ -1,35 +0,0 @@ -const initialState = { - devices: new Map(), - positions: new Map() -}; - -function updateMap(map, array, key) { - for (let value of array) { - map.set(value[key], value); - } - return map; -} - -function rootReducer(state = initialState, action) { - switch (action.type) { - case 'UPDATE_DEVICES': - return Object.assign({}, { - ...state, - devices: updateMap(state.devices, action.devices, 'id') - }); - case 'UPDATE_POSITIONS': - return Object.assign({}, { - ...state, - positions: updateMap(state.positions, action.positions, 'deviceId') - }); - case 'SELECT_DEVICE': - return Object.assign({}, { - ...state, - selectedDevice: action.device.id - }); - default: - return state; - } -} - -export default rootReducer -- cgit v1.2.3