diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 2f60e876c..7fe55aa95 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -175,9 +175,17 @@ "(Quarter)": "(Quarter)", "(Sent by {{firstName}} {{lastName}})": "(Sent by {{firstName}} {{lastName}})", "(Year)": "(Year)", + "Before You Start": "Before You Start", + "Complete this form by": "Complete this form by", "Dismiss": "Dismiss", + "Email the MPD Team.": "Email the MPD Team.", + "Questions or need a change?": "Questions or need a change?", "Review your goal, see how to present it to partners, and read your next steps. We also emailed you the full worksheet as a PDF.": "Review your goal, see how to present it to partners, and read your next steps. We also emailed you the full worksheet as a PDF.", + "Starting on {{date}}": "Starting on {{date}}", "View my MPD goal": "View my MPD goal", + "What is {{spouseName}}'s current annual requested MHA?": "What is {{spouseName}}'s current annual requested MHA?", + "You'll receive your support goal at {{trainingName}} that begins on {{date}}.": "You'll receive your support goal at {{trainingName}} that begins on {{date}}.", + "You'll receive your support goal at {{trainingName}}.": "You'll receive your support goal at {{trainingName}}.", "Your goal changed since you last looked. Review the updated worksheet, which was also emailed to you as a PDF.": "Your goal changed since you last looked. Review the updated worksheet, which was also emailed to you as a PDF.", "Your MPD goal is ready": "Your MPD goal is ready", "Your MPD goal was already sent, so this questionnaire can't change.": "Your MPD goal was already sent, so this questionnaire can't change.", @@ -1234,7 +1242,6 @@ "Drag here to create columns": "Drag here to create columns", "Drag here to create rows": "Drag here to create rows", "Drag here to create values": "Drag here to create values", - "Due {{date}}. After that you can't change or submit it.": "Due {{date}}. After that you can't change or submit it.", "Due Date": "Due Date", "Due Time": "Due Time", "e.g., Home visits, Conference travel": "e.g., Home visits, Conference travel", @@ -3191,7 +3198,7 @@ "Spouse's Last Name": "Spouse's Last Name", "Spouse's Personal Information": "Spouse's Personal Information", "Spouse's requested annual salary": "Spouse's requested annual salary", - "Spouse's requested MHA": "Spouse's requested MHA", + "Spouse's annual requested MHA": "Spouse's annual requested MHA", "Sri Lanka": "Sri Lanka", "Staff": "Staff", "Staff - non-RMO Spouse": "Staff - non-RMO Spouse", @@ -3844,7 +3851,6 @@ "What expenses can I claim on my MHA?": "What expenses can I claim on my MHA?", "What is {{spouseName}}'s 403(b) contribution percentage?": "What is {{spouseName}}'s 403(b) contribution percentage?", "What is {{spouseName}}'s current requested annual salary?": "What is {{spouseName}}'s current requested annual salary?", - "What is {{spouseName}}'s current requested MHA?": "What is {{spouseName}}'s current requested MHA?", "What is HCM?": "What is HCM?", "What is your monthly payment for all of your {{debtType}}?": "What is your monthly payment for all of your {{debtType}}?", "What ministry are you expecting to serve with?": "What ministry are you expecting to serve with?", diff --git a/src/components/HrTools/NsoMpdQuestionnaire/FinancialInformation/VariantQuestions.test.tsx b/src/components/HrTools/NsoMpdQuestionnaire/FinancialInformation/VariantQuestions.test.tsx index f9be98fd3..255fe26da 100644 --- a/src/components/HrTools/NsoMpdQuestionnaire/FinancialInformation/VariantQuestions.test.tsx +++ b/src/components/HrTools/NsoMpdQuestionnaire/FinancialInformation/VariantQuestions.test.tsx @@ -95,7 +95,7 @@ describe('VariantQuestions', () => { ).toBeInTheDocument(); expect( getByRole('spinbutton', { - name: "What is Jane's current requested MHA?", + name: "What is Jane's current annual requested MHA?", }), ).toBeInTheDocument(); expect( diff --git a/src/components/HrTools/NsoMpdQuestionnaire/FinancialInformation/VariantQuestions.tsx b/src/components/HrTools/NsoMpdQuestionnaire/FinancialInformation/VariantQuestions.tsx index 95d70af86..6f0d1aa5f 100644 --- a/src/components/HrTools/NsoMpdQuestionnaire/FinancialInformation/VariantQuestions.tsx +++ b/src/components/HrTools/NsoMpdQuestionnaire/FinancialInformation/VariantQuestions.tsx @@ -84,9 +84,12 @@ export const VariantQuestions: React.FC = () => { } /> diff --git a/src/components/HrTools/NsoMpdQuestionnaire/NsoMpdQuestionnaireTestWrapper.tsx b/src/components/HrTools/NsoMpdQuestionnaire/NsoMpdQuestionnaireTestWrapper.tsx index f3a0a73fe..b7a0c1ca1 100644 --- a/src/components/HrTools/NsoMpdQuestionnaire/NsoMpdQuestionnaireTestWrapper.tsx +++ b/src/components/HrTools/NsoMpdQuestionnaire/NsoMpdQuestionnaireTestWrapper.tsx @@ -26,6 +26,8 @@ export const newStaffQuestionnaireMock: DeepPartial< completedAt: null, deadline: null, locked: false, + trainingName: null, + trainingStartDate: null, viewerIsStaffMember: null, personNumber: '000123456', firstName: 'John', diff --git a/src/components/HrTools/NsoMpdQuestionnaire/PersonalInformation/Settings.test.tsx b/src/components/HrTools/NsoMpdQuestionnaire/PersonalInformation/Settings.test.tsx index dff1882b1..ab9d07062 100644 --- a/src/components/HrTools/NsoMpdQuestionnaire/PersonalInformation/Settings.test.tsx +++ b/src/components/HrTools/NsoMpdQuestionnaire/PersonalInformation/Settings.test.tsx @@ -1,16 +1,26 @@ import React from 'react'; -import { ThemeProvider } from '@mui/material/styles'; -import { render } from '@testing-library/react'; -import theme from 'src/theme'; +import { render } from '__tests__/util/testingLibraryReactMock'; +import { NsoMpdQuestionnaireTestWrapper } from '../NsoMpdQuestionnaireTestWrapper'; import { Settings } from './Settings'; const TestComponent: React.FC = () => ( - + - + ); describe('Settings', () => { + it('opens with Before You Start and the due date', async () => { + const { findByText, getByRole } = render(); + + expect( + getByRole('heading', { name: 'Before You Start' }), + ).toBeInTheDocument(); + expect(await findByText('Complete this form by')).toBeInTheDocument(); + }); + it('renders the informational title and description', () => { const { getByText } = render(); diff --git a/src/components/HrTools/NsoMpdQuestionnaire/PersonalInformation/Settings.tsx b/src/components/HrTools/NsoMpdQuestionnaire/PersonalInformation/Settings.tsx index 6199e3273..02976dccb 100644 --- a/src/components/HrTools/NsoMpdQuestionnaire/PersonalInformation/Settings.tsx +++ b/src/components/HrTools/NsoMpdQuestionnaire/PersonalInformation/Settings.tsx @@ -1,17 +1,19 @@ import React from 'react'; import { Alert, AlertTitle, Stack, Typography } from '@mui/material'; import { Trans, useTranslation } from 'react-i18next'; +import { TrainingDates } from './TrainingDates'; /** - * Informational subsection of the Personal Information step. Display-only guidance for the user - * before they answer — not a sidebar sub-step. + * Informational subsection of the Personal Information step: the training and due dates, then + * display-only guidance for the user before they answer — not a sidebar sub-step. */ export const Settings: React.FC = () => { const { t } = useTranslation(); return ( - {t('Settings')} + {t('Before You Start')} + {t('Please read all information before answering.')} diff --git a/src/components/HrTools/NsoMpdQuestionnaire/PersonalInformation/TrainingDates.test.tsx b/src/components/HrTools/NsoMpdQuestionnaire/PersonalInformation/TrainingDates.test.tsx new file mode 100644 index 000000000..deb7b6bb9 --- /dev/null +++ b/src/components/HrTools/NsoMpdQuestionnaire/PersonalInformation/TrainingDates.test.tsx @@ -0,0 +1,79 @@ +import { render } from '__tests__/util/testingLibraryReactMock'; +import { NsoMpdQuestionnaireTestWrapper } from '../NsoMpdQuestionnaireTestWrapper'; +import { useNsoMpdQuestionnaire } from '../Shared/NsoMpdQuestionnaireContext'; +import { TrainingDates } from './TrainingDates'; + +/** Shows once the questionnaire query has answered. */ +const LoadedProbe: React.FC = () => { + const { questionnaire } = useNsoMpdQuestionnaire(); + return questionnaire ? loaded : null; +}; + +const deadline = '2027-01-20T22:00:00Z'; + +const renderDates = ( + questionnaire: Partial<{ + trainingName: string | null; + trainingStartDate: string | null; + deadline: string | null; + locked: boolean; + completed: boolean; + }>, +) => + render( + + + + , + ); + +describe('TrainingDates', () => { + it('shows the training and when it starts', async () => { + const { findByText, getByText } = renderDates({ + trainingName: 'Winter NSO 2027', + trainingStartDate: '2027-01-05', + }); + + expect(await findByText('Winter NSO 2027')).toBeInTheDocument(); + expect(getByText('Starting on Jan 5, 2027')).toBeInTheDocument(); + }); + + it('leaves out the start date when there is no training name', async () => { + const { findByText, queryByText } = renderDates({ + trainingName: null, + trainingStartDate: '2027-01-05', + }); + await findByText('loaded'); + + expect(queryByText(/Starting on/)).not.toBeInTheDocument(); + }); + + it('leaves out the training when it has no start date', async () => { + const { findByText, queryByText } = renderDates({ + trainingName: 'Winter NSO 2027', + trainingStartDate: null, + }); + await findByText('loaded'); + + expect(queryByText('Winter NSO 2027')).not.toBeInTheDocument(); + expect(queryByText(/Starting on/)).not.toBeInTheDocument(); + }); + + it('shows when the form is due, in Eastern time', async () => { + const { findByText, getByText } = renderDates({ deadline }); + + expect(await findByText('Complete this form by')).toBeInTheDocument(); + expect(getByText('Jan 20, 2027, 5:00 PM EST')).toBeInTheDocument(); + }); + + it.each([ + ['there is no deadline', { deadline: null }], + ['it is locked', { deadline, locked: true }], + ['it was submitted', { deadline, completed: true }], + ])('leaves out the due date when %s', async (_, questionnaire) => { + const { findByText, queryByText } = renderDates(questionnaire); + await findByText('loaded'); + + expect(queryByText('Complete this form by')).not.toBeInTheDocument(); + }); +}); diff --git a/src/components/HrTools/NsoMpdQuestionnaire/PersonalInformation/TrainingDates.tsx b/src/components/HrTools/NsoMpdQuestionnaire/PersonalInformation/TrainingDates.tsx new file mode 100644 index 000000000..acd9ecb13 --- /dev/null +++ b/src/components/HrTools/NsoMpdQuestionnaire/PersonalInformation/TrainingDates.tsx @@ -0,0 +1,79 @@ +import React from 'react'; +import AccessTime from '@mui/icons-material/AccessTime'; +import CalendarTodayOutlined from '@mui/icons-material/CalendarTodayOutlined'; +import { Box, Stack, Typography } from '@mui/material'; +import { DateTime } from 'luxon'; +import { useTranslation } from 'react-i18next'; +import { useLocale } from 'src/hooks/useLocale'; +import { dateFormat } from 'src/lib/intlFormat'; +import { deadlineFormat } from '../../Shared/questionnaireDeadline'; +import { useNsoMpdQuestionnaire } from '../Shared/NsoMpdQuestionnaireContext'; + +const DateBox: React.FC<{ + icon: React.ReactNode; + label: string; + value: string; +}> = ({ icon, label, value }) => ( + + {icon} + + + {label} + + + {value} + + + +); + +/** The household's training start and the form's due date, shown once at the top of Step 1. */ +export const TrainingDates: React.FC = () => { + const { t } = useTranslation(); + const locale = useLocale(); + const { questionnaire } = useNsoMpdQuestionnaire(); + + if (!questionnaire) { + return null; + } + + const { trainingName, trainingStartDate, deadline, locked, completed } = + questionnaire; + const showTraining = !!trainingName && !!trainingStartDate; + // A locked form explains itself on every step (DeadlineNotice); a submitted one has no due date + const showDue = !!deadline && !locked && !completed; + if (!showTraining && !showDue) { + return null; + } + + return ( + + {showTraining && ( + } + label={trainingName} + value={t('Starting on {{date}}', { + date: dateFormat(DateTime.fromISO(trainingStartDate), locale), + })} + /> + )} + {showDue && ( + } + label={t('Complete this form by')} + value={deadlineFormat(deadline, locale)} + /> + )} + + ); +}; diff --git a/src/components/HrTools/NsoMpdQuestionnaire/Shared/DeadlineNotice.test.tsx b/src/components/HrTools/NsoMpdQuestionnaire/Shared/DeadlineNotice.test.tsx index 1deeccd0e..22ee40e37 100644 --- a/src/components/HrTools/NsoMpdQuestionnaire/Shared/DeadlineNotice.test.tsx +++ b/src/components/HrTools/NsoMpdQuestionnaire/Shared/DeadlineNotice.test.tsx @@ -26,14 +26,11 @@ const renderNotice = ( ); describe('DeadlineNotice', () => { - it('shows when the questionnaire is due, in Eastern time', async () => { - const { findByText } = renderNotice({ deadline }); + it('leaves an open deadline to Step 1', async () => { + const { findByText, queryByText } = renderNotice({ deadline }); + await findByText('loaded'); - expect( - await findByText( - "Due Jan 20, 2027, 5:00 PM EST. After that you can't change or submit it.", - ), - ).toBeInTheDocument(); + expect(queryByText(/deadline|Due/)).not.toBeInTheDocument(); }); it('says the deadline passed and who can reopen it', async () => { diff --git a/src/components/HrTools/NsoMpdQuestionnaire/Shared/DeadlineNotice.tsx b/src/components/HrTools/NsoMpdQuestionnaire/Shared/DeadlineNotice.tsx index b5bf0bcc2..efe0d6207 100644 --- a/src/components/HrTools/NsoMpdQuestionnaire/Shared/DeadlineNotice.tsx +++ b/src/components/HrTools/NsoMpdQuestionnaire/Shared/DeadlineNotice.tsx @@ -6,23 +6,29 @@ import { useLocale } from 'src/hooks/useLocale'; import { deadlineFormat } from '../../Shared/questionnaireDeadline'; import { useNsoMpdQuestionnaire } from './NsoMpdQuestionnaireContext'; -/** The household's deadline on every step: when it is due, or that it passed and who can reopen it. */ +/** + * Why the questionnaire is locked, on every step: its goal was sent, or the deadline passed and who + * can reopen it. An open deadline shows once, on Step 1 (TrainingDates). + */ export const DeadlineNotice: React.FC = () => { const { t } = useTranslation(); const locale = useLocale(); const { questionnaire } = useNsoMpdQuestionnaire(); - if (!questionnaire || questionnaire.completed) { + if (!questionnaire?.locked) { + return null; + } + if (questionnaire.completed) { return null; } - const { deadline, locked } = questionnaire; + const { deadline } = questionnaire; const date = deadline ? deadlineFormat(deadline, locale) : ''; const pastDeadline = !!deadline && DateTime.fromISO(deadline) < DateTime.now(); // The API also locks a household whose goal was already sent, deadline or not - if (locked && !pastDeadline) { + if (!pastDeadline) { return ( {t( @@ -31,24 +37,12 @@ export const DeadlineNotice: React.FC = () => { ); } - if (locked) { - return ( - - {t( - 'The deadline for this questionnaire passed on {{date}}. To change or submit it, ask the MPD team at mpdhelp@cru.org to reopen it.', - { date }, - )} - - ); - } - if (!deadline) { - return null; - } return ( - - {t("Due {{date}}. After that you can't change or submit it.", { - date, - })} + + {t( + 'The deadline for this questionnaire passed on {{date}}. To change or submit it, ask the MPD team at mpdhelp@cru.org to reopen it.', + { date }, + )} ); }; diff --git a/src/components/HrTools/NsoMpdQuestionnaire/Shared/NewStaffQuestionnaire.graphql b/src/components/HrTools/NsoMpdQuestionnaire/Shared/NewStaffQuestionnaire.graphql index 8c816294c..960ed9502 100644 --- a/src/components/HrTools/NsoMpdQuestionnaire/Shared/NewStaffQuestionnaire.graphql +++ b/src/components/HrTools/NsoMpdQuestionnaire/Shared/NewStaffQuestionnaire.graphql @@ -22,6 +22,8 @@ fragment NewStaffQuestionnaireFields on NewStaffQuestionnaire { completedAt deadline locked + trainingName + trainingStartDate viewerIsStaffMember accountTransfers assignmentType diff --git a/src/components/HrTools/NsoMpdQuestionnaire/Shared/NsoMpdQuestionnaireLayout.test.tsx b/src/components/HrTools/NsoMpdQuestionnaire/Shared/NsoMpdQuestionnaireLayout.test.tsx index 8bfe2b1a2..a1dc452e0 100644 --- a/src/components/HrTools/NsoMpdQuestionnaire/Shared/NsoMpdQuestionnaireLayout.test.tsx +++ b/src/components/HrTools/NsoMpdQuestionnaire/Shared/NsoMpdQuestionnaireLayout.test.tsx @@ -92,6 +92,14 @@ describe('NsoMpdQuestionnaireLayout', () => { expect(getByText('Main panel content')).toBeInTheDocument(); }); + it('keeps the form about 600px wide (MUI sm) inside its margins', () => { + const { getByTestId } = render(); + + expect(getByTestId('NsoMpdQuestionnaireContent')).toHaveStyle({ + maxWidth: 'calc(600px + 64px)', + }); + }); + it('enables every step icon in the rail', () => { const { getByRole } = render(); diff --git a/src/components/HrTools/NsoMpdQuestionnaire/Shared/NsoMpdQuestionnaireLayout.tsx b/src/components/HrTools/NsoMpdQuestionnaire/Shared/NsoMpdQuestionnaireLayout.tsx index 54dd41767..b08bc054e 100644 --- a/src/components/HrTools/NsoMpdQuestionnaire/Shared/NsoMpdQuestionnaireLayout.tsx +++ b/src/components/HrTools/NsoMpdQuestionnaire/Shared/NsoMpdQuestionnaireLayout.tsx @@ -19,8 +19,8 @@ interface NsoMpdQuestionnaireLayoutProps { * Layout shared by all NSO MPD Questionnaire pages. The icon rail holds a completion progress ring * and one navigable icon per view step, so users can jump directly to any step; the content has Back * and Continue buttons below it on every step except the last (Summary), which supplies its own Back - * button and, unless the questionnaire is read-only, a Submit button. Each step has a single section, - * so there is no sub-step sidebar. + * and Submit buttons until the questionnaire is submitted. Each step has a single section, so there + * is no sub-step sidebar. */ export const NsoMpdQuestionnaireLayout: React.FC< NsoMpdQuestionnaireLayoutProps @@ -58,7 +58,13 @@ export const NsoMpdQuestionnaireLayout: React.FC< backHref={`/accountLists/${accountListId}`} hideSidebar mainContent={ - + ({ + maxWidth: `calc(${theme.breakpoints.values.sm}px + ${theme.spacing(8)})`, + })} + > {children} {!isLastStep && ( diff --git a/src/components/HrTools/NsoMpdQuestionnaire/Summary/SubmittedNotice.tsx b/src/components/HrTools/NsoMpdQuestionnaire/Summary/SubmittedNotice.tsx new file mode 100644 index 000000000..967483c78 --- /dev/null +++ b/src/components/HrTools/NsoMpdQuestionnaire/Summary/SubmittedNotice.tsx @@ -0,0 +1,54 @@ +import React from 'react'; +import { Alert, AlertTitle, Link, Typography } from '@mui/material'; +import { DateTime } from 'luxon'; +import { useTranslation } from 'react-i18next'; +import { useLocale } from 'src/hooks/useLocale'; +import { dateFormat, dateFormatShort } from 'src/lib/intlFormat'; +import { useNsoMpdQuestionnaire } from '../Shared/NsoMpdQuestionnaireContext'; + +const MPD_TEAM_EMAIL = 'mpdhelp@cru.org'; + +/** The Summary's notice once the questionnaire is submitted: when, where the goal comes, and whom to ask. */ +export const SubmittedNotice: React.FC = () => { + const { t } = useTranslation(); + const locale = useLocale(); + const { questionnaire } = useNsoMpdQuestionnaire(); + + const completedAt = questionnaire?.completedAt; + const submittedAt = completedAt ? DateTime.fromISO(completedAt) : null; + const trainingName = questionnaire?.trainingName; + const startDate = questionnaire?.trainingStartDate; + + return ( + + + {submittedAt?.isValid + ? t('Submitted on {{date}}', { + date: dateFormatShort(submittedAt, locale), + }) + : t('This questionnaire has been submitted.')} + + {trainingName && ( + + {startDate + ? t( + "You'll receive your support goal at {{trainingName}} that begins on {{date}}.", + { + trainingName, + date: dateFormat(DateTime.fromISO(startDate), locale), + }, + ) + : t("You'll receive your support goal at {{trainingName}}.", { + trainingName, + })} + + )} + + {t('Questions or need a change?')}{' '} + + {t('Email the MPD Team.')} + + + + ); +}; diff --git a/src/components/HrTools/NsoMpdQuestionnaire/Summary/Summary.test.tsx b/src/components/HrTools/NsoMpdQuestionnaire/Summary/Summary.test.tsx index 1c447f00e..bca2d0af1 100644 --- a/src/components/HrTools/NsoMpdQuestionnaire/Summary/Summary.test.tsx +++ b/src/components/HrTools/NsoMpdQuestionnaire/Summary/Summary.test.tsx @@ -54,7 +54,7 @@ describe('Summary', () => { />, ); expect( - await findByRole('rowheader', { name: "Spouse's requested MHA" }), + await findByRole('rowheader', { name: "Spouse's annual requested MHA" }), ).toBeInTheDocument(); }); diff --git a/src/components/HrTools/NsoMpdQuestionnaire/Summary/Summary.tsx b/src/components/HrTools/NsoMpdQuestionnaire/Summary/Summary.tsx index 716dbe01c..6c6e2ac74 100644 --- a/src/components/HrTools/NsoMpdQuestionnaire/Summary/Summary.tsx +++ b/src/components/HrTools/NsoMpdQuestionnaire/Summary/Summary.tsx @@ -1,45 +1,32 @@ import { useRouter } from 'next/router'; import React, { useState } from 'react'; import { Alert, Box, Divider, Link, Stack, Typography } from '@mui/material'; -import { DateTime } from 'luxon'; import { useSnackbar } from 'notistack'; import { useTranslation } from 'react-i18next'; import { Confirmation } from 'src/components/Shared/Modal/Confirmation/Confirmation'; import { useAccountListId } from 'src/hooks/useAccountListId'; import { useApplyGoalAndLocation } from 'src/hooks/useApplyGoalAndLocation'; -import { useLocale } from 'src/hooks/useLocale'; -import { dateFormatShort } from 'src/lib/intlFormat'; import { BackButton } from '../Shared/BackButton'; import { useNsoMpdQuestionnaire } from '../Shared/NsoMpdQuestionnaireContext'; import { NsoMpdQuestionnaireLayout } from '../Shared/NsoMpdQuestionnaireLayout'; import { QuestionnaireActionButton } from '../Shared/QuestionnaireActionButton'; import { getIncompleteSteps } from '../Shared/stepCompletion'; +import { SubmittedNotice } from './SubmittedNotice'; import { SummarySection } from './SummarySection'; -import { useSummarySections } from './useSummarySections'; +import { SummarySectionData, useSummarySections } from './useSummarySections'; const SummaryIntro: React.FC<{ readOnly: boolean; completed: boolean; - completedAt: string | null | undefined; -}> = ({ readOnly, completed, completedAt }) => { +}> = ({ readOnly, completed }) => { const { t } = useTranslation(); - const locale = useLocale(); // Locked by the deadline before submitting: the layout's deadline notice says so if (readOnly && !completed) { return null; } if (readOnly) { - const submittedAt = completedAt ? DateTime.fromISO(completedAt) : null; - return ( - - {submittedAt?.isValid - ? t('Submitted on {{date}}', { - date: dateFormatShort(submittedAt, locale), - }) - : t('This questionnaire has been submitted.')} - - ); + return ; } return ( @@ -51,6 +38,32 @@ const SummaryIntro: React.FC<{ ); }; +const MissingInfoAlert: React.FC<{ + sections: SummarySectionData[]; + onSelect: (step: SummarySectionData['step']) => void; +}> = ({ sections, onSelect }) => { + const { t } = useTranslation(); + + return ( + + {t('Your form is missing information.')} +
    + {sections.map((section) => ( +
  • + onSelect(section.step)} + > + {section.title} + +
  • + ))} +
+
+ ); +}; + export const Summary: React.FC = () => { const { t } = useTranslation(); const router = useRouter(); @@ -121,7 +134,6 @@ export const Summary: React.FC = () => {
@@ -140,35 +152,26 @@ export const Summary: React.FC = () => { {!readOnly && !canSubmit && ( - - {t('Your form is missing information.')} -
    - {incompleteSections.map((section) => ( -
  • - handleStepChange(section.step)} - > - {section.title} - -
  • - ))} -
-
+ )} - - - {!readOnly && ( - setConfirmOpen(true)} - disabled={!canSubmit} - > - {t('Submit')} - - )} - + {/* Once submitted, the step icons are enough to read the answers */} + {!questionnaire?.completed && ( + + + {!readOnly && ( + setConfirmOpen(true)} + disabled={!canSubmit} + > + {t('Submit')} + + )} + + )} = ({ completed = true, completedAt = '2026-11-10T12:00:00Z', + trainingName = 'Winter NSO 2027', + trainingStartDate = '2027-01-05', children = , }) => ( {children} @@ -28,6 +37,39 @@ describe('Summary of a submitted questionnaire', () => { expect(await findByText('Submitted on 11/10/2026')).toBeInTheDocument(); }); + it('says where they get their goal and how to reach the MPD Team', async () => { + const { findByText, getByRole } = render(); + + expect( + await findByText( + "You'll receive your support goal at Winter NSO 2027 that begins on Jan 5, 2027.", + ), + ).toBeInTheDocument(); + expect(getByRole('link', { name: 'Email the MPD Team.' })).toHaveAttribute( + 'href', + 'mailto:mpdhelp@cru.org', + ); + }); + + it('leaves out the start date when the training has none', async () => { + const { findByText } = render(); + + expect( + await findByText("You'll receive your support goal at Winter NSO 2027."), + ).toBeInTheDocument(); + }); + + it('still offers the MPD Team email when there is no training', async () => { + const { findByRole, queryByText } = render( + , + ); + + expect( + await findByRole('link', { name: 'Email the MPD Team.' }), + ).toBeInTheDocument(); + expect(queryByText(/support goal/)).not.toBeInTheDocument(); + }); + it('says it was submitted when the date is missing', async () => { const { findByText, queryByText } = render( , @@ -77,6 +119,7 @@ describe('Summary of a submitted questionnaire', () => { queryByText('This questionnaire has been submitted.'), ).not.toBeInTheDocument(); expect(queryByRole('button', { name: 'Submit' })).not.toBeInTheDocument(); + expect(queryByRole('button', { name: 'Back' })).toBeInTheDocument(); }); it('offers no way to edit or submit it', async () => { @@ -96,15 +139,16 @@ describe('Summary of a submitted questionnaire', () => { expect(queryByText(/then select Submit to finish/)).not.toBeInTheDocument(); }); - it('still lets them go back to read the steps', async () => { - const { findByRole, findByText, getByRole } = render( + it('drops the Back button but still lets them read the steps', async () => { + const { findByRole, findByText, getByRole, queryByRole } = render( , ); await findByText('Submitted on 11/10/2026'); - userEvent.click(getByRole('button', { name: 'Back' })); + expect(queryByRole('button', { name: 'Back' })).not.toBeInTheDocument(); + userEvent.click(getByRole('button', { name: 'Questionnaire Step 4' })); expect( await findByRole('radio', { name: 'Single in hotel/dorm room' }), diff --git a/src/components/HrTools/NsoMpdQuestionnaire/Summary/useSummarySections.ts b/src/components/HrTools/NsoMpdQuestionnaire/Summary/useSummarySections.ts index 64b22cd5c..49d9f5d37 100644 --- a/src/components/HrTools/NsoMpdQuestionnaire/Summary/useSummarySections.ts +++ b/src/components/HrTools/NsoMpdQuestionnaire/Summary/useSummarySections.ts @@ -162,7 +162,7 @@ export const useSummarySections = (): SummarySectionData[] => { : `${spouseContribution403bPercentage}%`, }, { - label: t("Spouse's requested MHA"), + label: t("Spouse's annual requested MHA"), value: formatMoney(spouseMhaAmount), }, {