Skip to content

Commit

Permalink
refactored rules and fixed about family member payload
Browse files Browse the repository at this point in the history
  • Loading branch information
hemeshvpatel committed Dec 2, 2024
1 parent 9231692 commit e0a1389
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -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(),
},
Expand All @@ -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'],
Expand Down
11 changes: 11 additions & 0 deletions src/applications/ask-va/config/helpers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
};
13 changes: 3 additions & 10 deletions src/applications/ask-va/config/schema-helpers/formFlowHelper.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import _ from 'lodash';
import {
CategoryEducation,
CategoryVeteranReadinessAndEmployment,
CHAPTER_2,
CHAPTER_3,
healthcareCategoryLabels,
schoolInYourProfileOptions,
TopicVeteranReadinessAndEmploymentChapter31,
yourRoleOptionsEducation,
} from '../../constants';
import {
isBranchOfServiceRequired,
isLocationOfResidenceRequired,
isPostalCodeRequired,
isStateOfPropertyRequired,
isVRERequired,
} from '../helpers';

// Personal Information
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
<>
Expand Down
2 changes: 2 additions & 0 deletions src/applications/ask-va/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit e0a1389

Please sign in to comment.