Skip to content

Commit

Permalink
Merge branch 'main' into VACMS-20190-some-zip-codes-crash-FL
Browse files Browse the repository at this point in the history
  • Loading branch information
eselkin authored Dec 27, 2024
2 parents d6b0683 + 31b591d commit d532155
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,23 @@ export const applicantContactInfoSchema = {
),
applicantPhone: phoneUI(),
applicantEmail: emailUI(),
'ui:options': {
updateSchema: (formData, formSchema) => {
const fs = JSON.parse(JSON.stringify(formSchema)); // Deep copy
// If user is the applicant, they have already given us an email
// previously in signer section, so remove the field on this page:
if (formData.certifierRole === 'applicant') {
delete fs.properties.applicantEmail;
// Just in case we require this email field in future, be sure to un-require it:
fs.required = fs.required.filter(f => f !== 'applicantEmail');
} else if (fs.properties.applicantEmail === undefined) {
// Replace email field if we previously dropped it and
// user is not the applicant:
fs.properties.applicantEmail = emailSchema;
}
return fs;
},
},
},
schema: {
type: 'object',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,8 @@ export const applicantMedicareABUploadSchema = {
<br />
Upload a copy of one of these documents:
<ul>
<li>
Medicare Parts A and B card, <b>or</b>
</li>
<li>
Medicare Advantage card, <b>or</b>
</li>
<li>Medicare Parts A and B card, or</li>
<li>Medicare Advantage card, or</li>
<li>Medicare PACE card</li>
</ul>
If you don’t have a copy to upload now, you can send it by mail or
Expand Down
2 changes: 2 additions & 0 deletions src/applications/ivc-champva/10-7959C/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const officeAddress = (
P.O. Box 469063
<br />
Denver, CO 80246-9063
<br />
United States of America
</>
);
export const officeFaxNum = '3033317808';
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
],
"consentToMailMissingRequiredFiles": true,
"certifierRole": "other",
"certifierEmail": "[email protected]",
"signature": "Certifier Jones"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"suffix": "III"
},
"certifierRole": "other",
"certifierEmail": "[email protected]",
"signature": "Certifier Jones"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
],
"consentToMailMissingRequiredFiles": true,
"certifierRole": "other",
"certifierEmail": "[email protected]",
"signature": "Certifier Jones"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
],
"consentToMailMissingRequiredFiles": true,
"certifierRole": "other",
"certifierEmail": "[email protected]",
"signature": "Certifier Jones"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"certifierRole": "applicant",
"certifierEmail": "[email protected]",
"primaryInsuranceCard": [
{
"name": "example_upload.png",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"secondaryMedigapPlan": "M",
"secondaryAdditionalComments": "Additional secondary comment",
"certifierRole": "other",
"certifierEmail": "[email protected]",
"signature": "Certifier Jones",
"consentToMailMissingRequiredFiles": true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"consentToMailMissingRequiredFiles": true,
"certifierRole": "other",
"certifierEmail": "[email protected]",
"signature": "Certifier Jones"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"primaryAdditionalComments": "Additional primary comment",
"consentToMailMissingRequiredFiles": true,
"certifierRole": "other",
"certifierEmail": "[email protected]",
"signature": "Certifier Jones"
}
}
2 changes: 1 addition & 1 deletion src/applications/ivc-champva/10-7959f-1/config/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const formConfig = {
uiSchema: {
...titleUI(
'Phone and email address',
'For foreign numbers, add the country code so we can reach you if there are questions about this form.',
'Include a country code for foreign phone numbers',
),
messageAriaDescribedby:
'Please include this information so that we can contact you with questions or updates.',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable camelcase */
import CONSTANTS from 'vets-json-schema/dist/constants.json'; // For countries
import { formatDateShort } from 'platform/utilities/date';
import { transformForSubmit as formsSystemTransformForSubmit } from 'platform/forms-system/src/js/helpers';
import { concatStreets } from '../../shared/utilities';
Expand All @@ -12,6 +13,21 @@ function stringifyAddress(addr) {
: '';
}

/**
* Converts country codes to full country names and returns updated address.
* e.g., {country: 'USA'} => {country: 'United States'}
* @param {object} addr Standard address object provided by the addressUI component.
* @returns Updated address object with country value replaced or left alone depending on presence of matching country label in the CONSTANTS file.
*/
function getCountryLabel(addr) {
const tmpAdr = addr;
// Find country label that matches country code in `addr`
tmpAdr.country =
CONSTANTS.countries.filter(c => c.value === tmpAdr.country)[0]?.label ??
tmpAdr.country; // leave untouched if no match found
return tmpAdr;
}

export default function transformForSubmit(formConfig, form) {
const transformedData = JSON.parse(
formsSystemTransformForSubmit(formConfig, form),
Expand Down Expand Up @@ -62,6 +78,14 @@ export default function transformForSubmit(formConfig, form) {
dataPostTransform.veteran.mailing_address,
);

// Replace country code with full name:
dataPostTransform.veteran.physical_address = getCountryLabel(
dataPostTransform.veteran.physical_address,
);
dataPostTransform.veteran.mailing_address = getCountryLabel(
dataPostTransform.veteran.mailing_address,
);

return JSON.stringify({
...dataPostTransform,
form_number: formConfig.formId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,53 @@ import formConfig from '../../../config/form';
import transformForSubmit from '../../../config/submitTransformer';

describe('submit transformer', () => {
it('should return expected data', () => {
const formData = {
data: {
veteranDateOfBirth: '2004-02-19',
fullName: 'John Smith',
physical_address: {
street: '1 Main st',
city: 'Canton',
state: 'NY',
postalCode: '13625',
country: 'US',
},
mailing_address: {
street: '21 Jump St',
city: 'Prattville',
state: 'WA',
postalCode: '12569',
country: 'US',
},
ssn: '963879632',
va_claim_number: '5236978',
phone_number: '2056321459',
email_address: '[email protected]',
const formData = {
data: {
veteranDateOfBirth: '2004-02-19',
fullName: 'John Smith',
veteranAddress: {
street: '1 Main st',
city: 'Canton',
state: 'NY',
postalCode: '13625',
country: 'AFG',
},
physicalAddress: {
street: '21 Jump St',
city: 'Prattville',
state: 'WA',
postalCode: '12569',
country: 'USA',
},
};
ssn: '963879632',
va_claim_number: '5236978',
phone_number: '2056321459',
email_address: '[email protected]',
},
};
it('should return expected data', () => {
const newTransformData = JSON.parse(
transformForSubmit(formConfig, formData),
);
// eslint-disable-next-line no-console
expect(newTransformData.veteran.date_of_birth).to.equal('02/19/2004');
});
it('should replace country code with full country name', () => {
const data = JSON.parse(
transformForSubmit(formConfig, {
data: {
veteranDateOfBirth: '2004-02-19',
sameMailingAddress: true,
veteranAddress: {
street: '1 Main st',
city: 'Canton',
state: 'NY',
postalCode: '13625',
country: 'USA',
},
},
}),
);
expect(data.veteran.physical_address.country).to.equal('United States');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export default function MissingFileOverview({
// Update sponsor to identify missing uploads
const sponsorConditionalPages = getConditionalPages(pages, data);
const sponsorMiss = {
name: data?.[nonListNameKey || 'veteransFullName'],
[nonListNameKey ?? 'name']: data?.[nonListNameKey || 'veteransFullName'],
missingUploads: checkFlags(
sponsorConditionalPages,
data,
Expand Down

0 comments on commit d532155

Please sign in to comment.