aboutsummaryrefslogtreecommitdiff
path: root/modern/src/store/devices.js
blob: 0d96e98d3cbcb36982dda2d2b7792d64dd1d54be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 };