diff --git a/src/applications/ask-va/config/chapters/personalInformation/aboutTheFamilyMember.js b/src/applications/ask-va/config/chapters/personalInformation/aboutTheFamilyMember.js index 2167bd71b8c5..8a1fcc0d621e 100644 --- a/src/applications/ask-va/config/chapters/personalInformation/aboutTheFamilyMember.js +++ b/src/applications/ask-va/config/chapters/personalInformation/aboutTheFamilyMember.js @@ -1,42 +1,47 @@ +import VaTextInputField from 'platform/forms-system/src/js/web-component-fields/VaTextInputField'; import { dateOfBirthSchema, dateOfBirthUI, - fullNameSchema, - fullNameUI, + selectSchema, ssnSchema, ssnUI, titleUI, } from 'platform/forms-system/src/js/web-component-patterns'; -import { CHAPTER_3 } from '../../../constants'; -import { - personalInformationFormSchemas, - personalInformationUiSchemas, -} from '../../schema-helpers/personalInformationHelper'; - -const aboutVetUiSchema = { - ...personalInformationUiSchemas, - socialNum: { - ...ssnUI(), - 'ui:required': () => true, - 'ui:options': { - hideIf: () => false, - }, - }, -}; -delete aboutVetUiSchema.genderIdentity; -delete aboutVetUiSchema.socialOrServiceNum; -delete aboutVetUiSchema.isVeteranDeceased; - -const aboutVetFormSchema = { ...personalInformationFormSchemas, ssnSchema }; -delete aboutVetFormSchema.genderIdentity; -delete aboutVetFormSchema.socialOrServiceNum; -delete aboutVetFormSchema.isVeteranDeceased; +import VaSelectField from '~/platform/forms-system/src/js/web-component-fields/VaSelectField'; +import { CHAPTER_3, suffixes } from '../../../constants'; const aboutTheFamilyMemberPage = { uiSchema: { ...titleUI(CHAPTER_3.ABOUT_YOUR_FAM_MEM.TITLE), aboutTheFamilyMember: { - fullName: fullNameUI(), + first: { + 'ui:title': 'First name', + 'ui:webComponentField': VaTextInputField, + 'ui:autocomplete': 'given-name', + 'ui:required': () => true, + 'ui:errorMessages': { required: 'Please enter a first name' }, + }, + middle: { + 'ui:title': 'Middle name', + 'ui:webComponentField': VaTextInputField, + 'ui:autocomplete': 'additional-name', + }, + last: { + 'ui:title': 'Last name', + 'ui:webComponentField': VaTextInputField, + 'ui:autocomplete': 'family-name', + 'ui:required': () => true, + 'ui:errorMessages': { required: 'Please enter a last name' }, + }, + suffix: { + 'ui:title': 'Suffix', + 'ui:webComponentField': VaSelectField, + 'ui:autocomplete': 'honorific-suffix', + 'ui:options': { + widgetClassNames: 'form-select-medium', + hideEmptyValueInReview: true, + }, + }, socialOrServiceNum: { ssn: ssnUI() }, dateOfBirth: dateOfBirthUI(), }, @@ -48,7 +53,25 @@ const aboutTheFamilyMemberPage = { type: 'object', required: ['dateOfBirth'], properties: { - fullName: fullNameSchema, + first: { + type: 'string', + pattern: '^[A-Za-z]+$', + minLength: 1, + maxLength: 25, + }, + middle: { + type: 'string', + pattern: '^[A-Za-z]+$', + minLength: 1, + maxLength: 25, + }, + last: { + type: 'string', + pattern: '^[A-Za-z]+$', + minLength: 1, + maxLength: 25, + }, + suffix: selectSchema(suffixes), socialOrServiceNum: { type: 'object', required: ['ssn'], diff --git a/src/applications/ask-va/config/helpers.jsx b/src/applications/ask-va/config/helpers.jsx index 968c98ce9614..5ee7869589e2 100644 --- a/src/applications/ask-va/config/helpers.jsx +++ b/src/applications/ask-va/config/helpers.jsx @@ -489,3 +489,14 @@ export const isBranchOfServiceRequired = data => { whoIsYourQuestionAbout === whoIsYourQuestionAboutLabels.GENERAL ); }; + +// Veteran Readiness and Employment (VR&E) rules: https://github.com/department-of-veterans-affairs/va.gov-team/blob/master/products/ask-va/design/Fields%2C%20options%20and%20labels/Field%20rules.md#veteran-readiness-and-employment-vre-information +export const isVRERequired = data => { + const { selectCategory, selectTopic } = data; + + return ( + selectCategory === CategoryVeteranReadinessAndEmployment || + (selectCategory === CategoryEducation && + selectTopic === TopicVeteranReadinessAndEmploymentChapter31) + ); +}; diff --git a/src/applications/ask-va/config/schema-helpers/formFlowHelper.js b/src/applications/ask-va/config/schema-helpers/formFlowHelper.js index 0e2ff927d217..0dab8808124b 100644 --- a/src/applications/ask-va/config/schema-helpers/formFlowHelper.js +++ b/src/applications/ask-va/config/schema-helpers/formFlowHelper.js @@ -1,12 +1,10 @@ import _ from 'lodash'; import { CategoryEducation, - CategoryVeteranReadinessAndEmployment, CHAPTER_2, CHAPTER_3, healthcareCategoryLabels, schoolInYourProfileOptions, - TopicVeteranReadinessAndEmploymentChapter31, yourRoleOptionsEducation, } from '../../constants'; import { @@ -14,6 +12,7 @@ import { isLocationOfResidenceRequired, isPostalCodeRequired, isStateOfPropertyRequired, + isVRERequired, } from '../helpers'; // Personal Information @@ -319,10 +318,7 @@ const ch3Pages = { title: CHAPTER_3.YOUR_VRE_INFORMATION.TITLE, uiSchema: yourVREInformationPage.uiSchema, schema: yourVREInformationPage.schema, - depends: form => - form.selectCategory === CategoryVeteranReadinessAndEmployment || - (form.selectCategory === CategoryEducation && - form.selectTopic === TopicVeteranReadinessAndEmploymentChapter31), + depends: form => isVRERequired(form), }, yourVRECounselor: { title: CHAPTER_3.YOUR_VRE_COUNSELOR.TITLE, @@ -334,10 +330,7 @@ const ch3Pages = { title: CHAPTER_3.THEIR_VRE_INFORMATION.TITLE, uiSchema: theirVREInformationPage.uiSchema, schema: theirVREInformationPage.schema, - depends: form => - form.selectCategory === CategoryVeteranReadinessAndEmployment || - (form.selectCategory === CategoryEducation && - form.selectTopic === TopicVeteranReadinessAndEmploymentChapter31), + depends: form => isVRERequired(form), }, theirVRECounselor: { title: CHAPTER_3.THEIR_VRE_COUNSELOR.TITLE, diff --git a/src/applications/ask-va/config/schema-helpers/personalInformationHelper.js b/src/applications/ask-va/config/schema-helpers/personalInformationHelper.js index 68f5d3a50d08..47fbeca9da81 100644 --- a/src/applications/ask-va/config/schema-helpers/personalInformationHelper.js +++ b/src/applications/ask-va/config/schema-helpers/personalInformationHelper.js @@ -12,9 +12,12 @@ import { } from 'platform/forms-system/src/js/web-component-patterns'; import React from 'react'; import VaSelectField from '~/platform/forms-system/src/js/web-component-fields/VaSelectField'; -import { branchesOfService, CHAPTER_3, yesNoOptions } from '../../constants'; - -const suffixes = ['Jr.', 'Sr.', 'II', 'III', 'IV']; +import { + branchesOfService, + CHAPTER_3, + suffixes, + yesNoOptions, +} from '../../constants'; const ssnServiceInfo = ( <> diff --git a/src/applications/ask-va/constants.js b/src/applications/ask-va/constants.js index 527784b5a690..c4beaed327f2 100644 --- a/src/applications/ask-va/constants.js +++ b/src/applications/ask-va/constants.js @@ -149,6 +149,8 @@ export const RESPONSE_PAGE = { }, }; +export const suffixes = ['Jr.', 'Sr.', 'II', 'III', 'IV']; + export const pronounLabels = { heHimHis: 'He/him/his', sheHerHers: 'She/her/hers',