- if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
- dispatch(stopSubmit(COLLECTION_CREATE_FORM_NAME, { name: 'Collection with the same name already exists.' }));
+ if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) {
+ dispatch(stopSubmit(COLLECTION_CREATE_FORM_NAME, { name: 'Collection with the same name already exists.' } as FormErrors));
+ } else {
+ dispatch(stopSubmit(COLLECTION_CREATE_FORM_NAME));
+ dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_CREATE_FORM_NAME }));
+ const errMsg = e.errors
+ ? e.errors.join('')
+ : 'There was an error while creating the collection';
+ dispatch(snackbarActions.OPEN_SNACKBAR({
+ message: errMsg,
+ hideDuration: 2000,
+ kind: SnackbarKind.ERROR
+ }));
+ if (newCollection) { await services.collectionService.delete(newCollection.uuid); }