4207a3930410069a0871d5a4938d6df18a98fe1f
[arvados-workbench2.git] / src / store / collection-panel / collection-panel-reducer.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { collectionPanelActions, CollectionPanelAction } from "./collection-panel-action";
6 import { CollectionResource } from "~/models/collection";
7
8 export interface CollectionPanelState {
9     item: CollectionResource | null;
10     numberOfCollectionsWithSamePDH: number;
11 }
12
13 const initialState = {
14     item: null,
15     numberOfCollectionsWithSamePDH: 0
16 };
17
18 export const collectionPanelReducer = (state: CollectionPanelState = initialState, action: CollectionPanelAction) =>
19     collectionPanelActions.match(action, {
20         default: () => state,
21         SET_COLLECTION: (item) => ({ ...state, item }),
22         LOAD_COLLECTION_SUCCESS: ({ item }) => ({ ...state, item }),
23         SET_NUMBER_OF_COLLECTIONS_WITH_SAME_PDH: (num) => ({ ...state, numberOfCollectionsWithSamePDH: num }),
24     });