diff --git a/frontend/src/component/project/Project/CreateProject/CreateProject.tsx b/frontend/src/component/project/Project/CreateProject/CreateProject.tsx index fea67f914c..c22425b5ad 100644 --- a/frontend/src/component/project/Project/CreateProject/CreateProject.tsx +++ b/frontend/src/component/project/Project/CreateProject/CreateProject.tsx @@ -26,7 +26,6 @@ const CreateProject = () => { clearErrors, validateIdUniqueness, validateName, - validateProjectId, errors, } = useProjectForm(); @@ -36,10 +35,9 @@ const CreateProject = () => { e.preventDefault(); clearErrors(); const validName = validateName(); - const validProjectId = validateProjectId(); const validId = await validateIdUniqueness(); - if (validName && validId && validProjectId) { + if (validName && validId) { const payload = getProjectPayload(); try { await createProject(payload); @@ -67,7 +65,7 @@ const CreateProject = () => { }; const handleCancel = () => { - history.push('/projects'); + history.goBack(); }; return ( @@ -92,10 +90,7 @@ const CreateProject = () => { clearErrors={clearErrors} validateIdUniqueness={validateIdUniqueness} > - + Create project diff --git a/frontend/src/component/project/Project/hooks/useProjectForm.ts b/frontend/src/component/project/Project/hooks/useProjectForm.ts index 4ea6dc89a7..fed4269dec 100644 --- a/frontend/src/component/project/Project/hooks/useProjectForm.ts +++ b/frontend/src/component/project/Project/hooks/useProjectForm.ts @@ -39,6 +39,10 @@ const useProjectForm = ( const NAME_EXISTS_ERROR = 'Error: A project with this id already exists.'; const validateIdUniqueness = async () => { + if (projectId.length === 0) { + setErrors(prev => ({ ...prev, id: 'Id can not be empty.' })); + return false; + } try { await validateId(getProjectPayload()); return true; @@ -65,7 +69,7 @@ const useProjectForm = ( setErrors(prev => ({ ...prev, name: 'Name can not be empty.' })); return false; } - + return true; }; diff --git a/frontend/src/component/tagTypes/CreateTagType/CreateTagType.tsx b/frontend/src/component/tagTypes/CreateTagType/CreateTagType.tsx index 0b466729d9..75f589eaab 100644 --- a/frontend/src/component/tagTypes/CreateTagType/CreateTagType.tsx +++ b/frontend/src/component/tagTypes/CreateTagType/CreateTagType.tsx @@ -75,11 +75,9 @@ const CreateTagType = () => { setTagDesc={setTagDesc} mode="Create" clearErrors={clearErrors} + validateNameUniqueness={validateNameUniqueness} > - + Create type diff --git a/frontend/src/component/tagTypes/TagTypeForm/TagTypeForm.tsx b/frontend/src/component/tagTypes/TagTypeForm/TagTypeForm.tsx index 5eb02796bd..9c7ae6ed9a 100644 --- a/frontend/src/component/tagTypes/TagTypeForm/TagTypeForm.tsx +++ b/frontend/src/component/tagTypes/TagTypeForm/TagTypeForm.tsx @@ -16,6 +16,7 @@ interface ITagTypeForm { errors: { [key: string]: string }; mode: string; clearErrors: () => void; + validateNameUniqueness?: () => void; } const TagTypeForm: React.FC = ({ @@ -28,6 +29,7 @@ const TagTypeForm: React.FC = ({ setTagDesc, errors, mode, + validateNameUniqueness, clearErrors, }) => { const styles = useStyles(); @@ -49,11 +51,10 @@ const TagTypeForm: React.FC = ({ errorText={errors.name} onFocus={() => clearErrors()} disabled={mode === EDIT} + onBlur={validateNameUniqueness} /> -

- What is this role for? -

+

What is this tag for?