Skip to content

Commit

Permalink
🐛 Update close messsage when no questions answered
Browse files Browse the repository at this point in the history
Signed-off-by: ibolton336 <[email protected]>
  • Loading branch information
ibolton336 committed Dec 19, 2023
1 parent fc62ad6 commit e2bf9fc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 3 additions & 1 deletion client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@
"selectOwnerFromStakeholdersList": "Select owner from list of stakeholders",
"suggestedAdoptionPlanHelpText": "The suggested approach to migration based on effort, priority, and dependencies.",
"taskInProgressForTags": "A new analysis is in-progress. Tags may be updated upon completion.",
"toTagApplication": "Either no tags exist yet or you may not have permission to view any. If you have permission, try creating a new custom tag."
"toTagApplication": "Either no tags exist yet or you may not have permission to view any. If you have permission, try creating a new custom tag.",
"unsavedChanges": "Are you sure you want to close the assessment? Any unsaved changes will be lost.",
"noAnswers": "Are you sure you want to close the assessment? There are no answers to save."
},
"proposedActions": {
"refactor": "Refactor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ export const AssessmentWizard: React.FC<AssessmentWizardProps> = ({
return section.questions.every((question) => !questionHasValue(question));
});

return noAnswers;
const allQuestionsAnswered = sections.every((section) =>
areAllQuestionsAnswered(section)
);

return noAnswers || allQuestionsAnswered;
};

const shouldNextBtnBeEnabled = (
Expand Down Expand Up @@ -435,6 +439,13 @@ export const AssessmentWizard: React.FC<AssessmentWizardProps> = ({
}
};

const haveAnyQuestionBeenAnswered = () => {
const questions = values[QUESTIONS_KEY];
return Object.values(questions).some(
(answer) => answer !== null && answer !== ""
);
};

const handleCancelAssessment = () => {
if (assessment) {
if (isArchetype) {
Expand Down Expand Up @@ -562,7 +573,11 @@ export const AssessmentWizard: React.FC<AssessmentWizardProps> = ({
onCancel={() => setAssessmentToCancel(null)}
onClose={() => setAssessmentToCancel(null)}
onConfirm={() => handleCancelAssessment()}
message="Are you sure you want to close the assessment? Any unsaved changes will be lost."
message={
haveAnyQuestionBeenAnswered()
? t("message.unsavedChanges")
: t("message.noAnswers")
}
/>
)}
</FormProvider>
Expand Down

0 comments on commit e2bf9fc

Please sign in to comment.