diff --git a/services/common/src/components/forms/SteppedForm.tsx b/services/common/src/components/forms/SteppedForm.tsx index dc45a1ab75..c5fafdf565 100644 --- a/services/common/src/components/forms/SteppedForm.tsx +++ b/services/common/src/components/forms/SteppedForm.tsx @@ -12,7 +12,7 @@ interface SteppedFormProps extends Omit { children: Array>; handleTabChange: (newTab: string) => void | Promise; handleSaveDraft?: (formValues) => Promise; - handleSaveData?: (values, newActiveTab?: string) => Promise; + handleSaveData?: (values, newActiveTab?: string, currentTab?: string) => Promise; handleCancel?: () => void | Promise; transformPayload?: (values: any) => any; activeTab: string; @@ -108,7 +108,7 @@ const SteppedForm: FC = ({ setIsSubmitting(true); try { if (handleSaveData && (await saveCheck())) { - await handleSaveData(getValues(formValues), tab); + await handleSaveData(getValues(formValues), tab, `${tabs[tabIndex]}`); } if (errors.length > 0) return; setTabIndex(indexOf(tabs, tab)); diff --git a/services/common/src/components/projectSummary/ProjectSummaryForm.tsx b/services/common/src/components/projectSummary/ProjectSummaryForm.tsx index 923f6d36fa..c37628929b 100644 --- a/services/common/src/components/projectSummary/ProjectSummaryForm.tsx +++ b/services/common/src/components/projectSummary/ProjectSummaryForm.tsx @@ -29,7 +29,7 @@ import { areAuthFieldsDisabled, areDocumentFieldsDisabled, areFieldsDisabled, is interface ProjectSummaryFormProps { initialValues: IProjectSummary; handleTabChange: (newTab: string) => void; - handleSaveData: (formValues, newActiveTab?) => Promise; + handleSaveData: (formValues, newActiveTab?, currentTab?) => Promise; activeTab: string; isEditMode?: boolean; } diff --git a/services/minespace-web/src/components/pages/Project/ProjectSummaryPage.tsx b/services/minespace-web/src/components/pages/Project/ProjectSummaryPage.tsx index d1a79fc5d8..1c16b74ed9 100644 --- a/services/minespace-web/src/components/pages/Project/ProjectSummaryPage.tsx +++ b/services/minespace-web/src/components/pages/Project/ProjectSummaryPage.tsx @@ -183,14 +183,20 @@ export const ProjectSummaryPage = () => { history.push(url); }; - const handleSaveData = async (formValues, newActiveTab?: string) => { + const handleSaveData = async (formValues, newActiveTab?: string, currentTab?: string) => { let message = newActiveTab ? "Successfully updated the project description." : "Successfully submitted a project description to the Province of British Columbia."; let status_code = projectSummary.status_code; let is_historic = projectSummary.is_historic; - if (status_code === "CHR" && formValues.confirmation_of_submission) { + if ( + status_code === "CHR" && + formValues.confirmation_of_submission && + currentTab === "declaration" + ) { + // If a proponent re-submits the declaration, when changes are made to the project description, + // change it back to under review. status_code = "UNR"; } else if ((!status_code || !isEditMode) && status_code !== "UNR") { status_code = "DFT";