From 41a205f62ab87bbb39ff9b5906effee59321f2b2 Mon Sep 17 00:00:00 2001 From: ibolton336 Date: Tue, 19 Sep 2023 10:24:49 -0400 Subject: [PATCH] Wire discard back in --- .../applications-table-assessment.tsx | 9 +++ .../assessment-wizard/assessment-wizard.tsx | 60 +++++++++++++------ .../custom-wizard-footer.tsx | 20 ++++--- 3 files changed, 63 insertions(+), 26 deletions(-) diff --git a/client/src/app/pages/applications/applications-table-assessment/applications-table-assessment.tsx b/client/src/app/pages/applications/applications-table-assessment/applications-table-assessment.tsx index ea74048810..09c3dedb33 100644 --- a/client/src/app/pages/applications/applications-table-assessment/applications-table-assessment.tsx +++ b/client/src/app/pages/applications/applications-table-assessment/applications-table-assessment.tsx @@ -669,6 +669,15 @@ export const ApplicationsTable: React.FC = () => { title: t("actions.review"), onClick: () => reviewSelectedApp(application), }, + ...(application?.review + ? [ + { + title: t("actions.discardAssessment"), + onClick: () => + setAssessmentOrReviewToDiscard(application), + }, + ] + : []), { title: t("actions.delete"), onClick: () => diff --git a/client/src/app/pages/assessment/components/assessment-wizard/assessment-wizard.tsx b/client/src/app/pages/assessment/components/assessment-wizard/assessment-wizard.tsx index 646b871fe9..2c9c2a8589 100644 --- a/client/src/app/pages/assessment/components/assessment-wizard/assessment-wizard.tsx +++ b/client/src/app/pages/assessment/components/assessment-wizard/assessment-wizard.tsx @@ -125,13 +125,17 @@ export const AssessmentWizard: React.FC = ({ useEffect(() => { methods.reset({ - // stakeholders: assessment?.stakeholders || [], - // stakeholderGroups: assessment?.stakeholderGroups || [], + stakeholders: + assessment?.stakeholders.map((stakeholder) => stakeholder.name) || [], + stakeholderGroups: + assessment?.stakeholderGroups.map( + (stakeholderGroup) => stakeholderGroup.name + ) || [], // comments: initialComments, questions: initialQuestions, [SAVE_ACTION_KEY]: SAVE_ACTION_VALUE.SAVE_AS_DRAFT, }); - }, [initialQuestions]); + }, [initialQuestions, assessment]); const validationSchema = yup.object().shape({ stakeholders: yup.array().of(yup.string()), @@ -370,22 +374,41 @@ export const AssessmentWizard: React.FC = ({ title: "Assessment has been saved.", variant: "success", }); - - assessment?.application?.id && - getApplicationById(assessment.application.id) - .then((data) => { - history.push( - formatPath(Paths.applicationsReview, { - applicationId: data.id, - }) - ); - }) - .catch((error) => { - pushNotification({ - title: getAxiosErrorMessage(error), - variant: "danger", + if (isArchetype) { + //TODO: Review Archetype? + // assessment?.archetype?.id && + // getArchetypeById(assessment.archetype.id) + // .then((data) => { + // history.push( + // formatPath(Paths.a, { + // applicationId: data.id, + // }) + // ); + // }) + // .catch((error) => { + // pushNotification({ + // title: getAxiosErrorMessage(error), + // variant: "danger", + // }); + // }); + // } + } else { + assessment?.application?.id && + getApplicationById(assessment.application.id) + .then((data) => { + history.push( + formatPath(Paths.applicationsReview, { + applicationId: data.id, + }) + ); + }) + .catch((error) => { + pushNotification({ + title: getAxiosErrorMessage(error), + variant: "danger", + }); }); - }); + } } catch (error) { pushNotification({ title: "Failed to save.", @@ -448,6 +471,7 @@ export const AssessmentWizard: React.FC = ({ const wizardFooter = ( void; onSaveAsDraft: () => void; } @@ -21,6 +22,7 @@ export const CustomWizardFooter: React.FC = ({ isLastStep, isDisabled, isFormInvalid, + isArchetype, onSave, onSaveAsDraft, }) => { @@ -47,14 +49,16 @@ export const CustomWizardFooter: React.FC = ({ > {t("actions.save")} - + {!isArchetype && ( + + )} ) : (