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 = {
8 creator: CollectionCreator
11 interface CollectionCreator {
16 const updateCreator = (state: CollectionCreatorState, creator?: Partial<CollectionCreator>) => ({
24 const initialState: CollectionCreatorState = {
31 export const collectionCreationReducer = (state: CollectionCreatorState = initialState, action: CollectionCreateAction) => {
32 return collectionCreateActions.match(action, {
33 OPEN_COLLECTION_CREATOR: ({ ownerUuid }) => updateCreator(state, { ownerUuid, opened: true }),
34 CLOSE_COLLECTION_CREATOR: () => updateCreator(state, { opened: false }),
35 CREATE_COLLECTION: () => updateCreator(state),
36 CREATE_COLLECTION_SUCCESS: () => updateCreator(state, { opened: false, ownerUuid: "" }),