1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { collectionCreateActions, CollectionCreateAction } from './collection-creator-action';
7 export type CollectionCreatorState = CollectionCreator;
9 interface CollectionCreator {
14 const updateCreator = (state: CollectionCreatorState, creator?: Partial<CollectionCreator>) => ({
19 const initialState: CollectionCreatorState = {
24 export const collectionCreatorReducer = (state: CollectionCreatorState = initialState, action: CollectionCreateAction) => {
25 return collectionCreateActions.match(action, {
26 OPEN_COLLECTION_CREATOR: ({ ownerUuid }) => updateCreator(state, { ownerUuid, opened: true }),
27 CLOSE_COLLECTION_CREATOR: () => updateCreator(state, { opened: false }),
28 CREATE_COLLECTION: () => updateCreator(state),
29 CREATE_COLLECTION_SUCCESS: () => updateCreator(state, { opened: false, ownerUuid: "" }),