Skip to content

Commit

Permalink
Vebt 868 updated (#33621)
Browse files Browse the repository at this point in the history
* fixed issue with addressline 2

* fixed issue with addressline 2
  • Loading branch information
wafimohamed authored Dec 18, 2024
1 parent dba8ffd commit 179c552
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,6 @@ import {
import { blockURLsRegEx } from '../constants';
import { splitAddressLine } from '../helpers';

const initializeAddressLine1 = formData => {
return formData?.addressLine1 !== undefined
? splitAddressLine(formData?.addressLine1, 20).line1
: splitAddressLine(formData?.street?.trim(), 20).line1;
};

const initializeAddressLine2 = formData => {
const address1 =
formData?.street?.length > 20
? splitAddressLine(formData?.addressLine1, 20).line2
: splitAddressLine(formData?.addressLine2, 20).line1;
const address2 =
formData?.street?.length > 20
? splitAddressLine(formData?.street?.trim(), 20).line2
: splitAddressLine(formData?.street2?.trim(), 20).line1;

if (formData?.addressLine2 === undefined && address2 === '') {
return undefined;
}
return formData?.addressLine2 !== undefined ? address1 : address2;
};

const cleanZipCode = zipcode => {
return zipcode?.substring(0, 5);
};
Expand All @@ -45,7 +23,6 @@ const ADDRESS_FORM_VALUES = {
COUNTRY_ISO3_CODES: countries.map(country => country.countryCodeISO3),
MILITARY_STATES,
};

const STREET_LINE_MAX_LENGTH = 20;

export const getFormSchema = (formData = {}) => {
Expand Down Expand Up @@ -75,14 +52,16 @@ export const getFormSchema = (formData = {}) => {
minLength: 1,
maxLength: STREET_LINE_MAX_LENGTH,
pattern: blockURLsRegEx,
default: initializeAddressLine1(formData),
default: splitAddressLine(formData?.addressLine1, 20).line1,
},
addressLine2: {
type: 'string',
minLength: 1,
maxLength: STREET_LINE_MAX_LENGTH,
pattern: blockURLsRegEx,
default: initializeAddressLine2(formData),
default:
splitAddressLine(formData?.addressLine1, 20).line2 ||
formData?.addressLine2,
},
addressLine3: {
type: 'string',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ const ChangeOfAddressWrapper = ({ mailingAddress, loading, applicantName }) => {
cancelEditClick={cancelEditClick}
formType=" mailing address"
/>

<ChangeOfAddressForm
addressFormData={formData}
formChange={addressData => updateAddressData(addressData)}
Expand Down

0 comments on commit 179c552

Please sign in to comment.