Navigation fixes
[arvados-workbench2.git] / src / store / collection / collection-reducer.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import actions, { CollectionAction } from "./collection-action";
6 import { Collection } from "../../models/collection";
7
8 export type CollectionState = Collection[];
9
10
11 const collectionsReducer = (state: CollectionState = [], action: CollectionAction) => {
12     return actions.match(action, {
13         CREATE_COLLECTION: collection => [...state, collection],
14         REMOVE_COLLECTION: () => state,
15         COLLECTIONS_REQUEST: () => {
16             return [];
17         },
18         COLLECTIONS_SUCCESS: ({ collections }) => {
19             return collections;
20         },
21         default: () => state
22     });
23 };
24
25 export default collectionsReducer;