diff options
Diffstat (limited to 'modern/src/store/devices.js')
-rw-r--r-- | modern/src/store/devices.js | 20 |
1 files changed, 20 insertions, 0 deletions
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 }; |