From 271c9c5460c639ebda846038cebcc469b599e18d Mon Sep 17 00:00:00 2001 From: Maks Turtiainen Date: Mon, 25 Sep 2023 16:07:17 +0200 Subject: [PATCH] fix: bugs related to step 2 --- .../step2/ApplicationFormStep2.tsx | 15 ---------- .../application/step2/utils/validation.ts | 30 +++++++++---------- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/frontend/benefit/applicant/src/components/applications/forms/application/step2/ApplicationFormStep2.tsx b/frontend/benefit/applicant/src/components/applications/forms/application/step2/ApplicationFormStep2.tsx index e2e83dfbc4..af8d3f00d1 100644 --- a/frontend/benefit/applicant/src/components/applications/forms/application/step2/ApplicationFormStep2.tsx +++ b/frontend/benefit/applicant/src/components/applications/forms/application/step2/ApplicationFormStep2.tsx @@ -77,20 +77,6 @@ const ApplicationFormStep2: React.FC = ({ useAlertBeforeLeaving(formik.dirty); - const isAbleToSelectEmploymentBenefit = - data?.company?.organizationType !== ORGANIZATION_TYPES.ASSOCIATION || - (data?.company?.organizationType === ORGANIZATION_TYPES.ASSOCIATION && - data?.associationHasBusinessActivities); - - // TODO: Preselect this from backend - const isAbleToSelectSalaryBenefit = - formik.values.paySubsidyGranted === PAY_SUBSIDY_GRANTED.GRANTED; - - const isNoAvailableBenefitTypes = - formik.values.paySubsidyGranted !== null && - !isAbleToSelectEmploymentBenefit && - !isAbleToSelectSalaryBenefit; - return (
@@ -558,7 +544,6 @@ const ApplicationFormStep2: React.FC = ({ handleSave={handleSave} handleBack={handleBack} handleDelete={handleDelete} - disabledNext={isNoAvailableBenefitTypes} /> ); diff --git a/frontend/benefit/applicant/src/components/applications/forms/application/step2/utils/validation.ts b/frontend/benefit/applicant/src/components/applications/forms/application/step2/utils/validation.ts index e291898257..7925301f0d 100644 --- a/frontend/benefit/applicant/src/components/applications/forms/application/step2/utils/validation.ts +++ b/frontend/benefit/applicant/src/components/applications/forms/application/step2/utils/validation.ts @@ -53,6 +53,21 @@ export const getValidationSchema = ( [APPLICATION_FIELDS_STEP2_KEYS.END_DATE]: Yup.string().required( t(VALIDATION_MESSAGE_KEYS.REQUIRED) ), + [APPLICATION_FIELDS_STEP2_KEYS.ASSOCIATION_IMMEDIATE_MANAGER_CHECK]: + Yup.boolean() + .nullable() + .test({ + message: t(VALIDATION_MESSAGE_KEYS.REQUIRED), + test: (val) => { + if ( + organizationType?.toLowerCase() === + ORGANIZATION_TYPES.ASSOCIATION.toLowerCase() + ) + return val === true; + + return true; + }, + }), [APPLICATION_FIELDS_STEP2_KEYS.EMPLOYEE]: Yup.object().shape({ [EMPLOYEE_KEYS.FIRST_NAME]: Yup.string() .matches(NAMES_REGEX, t(VALIDATION_MESSAGE_KEYS.INVALID)) @@ -72,21 +87,6 @@ export const getValidationSchema = ( [true], t(VALIDATION_MESSAGE_KEYS.REQUIRED_IS_LIVING_IN_HELSINKI) ), - [APPLICATION_FIELDS_STEP2_KEYS.ASSOCIATION_IMMEDIATE_MANAGER_CHECK]: - Yup.boolean() - .nullable() - .test({ - message: t(VALIDATION_MESSAGE_KEYS.REQUIRED), - test: (val) => { - if ( - organizationType?.toLowerCase() === - ORGANIZATION_TYPES.ASSOCIATION.toLowerCase() - ) - return val === true; - - return true; - }, - }), [EMPLOYEE_KEYS.JOB_TITLE]: Yup.string() .nullable() .required(t(VALIDATION_MESSAGE_KEYS.REQUIRED)),