Skip to content

Commit

Permalink
Wire discard back in
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 committed Sep 19, 2023
1 parent f7a12f1 commit 41a205f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,17 @@ export const AssessmentWizard: React.FC<AssessmentWizardProps> = ({

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()),
Expand Down Expand Up @@ -370,22 +374,41 @@ export const AssessmentWizard: React.FC<AssessmentWizardProps> = ({
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.",
Expand Down Expand Up @@ -448,6 +471,7 @@ export const AssessmentWizard: React.FC<AssessmentWizardProps> = ({

const wizardFooter = (
<CustomWizardFooter
isArchetype={isArchetype}
isFirstStep={currentStep === 0}
isLastStep={currentStep === sortedSections.length}
isDisabled={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface CustomWizardFooterProps {
isLastStep: boolean;
isDisabled: boolean;
isFormInvalid: boolean;
isArchetype?: boolean;
onSave: (review: boolean) => void;
onSaveAsDraft: () => void;
}
Expand All @@ -21,6 +22,7 @@ export const CustomWizardFooter: React.FC<CustomWizardFooterProps> = ({
isLastStep,
isDisabled,
isFormInvalid,
isArchetype,
onSave,
onSaveAsDraft,
}) => {
Expand All @@ -47,14 +49,16 @@ export const CustomWizardFooter: React.FC<CustomWizardFooterProps> = ({
>
{t("actions.save")}
</Button>
<Button
variant="primary"
onClick={() => onSave(true)}
isDisabled={!enableNext || isDisabled || isFormInvalid}
cy-data="save-and-review"
>
{t("actions.saveAndReview")}
</Button>
{!isArchetype && (
<Button
variant="primary"
onClick={() => onSave(true)}

Check warning on line 55 in client/src/app/pages/assessment/components/custom-wizard-footer/custom-wizard-footer.tsx

View check run for this annotation

Codecov / codecov/patch

client/src/app/pages/assessment/components/custom-wizard-footer/custom-wizard-footer.tsx#L55

Added line #L55 was not covered by tests
isDisabled={!enableNext || isDisabled || isFormInvalid}
cy-data="save-and-review"
>
{t("actions.saveAndReview")}
</Button>
)}
</>
) : (
<Button
Expand Down

0 comments on commit 41a205f

Please sign in to comment.