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 interface CollectionCreatorState {
12 const updateCreator = (state: CollectionCreatorState, creator?: Partial<CollectionCreatorState>) => ({
17 const initialState: CollectionCreatorState = {
22 export const collectionCreatorReducer = (state: CollectionCreatorState = initialState, action: CollectionCreateAction) => {
23 return collectionCreateActions.match(action, {
24 OPEN_COLLECTION_CREATOR: ({ ownerUuid }) => updateCreator(state, { ownerUuid, opened: true }),
25 CLOSE_COLLECTION_CREATOR: () => updateCreator(state, { opened: false }),
26 CREATE_COLLECTION: () => updateCreator(state),
27 CREATE_COLLECTION_SUCCESS: () => updateCreator(state, { opened: false, ownerUuid: "" }),