Skip to content

Commit

Permalink
MBMS-71539 Setting up address validation flow for preneed integration (
Browse files Browse the repository at this point in the history
…#33435)

* MBMS-71539 Setting up address validation flow for preneed integration

* Redid address validation page, need to combine both custom pages still

* MBMS-71539 fixed zip code error message

* Renamed file

* MBMS-71539 Dev Complete

* MBMS-71539 Passed POR/UI/UX Review and added basic unit tests

* MBMS-71359 Postal code error text for preparerContactDetails

* MBMS-71539 Curvy punctuation

* MBMS-71539 Revamped unit tests for suggested address pages
  • Loading branch information
ConnorJeff authored Jan 16, 2025
1 parent 0098df3 commit 3d58c33
Show file tree
Hide file tree
Showing 16 changed files with 1,216 additions and 184 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export function ContactDetailsTitle() {
);
}

export function ValidateAddressTitle() {
export function ValidateAddressTitle({ title }) {
return (
<div className="validate-address-title">
<h3 className="vads-u-font-size--h5">Validate Address</h3>
<h3 className="vads-u-font-size--h5">{title}</h3>
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React from 'react';
import { VaRadio } from '@department-of-veterans-affairs/component-library/dist/react-bindings';
import { FIELD_NAMES } from '@@vap-svc/constants';
import { formatSuggestedAddress } from '../utils/helpers';
import { ValidateAddressTitle } from './PreparerHelpers';

export default function SuggestedAddressRadio({
title,
userAddress,
selectedAddress,
addressValidation,
onChangeSelectedAddress,
}) {
return (
<div
className="va-profile-wrapper"
id={`edit-${FIELD_NAMES.MAILING_ADDRESS}`}
>
<ValidateAddressTitle title={title} />
<p>We found a similar address to the one you entered.</p>
<VaRadio
label="Tell us which address you’d like to use."
onVaValueChange={onChangeSelectedAddress}
required
>
{userAddress && (
<va-radio-option
key="userAddress"
name="addressGroup"
label="Address you entered:"
description={formatSuggestedAddress(userAddress)}
value={JSON.stringify(userAddress)}
tile
checked={
JSON.stringify(selectedAddress) === JSON.stringify(userAddress)
}
/>
)}
{addressValidation?.confirmedSuggestions?.[0] && (
<va-radio-option
key="suggestedAddress"
name="addressGroup"
label="Suggested address:"
description={formatSuggestedAddress(
addressValidation?.confirmedSuggestions?.[0],
)}
value={JSON.stringify(addressValidation?.confirmedSuggestions?.[0])}
tile
checked={
JSON.stringify(selectedAddress) ===
JSON.stringify(addressValidation?.confirmedSuggestions?.[0])
}
/>
)}
</VaRadio>
</div>
);
}
121 changes: 115 additions & 6 deletions src/applications/pre-need-integration/config/form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ import {
ContactDetailsTitle,
PreparerDetailsTitle,
} from '../components/PreparerHelpers';
import preparerContactDetailsCustom from './pages/preparerContactDetailsCustom';
import ApplicantSuggestedAddress from './pages/applicantSuggestedAddress';
import SponsorSuggestedAddress from './pages/sponsorSuggestedAddress';
import preparerSuggestedAddress from './pages/preparerSuggestedAddress';

const {
preneedAttachments,
Expand Down Expand Up @@ -205,16 +207,16 @@ const formConfig = {
uiSchema: preparerContactDetails.uiSchema,
schema: preparerContactDetails.schema,
},
validatePreparerContactDetails: {
preparerSuggestedAddress: {
title: 'Validate Address',
path: 'validate-preparer-contact-details',
path: 'preparer-suggested-address',
depends: formData => isAuthorizedAgent(formData),
uiSchema: {
application: {
applicant: {
'view:validateAddress': {
'view:preparerSuggestedAddress': {
'ui:title': 'Validate Address',
'ui:field': preparerContactDetailsCustom,
'ui:field': preparerSuggestedAddress,
},
},
},
Expand All @@ -228,7 +230,7 @@ const formConfig = {
applicant: {
type: 'object',
properties: {
'view:validateAddress': {
'view:preparerSuggestedAddress': {
type: 'object',
properties: {},
},
Expand Down Expand Up @@ -335,6 +337,40 @@ const formConfig = {
),
schema: applicantContactInformation.schema,
},
applicantSuggestedAddress: {
title: 'Validate Address',
path: 'applicant-suggested-address',
depends: formData => !isAuthorizedAgent(formData),
uiSchema: {
application: {
applicant: {
'view:applicantSuggestedAddress': {
'ui:title': 'Validate Address',
'ui:field': ApplicantSuggestedAddress,
},
},
},
},
schema: {
type: 'object',
properties: {
application: {
type: 'object',
properties: {
applicant: {
type: 'object',
properties: {
'view:applicantSuggestedAddress': {
type: 'object',
properties: {},
},
},
},
},
},
},
},
},
applicantContactInformationPreparer: {
title: applicantContactInfoPreparerAddressTitle,
path: 'applicant-contact-information-preparer',
Expand All @@ -346,6 +382,40 @@ const formConfig = {
),
schema: applicantContactInformation.schema,
},
applicantSuggestedAddressPreparer: {
title: 'Validate Address',
path: 'preparer-suggested-address-preparer',
depends: formData => isAuthorizedAgent(formData),
uiSchema: {
application: {
applicant: {
'view:applicantSuggestedAddressPreparer': {
'ui:title': 'Validate Address',
'ui:field': ApplicantSuggestedAddress,
},
},
},
},
schema: {
type: 'object',
properties: {
application: {
type: 'object',
properties: {
applicant: {
type: 'object',
properties: {
'view:applicantSuggestedAddressPreparer': {
type: 'object',
properties: {},
},
},
},
},
},
},
},
},
applicantDemographics: {
title: 'Your demographics',
path: 'applicant-demographics',
Expand Down Expand Up @@ -430,6 +500,45 @@ const formConfig = {
uiSchema: sponsorContactInformation.uiSchema,
schema: sponsorContactInformation.schema,
},
sponsorSuggestedAddress: {
title: 'Validate Address',
path: 'sponsor-suggested-address',
depends: formData =>
!isVeteran(formData) &&
((!isApplicantTheSponsor(formData) &&
!isSponsorDeceased(formData)) ||
isApplicantTheSponsor(formData)) &&
formData?.application?.veteran?.address.street !== undefined,
uiSchema: {
application: {
applicant: {
'view:sponsorSuggestedAddress': {
'ui:title': 'Validate Address',
'ui:field': SponsorSuggestedAddress,
},
},
},
},
schema: {
type: 'object',
properties: {
application: {
type: 'object',
properties: {
applicant: {
type: 'object',
properties: {
'view:sponsorSuggestedAddress': {
type: 'object',
properties: {},
},
},
},
},
},
},
},
},
sponsorDemographics: {
title: 'Sponsor demographics',
path: 'sponsor-demographics',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React from 'react';
import { connect } from 'react-redux';

function AddressConfirmation(/* { formData } */) {
const formDataUserAddress = {
street: '123 Test Street',
city: 'City',
state: 'MC',
postalCode: '28226',
country: 'USA',
};

// Helper function to conditionally return a line with a break
const renderLine = content => {
return content ? (
<>
{content}
<br />
</>
) : null;
};

// For city/state/postalCode line, we build it conditionally:
const cityStatePostal = [
formDataUserAddress?.city,
formDataUserAddress?.city &&
(formDataUserAddress?.state || formDataUserAddress?.postalCode)
? ','
: '',
formDataUserAddress?.state,
formDataUserAddress?.state && formDataUserAddress?.postalCode ? ' ' : '',
formDataUserAddress?.postalCode,
]
.join('')
.trim();

return (
<>
<va-alert
close-btn-aria-label="Close notification"
status="warning"
visible
>
<h2 slot="headline">Check the address you entered</h2>
<React.Fragment key=".1">
<p className="vads-u-margin-y--0">
We can’t confirm the address you entered with the U.S. Postal
Service. Check the address before continuing.
</p>
</React.Fragment>
</va-alert>
<h3 className="vads-u-font-size--h5" style={{ paddingTop: '2em' }}>
Check your mailing address
</h3>
<p style={{ marginTop: '1em' }}>You entered:</p>
<div className="blue-bar-block">
<p className="va-address-block">
{renderLine(formDataUserAddress?.street)}
{renderLine(formDataUserAddress?.street2)}
{cityStatePostal && renderLine(cityStatePostal)}
{renderLine(formDataUserAddress?.country)}
</p>
</div>
<p>
If the address is correct, you can continue. If you need to edit the
address, you can go back.
</p>
<va-additional-info trigger="Why we can't confirm the address you entered">
<p>
The address you entered may not be in the U.S. Postal Service’s
system. Or, you may have entered an error or other incorrect
information.
</p>
</va-additional-info>
</>
);
}

const mapStateToProps = state => {
return {
state,
formData: state?.form?.data,
addressValidation: state?.vapService?.addressValidation,
};
};

export default connect(mapStateToProps)(AddressConfirmation);
Loading

0 comments on commit 3d58c33

Please sign in to comment.