import { Dispatch } from "redux";
import { reset, startSubmit, stopSubmit, initialize, FormErrors } from 'redux-form';
import { RootState } from '~/store/store';
+import { getUserUuid } from "~/common/getuser";
import { dialogActions } from "~/store/dialog/dialog-actions";
import { ServiceRepository } from '~/services/services';
import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
const router = getState();
const properties = getState().properties;
if (isItemNotInProject(properties) || !isProjectOrRunProcessRoute(router)) {
- const userUuid = getState().auth.user!.uuid;
+ const userUuid = getUserUuid(getState());
+ if (!userUuid) { return; }
dispatch(initialize(COLLECTION_CREATE_FORM_NAME, { userUuid }));
} else {
dispatch(initialize(COLLECTION_CREATE_FORM_NAME, { ownerUuid }));
return newCollection;
} catch (e) {
const error = getCommonResourceServiceError(e);
- if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
+ if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) {
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));