diff options
Diffstat (limited to 'modern/src/store/devices.js')
-rw-r--r-- | modern/src/store/devices.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/modern/src/store/devices.js b/modern/src/store/devices.js index cca23cb9..ab4ca9ee 100644 --- a/modern/src/store/devices.js +++ b/modern/src/store/devices.js @@ -5,6 +5,7 @@ const { reducer, actions } = createSlice({ initialState: { items: {}, selectedId: null, + filteredItems: {}, }, reducers: { refresh(state, action) { @@ -20,6 +21,14 @@ const { reducer, actions } = createSlice({ remove(state, action) { delete state.items[action.payload]; }, + filterByName(state, action) { + return { + ...state, + filteredItems: action.payload ? + Object.values(state.items).filter((item) => item.name?.toLowerCase().includes(action.payload?.toLowerCase())) + : state.items, + } + } }, }); |