Skip to content

Commit 7b5d382

Browse files
committed
🐛 Update close messsage when no questions answered
1 parent fc62ad6 commit 7b5d382

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

client/public/locales/en/translation.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@
212212
"selectOwnerFromStakeholdersList": "Select owner from list of stakeholders",
213213
"suggestedAdoptionPlanHelpText": "The suggested approach to migration based on effort, priority, and dependencies.",
214214
"taskInProgressForTags": "A new analysis is in-progress. Tags may be updated upon completion.",
215-
"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."
215+
"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.",
216+
"unsavedChanges": "Are you sure you want to close the assessment? Any unsaved changes will be lost.",
217+
"noAnswers": "Are you sure you want to close the assessment? There are no answers to save."
216218
},
217219
"proposedActions": {
218220
"refactor": "Refactor",

client/src/app/pages/assessment/components/assessment-wizard/assessment-wizard.tsx

+17-2
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,11 @@ export const AssessmentWizard: React.FC<AssessmentWizardProps> = ({
198198
return section.questions.every((question) => !questionHasValue(question));
199199
});
200200

201-
return noAnswers;
201+
const allQuestionsAnswered = sections.every((section) =>
202+
areAllQuestionsAnswered(section)
203+
);
204+
205+
return noAnswers || allQuestionsAnswered;
202206
};
203207

204208
const shouldNextBtnBeEnabled = (
@@ -435,6 +439,13 @@ export const AssessmentWizard: React.FC<AssessmentWizardProps> = ({
435439
}
436440
};
437441

442+
const haveAnyQuestionBeenAnswered = () => {
443+
const questions = values[QUESTIONS_KEY];
444+
return Object.values(questions).some(
445+
(answer) => answer !== null && answer !== ""
446+
);
447+
};
448+
438449
const handleCancelAssessment = () => {
439450
if (assessment) {
440451
if (isArchetype) {
@@ -562,7 +573,11 @@ export const AssessmentWizard: React.FC<AssessmentWizardProps> = ({
562573
onCancel={() => setAssessmentToCancel(null)}
563574
onClose={() => setAssessmentToCancel(null)}
564575
onConfirm={() => handleCancelAssessment()}
565-
message="Are you sure you want to close the assessment? Any unsaved changes will be lost."
576+
message={
577+
haveAnyQuestionBeenAnswered()
578+
? t("message.unsavedChanges")
579+
: t("message.noAnswers")
580+
}
566581
/>
567582
)}
568583
</FormProvider>

0 commit comments

Comments
 (0)