diff --git a/frontend/src/actions/projectActions.ts b/frontend/src/actions/projectActions.ts index 0dd82fea..b28d0526 100644 --- a/frontend/src/actions/projectActions.ts +++ b/frontend/src/actions/projectActions.ts @@ -30,10 +30,6 @@ export function saveProject(project: IProjectModel, navigate?: any, after: 'to-l if (after === 'to-list') { navigate('/projects'); } else { - // First navigate away? - // Workaround for EditProject not reloading the form - // when the url _id changes. Need a hook for this :) - navigate('/projects'); navigate(`/projects/${response.body._id}`); } } diff --git a/frontend/src/components/project/CopyProject.tsx b/frontend/src/components/project/CopyProject.tsx index 04c3a37e..64715e7b 100644 --- a/frontend/src/components/project/CopyProject.tsx +++ b/frontend/src/components/project/CopyProject.tsx @@ -9,7 +9,7 @@ import {Modal} from '../controls/Modal'; import {saveProject} from '../../actions/projectActions'; import {ArrayInput} from '../controls/form-controls/inputs/ArrayInput'; import {FullFormConfig} from '../../models'; -import { ContractStatus } from '../client/models/ContractModels'; +import {ContractStatus} from '../client/models/ContractModels'; type CopyProjectProps = { projectToCopy: IProjectModel; diff --git a/frontend/src/components/project/EditProject.tsx b/frontend/src/components/project/EditProject.tsx index e058a08f..f1ff1567 100644 --- a/frontend/src/components/project/EditProject.tsx +++ b/frontend/src/components/project/EditProject.tsx @@ -43,8 +43,7 @@ export const EditProject = () => { const docTitle = consultant._id ? 'projectEdit' : 'projectNew'; useDocumentTitle(docTitle, {consultant: consultant.firstName, client: client.name}); - - if (model && !project._id) { + if (model && (!project._id || project._id !== params.id)) { setProject(model); } @@ -131,7 +130,7 @@ export const EditProject = () => { dispatch(deleteProject(project._id, navigate) as any)} variant="danger" title={t('project.deleteConfirm.title')} @@ -140,7 +139,7 @@ export const EditProject = () => { > {t('project.deleteConfirm.content')} - {project.endDate && project._id && } + {project.endDate && project._id && } dispatch(saveProject(project, navigate) as any)} disabled={isButtonDisabled}> {t('save')}