From 506fe663e2e3b9ffe9764f5c06b04524c4793534 Mon Sep 17 00:00:00 2001 From: ditoaugusta Date: Wed, 25 Mar 2020 00:24:33 +0700 Subject: delete module subfolder. edit relative path. --- modern/src/store/devices.js | 20 ++++++++++++++++++++ modern/src/store/index.js | 15 ++++++++++++--- modern/src/store/modules/devices.js | 20 -------------------- modern/src/store/modules/index.js | 12 ------------ modern/src/store/modules/positions.js | 16 ---------------- modern/src/store/positions.js | 16 ++++++++++++++++ 6 files changed, 48 insertions(+), 51 deletions(-) create mode 100644 modern/src/store/devices.js delete mode 100644 modern/src/store/modules/devices.js delete mode 100644 modern/src/store/modules/index.js delete mode 100644 modern/src/store/modules/positions.js create mode 100644 modern/src/store/positions.js (limited to 'modern/src/store') diff --git a/modern/src/store/devices.js b/modern/src/store/devices.js new file mode 100644 index 00000000..0d96e98d --- /dev/null +++ b/modern/src/store/devices.js @@ -0,0 +1,20 @@ +import { createSlice } from '@reduxjs/toolkit'; + +const { reducer, actions } = createSlice({ + name: 'devices', + initialState: { + items: {}, + selectedId: null + }, + reducers: { + update(state, action) { + action.payload.forEach(item => state.items[item['id']] = item); + }, + select(state, action) { + state.selectedId = action.payload.id; + } + } +}); + +export { actions as devicesActions }; +export { reducer as devicesReducer }; diff --git a/modern/src/store/index.js b/modern/src/store/index.js index c981c136..86de31a9 100644 --- a/modern/src/store/index.js +++ b/modern/src/store/index.js @@ -1,5 +1,14 @@ -import { configureStore } from '@reduxjs/toolkit'; +import { combineReducers, configureStore } from '@reduxjs/toolkit'; -import { rootReducer } from './modules'; +import { devicesReducer as devices } from './devices'; +import { positionsReducer as positions } from './positions'; -export default configureStore({ reducer: rootReducer }); +const reducer = combineReducers({ + devices, + positions, +}); + +export { devicesActions } from './devices'; +export { positionsActions } from './positions'; + +export default configureStore({ reducer }); diff --git a/modern/src/store/modules/devices.js b/modern/src/store/modules/devices.js deleted file mode 100644 index 0d96e98d..00000000 --- a/modern/src/store/modules/devices.js +++ /dev/null @@ -1,20 +0,0 @@ -import { createSlice } from '@reduxjs/toolkit'; - -const { reducer, actions } = createSlice({ - name: 'devices', - initialState: { - items: {}, - selectedId: null - }, - reducers: { - update(state, action) { - action.payload.forEach(item => state.items[item['id']] = item); - }, - select(state, action) { - state.selectedId = action.payload.id; - } - } -}); - -export { actions as devicesActions }; -export { reducer as devicesReducer }; diff --git a/modern/src/store/modules/index.js b/modern/src/store/modules/index.js deleted file mode 100644 index e2037c72..00000000 --- a/modern/src/store/modules/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import { combineReducers } from '@reduxjs/toolkit'; - -import { devicesReducer as devices } from './devices'; -import { positionsReducer as positions } from './positions'; - -export const rootReducer = combineReducers({ - devices, - positions, -}); - -export { devicesActions } from './devices'; -export { positionsActions } from './positions'; diff --git a/modern/src/store/modules/positions.js b/modern/src/store/modules/positions.js deleted file mode 100644 index 1df468cd..00000000 --- a/modern/src/store/modules/positions.js +++ /dev/null @@ -1,16 +0,0 @@ -import { createSlice } from '@reduxjs/toolkit'; - -const { reducer, actions } = createSlice({ - name: 'positions', - initialState: { - items: {}, - }, - reducers: { - update(state, action) { - action.payload.forEach(item => state.items[item['deviceId']] = item); - }, - } -}); - -export { actions as positionsActions }; -export { reducer as positionsReducer }; diff --git a/modern/src/store/positions.js b/modern/src/store/positions.js new file mode 100644 index 00000000..1df468cd --- /dev/null +++ b/modern/src/store/positions.js @@ -0,0 +1,16 @@ +import { createSlice } from '@reduxjs/toolkit'; + +const { reducer, actions } = createSlice({ + name: 'positions', + initialState: { + items: {}, + }, + reducers: { + update(state, action) { + action.payload.forEach(item => state.items[item['deviceId']] = item); + }, + } +}); + +export { actions as positionsActions }; +export { reducer as positionsReducer }; -- cgit v1.2.3