Merge branch '14917-searching-by-properties'
[arvados.git] / src / store / resources / resources-reducer.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { ResourcesState, setResource, deleteResource } from './resources';
6 import { ResourcesAction, resourcesActions } from './resources-actions';
7
8 export const resourcesReducer = (state: ResourcesState = {}, action: ResourcesAction) =>
9     resourcesActions.match(action, {
10         SET_RESOURCES: resources => resources.reduce((state, resource) => setResource(resource.uuid, resource)(state), state),
11         DELETE_RESOURCES: ids => ids.reduce((state, id) => deleteResource(id)(state), state),
12         default: () => state,
13     });