Skip to content

Commit

Permalink
Merge branch 'main' into dst1957-replace-deprecated-color
Browse files Browse the repository at this point in the history
  • Loading branch information
ataker authored Aug 29, 2023
2 parents c461263 + 2b25056 commit e4c3db1
Show file tree
Hide file tree
Showing 63 changed files with 1,190 additions and 569 deletions.
6 changes: 0 additions & 6 deletions script/install-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,3 @@ if [ ! -d ../vets-api ]; then
else
echo "Repo vets-api already cloned."
fi

# @TODO: if these are not needed anymore, remove.
# git clone [email protected]:department-of-veterans-affairs/vets-json-schema.git
# git clone [email protected]:department-of-veterans-affairs/veteran-facing-services-tools.git
# git clone [email protected]:department-of-veterans-affairs/vets-api.git
# git clone [email protected]:department-of-veterans-affairs/vets-api-mockdata.git
12 changes: 0 additions & 12 deletions script/pre-push.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
#!/bin/bash

# Temporary check due to master -> main branch switch. Remove after 2022
if [[ `git rev-parse --abbrev-ref origin/HEAD` != 'origin/main' ]]; then
echo "ERROR: The vets-website default branch has changed from 'master' to 'main'."
echo "Please run the following commands to make the switch locally:"
echo " git branch -m master main"
echo " git fetch origin"
echo " git branch -u origin/main main"
echo " git remote set-head origin -a"
exit 1
fi
# End temporary check

if [[ ! `git log origin/main.. --no-merges` ]]; then
echo "No commits to push! Add at least one commit to push this branch to origin."
exit 1
Expand Down
25 changes: 25 additions & 0 deletions src/applications/caregivers/components/FormDescriptions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,28 @@ export const VeteranSSNDescription = (
requirement to apply for the program.
</va-additional-info>
);

export const VeteranFullNameDescription = (
<>
<span className="vads-u-display--block vads-u-color--gray-medium">
Enter the name on the Veteran’s government-issued ID, like a driver’s
license or passport
</span>
</>
);
export const CaregiverFullNameDescription = (
<>
<span className="vads-u-display--block vads-u-color--gray-medium">
Enter the name on the Caregiver’s government-issued ID, like a driver’s
license or passport
</span>
</>
);

export const VeteranHomeAddressDescription = (
<>
<span className="vads-u-display--block vads-u-color--gray-medium">
This is the address where the Veteran lives
</span>
</>
);
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const PrimaryAddressWithAutofill = props => {

// define our custom error messages
const errorMessages = {
street: { required: 'Please enter a street address' },
street: { required: 'Please enter a home address' },
city: { required: 'Please enter a city' },
state: { required: 'Please enter a state' },
postalCode: {
Expand Down Expand Up @@ -138,7 +138,8 @@ const PrimaryAddressWithAutofill = props => {
id={idSchema.street.$id}
name={idSchema.street.$id}
value={formData.street}
label={`${inputLabelMap[props.name]} current street address`}
label={`${inputLabelMap[props.name]} current home address`}
hint="This is the address where the Caregiver lives"
className="cg-address-input"
error={showError('street') || null}
required
Expand All @@ -150,7 +151,7 @@ const PrimaryAddressWithAutofill = props => {
id={idSchema.street2.$id}
name={idSchema.street2.$id}
value={formData.street2}
label="Street address line 2"
label="Home address line 2"
className="cg-address-input"
onInput={handleChange}
onBlur={handleBlur}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,30 @@ import { primaryCaregiverFields } from '../../../definitions/constants';
import {
dateOfBirthUI,
fullNameUI,
customFieldSchemaUI,
genderUI,
ssnUI,
} from '../../../definitions/UIDefinitions/sharedUI';
import { primaryInputLabel } from '../../../definitions/UIDefinitions/caregiverUI';
import { CaregiverFullNameDescription } from '../../../components/FormDescriptions';
import PrimaryCaregiverDescription from '../../../components/FormDescriptions/PrimaryCaregiverDescription';

const { primaryCaregiver } = fullSchema.properties;
const primaryCaregiverProps = primaryCaregiver.properties;
// Initialize fullNameUI with originalUI
let extendedNameUI = fullNameUI(primaryInputLabel);
// Add/replace whatever key/values needed
extendedNameUI = customFieldSchemaUI(
extendedNameUI,
'first',
'ui:description',
CaregiverFullNameDescription,
);

const primaryInfoPage = {
uiSchema: {
'ui:description': PrimaryCaregiverDescription({ showPageIntro: true }),
[primaryCaregiverFields.fullName]: fullNameUI(primaryInputLabel),
[primaryCaregiverFields.fullName]: extendedNameUI,
[primaryCaregiverFields.ssn]: ssnUI(primaryInputLabel),
[primaryCaregiverFields.dateOfBirth]: dateOfBirthUI(primaryInputLabel),
[primaryCaregiverFields.gender]: genderUI(primaryInputLabel),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@ import { secondaryOnePageIntro } from '../../../definitions/content';
import {
dateOfBirthUI,
fullNameUI,
customFieldSchemaUI,
genderUI,
ssnUI,
} from '../../../definitions/UIDefinitions/sharedUI';
import { secondaryOneInputLabel } from '../../../definitions/UIDefinitions/caregiverUI';
import { CaregiverFullNameDescription } from '../../../components/FormDescriptions';
import SecondaryCaregiverDescription from '../../../components/FormDescriptions/SecondaryCaregiverDescription';

const { secondaryCaregiverOne } = fullSchema.properties;
const secondaryCaregiverOneProps = secondaryCaregiverOne.properties;
// Initialize fullNameUI with originalUI
let extendedNameUI = fullNameUI(secondaryOneInputLabel);
// Add/replace whatever key/values needed
extendedNameUI = customFieldSchemaUI(
extendedNameUI,
'first',
'ui:description',
CaregiverFullNameDescription,
);

const secondaryCaregiverInfoPage = {
uiSchema: {
Expand All @@ -20,7 +31,7 @@ const secondaryCaregiverInfoPage = {
showPageIntro: true,
}),
// secondaryOne UI
[secondaryOneFields.fullName]: fullNameUI(secondaryOneInputLabel),
[secondaryOneFields.fullName]: extendedNameUI,
[secondaryOneFields.ssn]: ssnUI(secondaryOneInputLabel),
[secondaryOneFields.dateOfBirth]: dateOfBirthUI(secondaryOneInputLabel),
[secondaryOneFields.gender]: genderUI(secondaryOneInputLabel),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@ import {
ssnUI,
genderUI,
fullNameUI,
customFieldSchemaUI,
dateOfBirthUI,
addressWithoutCountryUI,
} from '../../../definitions/UIDefinitions/sharedUI';
import { secondaryTwoInputLabel } from '../../../definitions/UIDefinitions/caregiverUI';
import { CaregiverFullNameDescription } from '../../../components/FormDescriptions';
import SecondaryCaregiverDescription from '../../../components/FormDescriptions/SecondaryCaregiverDescription';

const { secondaryCaregiverTwo } = fullSchema.properties;
const secondaryCaregiverTwoProps = secondaryCaregiverTwo.properties;
// Initialize fullNameUI with originalUI
let extendedNameUI = fullNameUI(secondaryTwoInputLabel);
// Add/replace whatever key/values needed
extendedNameUI = customFieldSchemaUI(
extendedNameUI,
'first',
'ui:description',
CaregiverFullNameDescription,
);

const secondaryTwoInfoPage = {
uiSchema: {
Expand All @@ -21,7 +32,7 @@ const secondaryTwoInfoPage = {
showPageIntro: true,
}),
// secondaryTwo UI
[secondaryTwoFields.fullName]: fullNameUI(secondaryTwoInputLabel),
[secondaryTwoFields.fullName]: extendedNameUI,
[secondaryTwoFields.ssn]: ssnUI(secondaryTwoInputLabel),
[secondaryTwoFields.dateOfBirth]: dateOfBirthUI(secondaryTwoInputLabel),
[secondaryTwoFields.gender]: genderUI(secondaryTwoInputLabel),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,37 @@ import {
emptyObjectSchema,
} from '../../../definitions/constants';
import {
customFieldSchemaUI,
emailUI,
alternativePhoneNumberUI,
primaryPhoneNumberUI,
addressWithoutCountryUI,
emailEncouragementUI,
} from '../../../definitions/UIDefinitions/sharedUI';
import { vetInputLabel } from '../../../definitions/UIDefinitions/veteranUI';
import { VeteranHomeAddressDescription } from '../../../components/FormDescriptions';
import VeteranContactDescription from '../../../components/FormDescriptions/VeteranContactDescription';

const { veteran } = fullSchema.properties;
const veteranProps = veteran.properties;
const { address, phone } = fullSchema.definitions;
// Initialize fullNameUI with originalUI object
let extendedAddressUI = addressWithoutCountryUI(vetInputLabel);
// Add/replace whatever key/values needed
extendedAddressUI = customFieldSchemaUI(
extendedAddressUI,
'street',
'ui:description',
VeteranHomeAddressDescription,
);

const vetContactInfoPage = {
uiSchema: {
'ui:description': VeteranContactDescription({
pageTitle: 'Veteran contact information',
showPageIntro: true,
}),
[veteranFields.address]: addressWithoutCountryUI(vetInputLabel),
[veteranFields.address]: extendedAddressUI,
[veteranFields.primaryPhoneNumber]: primaryPhoneNumberUI(vetInputLabel),
[veteranFields.alternativePhoneNumber]: alternativePhoneNumberUI(
vetInputLabel,
Expand Down
17 changes: 15 additions & 2 deletions src/applications/caregivers/config/chapters/veteran/vetInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,33 @@ import { veteranFields } from '../../../definitions/constants';
import {
dateOfBirthUI,
fullNameUI,
customFieldSchemaUI,
genderUI,
ssnUI,
} from '../../../definitions/UIDefinitions/sharedUI';
import { vetInputLabel } from '../../../definitions/UIDefinitions/veteranUI';
import { VeteranSSNDescription } from '../../../components/FormDescriptions';
import {
VeteranSSNDescription,
VeteranFullNameDescription,
} from '../../../components/FormDescriptions';
import VeteranContactDescription from '../../../components/FormDescriptions/VeteranContactDescription';

const { veteran } = fullSchema.properties;
const veteranProps = veteran.properties;
// Initialize fullNameUI with originalUI object
let extendedNameUI = fullNameUI(vetInputLabel);
// Add/replace whatever key/values needed
extendedNameUI = customFieldSchemaUI(
extendedNameUI,
'first',
'ui:description',
VeteranFullNameDescription,
);

const vetInfoPage = {
uiSchema: {
'ui:description': VeteranContactDescription({ showPageIntro: true }),
[veteranFields.fullName]: fullNameUI(vetInputLabel),
[veteranFields.fullName]: extendedNameUI,
[veteranFields.ssn]: merge({}, ssnUI(vetInputLabel), {
'ui:description': VeteranSSNDescription,
}),
Expand Down
40 changes: 35 additions & 5 deletions src/applications/caregivers/definitions/UIDefinitions/sharedUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export const genderUI = label => ({

export const fullNameUI = label => ({
first: {
'ui:title': `${label} first name`,
'ui:title': `${label} legal first name`,
'ui:errorMessages': {
required: `Please enter ${label} first name`,
required: `Please enter ${label} legal first name`,
},
},
last: {
Expand All @@ -51,6 +51,36 @@ export const fullNameUI = label => ({
},
});

/**
* Extend a specific field within a UI schema object with additional properties.
*
* @param {Object} originalUI - The original UI schema object that you want to extend.
* @param {string} fieldName - The name of the field within the UI schema that you want to extend (e.g., 'first', 'last', 'middle').
* @param {string} uiKey - The UI property key you want to add or modify (e.g., 'ui:description', 'ui:options').
* @param {*} uiValue - The value for the UI property key you're adding or modifying.
*
* @returns {Object} A new UI schema object with the specified field extended with the given UI key-value pair.
*
* @example
* const vetUI = { first: { 'ui:title': 'Veteran's legal first name' } };
* const extendedNameUI = customFieldSchemaUI(vetUI, 'first', 'ui:description', 'Enter your first name');
* // extendedNameUI now is: { first: { 'ui:title': 'Veteran's legal first name', 'ui:description': 'Enter your first name' } }
*/
export const customFieldSchemaUI = (originalUI, fieldName, uiKey, uiValue) => {
if (!originalUI[fieldName]) {
// If the field name doesn't exist in the originalUI, we just return the original without changes
return originalUI;
}

return {
...originalUI,
[fieldName]: {
...originalUI[fieldName],
[uiKey]: uiValue,
},
};
};

export const ssnUI = label => ({
...platformSsnUI,
'ui:title': `${label} Social Security number or tax identification number`,
Expand All @@ -76,11 +106,11 @@ export const addressWithoutCountryUI = label => ({
'ui:title': ' ',
'ui:order': ['street', 'street2', 'city', 'state', 'postalCode'],
street: {
'ui:title': `${label} current street address`,
'ui:errorMessages': { required: 'Please enter a street address' },
'ui:title': `${label} current home address`,
'ui:errorMessages': { required: 'Please enter a home address' },
},
street2: {
'ui:title': `Street address line 2`,
'ui:title': `Home address line 2`,
},
city: {
'ui:title': `City`,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { expect } from 'chai';

import { customFieldSchemaUI } from '../../../definitions/UIDefinitions/sharedUI';

describe('customFieldSchemaUI', () => {
it('should extend the specified field with the given UI key-value pair', () => {
const originalUI = {
first: { 'ui:title': 'First Name' },
last: { 'ui:title': 'Last Name' },
};

const extendedUI = customFieldSchemaUI(
originalUI,
'first',
'ui:description',
'Enter your first name',
);

expect(extendedUI.first).to.have.property('ui:title', 'First Name');
expect(extendedUI.first).to.have.property(
'ui:description',
'Enter your first name',
);
expect(extendedUI.last).to.have.property('ui:title', 'Last Name');
});

it('should return the original UI if the field name does not exist', () => {
const originalUI = {
first: { 'ui:title': 'First Name' },
};

const extendedUI = customFieldSchemaUI(
originalUI,
'somethingElse',
'ui:description',
'Enter your middle name',
);

expect(extendedUI).to.deep.equal(originalUI);
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Dependencies
import React from 'react';
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';

// Relative Imports
Expand All @@ -11,6 +11,13 @@ import {
} from '../../helpers';

const ResultsSummary = ({ formValues }) => {
useEffect(() => {
// Redirect to the discharge wizard homepage if there isn't any form values in state.
if (formValues.questions.length <= 1) {
window.location.replace('/discharge-upgrade-instructions/');
}
}, []);

const forReconsideration =
formValues['10_prevApplicationType'] === '3' &&
formValues['11_failureToExhaust'] !== '1';
Expand Down
Loading

0 comments on commit e4c3db1

Please sign in to comment.