refs #14280 Merge branch 'origin/14280-query-language'
[arvados-workbench2.git] / src / store / collections / collection-create-actions.ts
index f4375688141cdc5eb3873321eaac01c22c895024..8d1e9ba5f247be426fc0b2faabb6d4ec60f858fb 100644 (file)
@@ -3,7 +3,7 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { Dispatch } from "redux";
-import { reset, startSubmit, stopSubmit, initialize } from 'redux-form';
+import { reset, startSubmit, stopSubmit, initialize, FormErrors } from 'redux-form';
 import { RootState } from '~/store/store';
 import { dialogActions } from "~/store/dialog/dialog-actions";
 import { ServiceRepository } from '~/services/services';
@@ -40,7 +40,7 @@ export const openCollectionCreateDialog = (ownerUuid: string) =>
 export const createCollection = (data: CollectionCreateFormDialogData) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         dispatch(startSubmit(COLLECTION_CREATE_FORM_NAME));
-        let newCollection: CollectionResource | null = null;
+        let newCollection: CollectionResource;
         try {
             dispatch(progressIndicatorActions.START_WORKING(COLLECTION_CREATE_FORM_NAME));
             newCollection = await services.collectionService.create(data);
@@ -52,7 +52,7 @@ export const createCollection = (data: CollectionCreateFormDialogData) =>
         } catch (e) {
             const error = getCommonResourceServiceError(e);
             if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
-                dispatch(stopSubmit(COLLECTION_CREATE_FORM_NAME, { name: 'Collection with the same name already exists.' }));
+                dispatch(stopSubmit(COLLECTION_CREATE_FORM_NAME, { name: 'Collection with the same name already exists.' } as FormErrors));
             } else if (error === CommonResourceServiceError.NONE) {
                 dispatch(stopSubmit(COLLECTION_CREATE_FORM_NAME));
                 dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_CREATE_FORM_NAME }));