diff --git a/client/public/locales/en/translation.json b/client/public/locales/en/translation.json index 6d37a4925..cefc254cc 100644 --- a/client/public/locales/en/translation.json +++ b/client/public/locales/en/translation.json @@ -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", 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 9a62eb9df..5fabca265 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 @@ -198,7 +198,11 @@ export const AssessmentWizard: React.FC = ({ return section.questions.every((question) => !questionHasValue(question)); }); - return noAnswers; + const allQuestionsAnswered = sections.every((section) => + areAllQuestionsAnswered(section) + ); + + return noAnswers || allQuestionsAnswered; }; const shouldNextBtnBeEnabled = ( @@ -435,6 +439,13 @@ export const AssessmentWizard: React.FC = ({ } }; + const haveAnyQuestionBeenAnswered = () => { + const questions = values[QUESTIONS_KEY]; + return Object.values(questions).some( + (answer) => answer !== null && answer !== "" + ); + }; + const handleCancelAssessment = () => { if (assessment) { if (isArchetype) { @@ -562,7 +573,11 @@ export const AssessmentWizard: React.FC = ({ 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") + } /> )}