diff --git a/frontend/benefit/handler/src/components/newApplication/formContent/FormContent.tsx b/frontend/benefit/handler/src/components/newApplication/formContent/FormContent.tsx index cf0f3b4039..20d8329591 100644 --- a/frontend/benefit/handler/src/components/newApplication/formContent/FormContent.tsx +++ b/frontend/benefit/handler/src/components/newApplication/formContent/FormContent.tsx @@ -10,6 +10,7 @@ import { ATTACHMENT_TYPES, ORGANIZATION_TYPES, PAY_SUBSIDY_GRANTED, + TRUTHY_SUBSIDIES, } from 'benefit-shared/constants'; import { ApplicationData, @@ -91,11 +92,6 @@ const FormContent: React.FC = ({ getErrorMessage, } = useFormContent(formik, fields); - const truthySubsidies = new Set([ - PAY_SUBSIDY_GRANTED.GRANTED, - PAY_SUBSIDY_GRANTED.GRANTED_AGED, - ]); - const theme = useTheme(); useAlertBeforeLeaving(formik.dirty); @@ -518,7 +514,7 @@ const FormContent: React.FC = ({ /> - {truthySubsidies.has(formik.values.paySubsidyGranted) && ( + {TRUTHY_SUBSIDIES.has(formik.values.paySubsidyGranted) && ( <$GridCell as={$Grid} $colSpan={12} @@ -660,7 +656,7 @@ const FormContent: React.FC = ({ /> )} - {truthySubsidies.has(formik.values.paySubsidyGranted) && ( + {TRUTHY_SUBSIDIES.has(formik.values.paySubsidyGranted) && ( <$GridCell $colSpan={12}> = ({ {t(`${translationsBase}.fields.paySubsidyGranted.review`)} <$ViewField> - {t( - `${translationsBase}.fields.paySubsidyGranted.${camelCase( - data.paySubsidyGranted - )}` - )} + {TRUTHY_SUBSIDIES.has(data.paySubsidyGranted) + ? t( + `${translationsBase}.fields.paySubsidyGranted.${camelCase( + data.paySubsidyGranted + )}` + ) + : '-'} <$GridCell $colSpan={6}> diff --git a/frontend/benefit/handler/src/components/newApplication/utils/applicationForm.ts b/frontend/benefit/handler/src/components/newApplication/utils/applicationForm.ts index 031b495306..28d0e0d263 100644 --- a/frontend/benefit/handler/src/components/newApplication/utils/applicationForm.ts +++ b/frontend/benefit/handler/src/components/newApplication/utils/applicationForm.ts @@ -13,9 +13,9 @@ import { } from 'benefit/handler/types/application'; import { ATTACHMENT_TYPES, - BENEFIT_TYPES, EMPLOYEE_KEYS, PAY_SUBSIDY_OPTIONS, + TRUTHY_SUBSIDIES, } from 'benefit-shared/constants'; import { ApplicationData } from 'benefit-shared/types/application'; import camelcaseKeys from 'camelcase-keys'; @@ -173,48 +173,42 @@ const getSubsidyOptions = (): OptionType[] => })); const requiredAttachments = (values: Application): boolean => { - if ( - values.benefitType === BENEFIT_TYPES.EMPLOYMENT || - values.benefitType === BENEFIT_TYPES.SALARY - ) { - const hasWorkContract = !isEmpty( - values.attachments?.find( + const hasWorkContract = !isEmpty( + values.attachments?.find( + (att: BenefitAttachment) => + att.attachmentType === ATTACHMENT_TYPES.EMPLOYMENT_CONTRACT + ) + ); + const hasFullApplication = !isEmpty( + values.attachments?.find( + (att: BenefitAttachment) => + att.attachmentType === ATTACHMENT_TYPES.FULL_APPLICATION + ) + ); + let hasPaySubsidyDecision = true; + if (TRUTHY_SUBSIDIES.has(values.paySubsidyGranted)) { + hasPaySubsidyDecision = !isEmpty( + values?.attachments?.find( (att: BenefitAttachment) => - att.attachmentType === ATTACHMENT_TYPES.EMPLOYMENT_CONTRACT + att.attachmentType === ATTACHMENT_TYPES.PAY_SUBSIDY_CONTRACT ) ); - const hasFullApplication = !isEmpty( - values.attachments?.find( + } + let hasApprenticeshipProgram = true; + if (values.apprenticeshipProgram) { + hasApprenticeshipProgram = !isEmpty( + values?.attachments?.find( (att: BenefitAttachment) => - att.attachmentType === ATTACHMENT_TYPES.FULL_APPLICATION + att.attachmentType === ATTACHMENT_TYPES.EDUCATION_CONTRACT ) ); - let hasPaySubsidyDecision = true; - if (values.paySubsidyGranted) { - hasPaySubsidyDecision = !isEmpty( - values?.attachments?.find( - (att: BenefitAttachment) => - att.attachmentType === ATTACHMENT_TYPES.PAY_SUBSIDY_CONTRACT - ) - ); - } - let hasApprenticeshipProgram = true; - if (values.apprenticeshipProgram) { - hasApprenticeshipProgram = !isEmpty( - values?.attachments?.find( - (att: BenefitAttachment) => - att.attachmentType === ATTACHMENT_TYPES.EDUCATION_CONTRACT - ) - ); - } - return ( - hasWorkContract && - hasFullApplication && - hasPaySubsidyDecision && - hasApprenticeshipProgram - ); } - return false; + return ( + hasWorkContract && + hasFullApplication && + hasPaySubsidyDecision && + hasApprenticeshipProgram + ); }; export { diff --git a/frontend/benefit/shared/src/constants.ts b/frontend/benefit/shared/src/constants.ts index baaf773ed2..5ac3aea187 100644 --- a/frontend/benefit/shared/src/constants.ts +++ b/frontend/benefit/shared/src/constants.ts @@ -174,4 +174,9 @@ export enum PAY_SUBSIDY_GRANTED { NOT_GRANTED = 'not_granted', } +export const TRUTHY_SUBSIDIES = new Set([ + PAY_SUBSIDY_GRANTED.GRANTED, + PAY_SUBSIDY_GRANTED.GRANTED_AGED, +]); + export const APPLICATION_START_DATE = new Date(new Date().getFullYear(), 0, 1);