Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Update close messsage when no questions answered #1641

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading