From e90be0b4bdc3574ad4e4c752b1b23da9f3c25e7f Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Wed, 14 Jul 2021 11:41:42 -0400 Subject: [PATCH 1/2] Remove default state AK and require users to enter a state --- src/components/StatePicker.js | 7 +++++++ src/libs/ValidationUtils.js | 2 +- src/pages/ReimbursementAccount/CompanyStep.js | 4 ++-- src/pages/ReimbursementAccount/RequestorStep.js | 3 ++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/StatePicker.js b/src/components/StatePicker.js index 53239f2e6d01..c81dae2f1e33 100644 --- a/src/components/StatePicker.js +++ b/src/components/StatePicker.js @@ -9,6 +9,13 @@ const STATES = _.map(CONST.STATES, ({stateISO}) => ({ label: stateISO, })); + +// Add a blank state so users are sure to actively choose a state instead accidentally going with the default choice +STATES.unshift({ + value: '', + label: '-', +}); + const propTypes = { /** A callback method that is called when the value changes and it received the selected value as an argument */ onChange: PropTypes.func.isRequired, diff --git a/src/libs/ValidationUtils.js b/src/libs/ValidationUtils.js index df3aa71cfa2c..7a46bbfba6c1 100644 --- a/src/libs/ValidationUtils.js +++ b/src/libs/ValidationUtils.js @@ -73,7 +73,7 @@ function isValidSSNLastFour(ssnLast4) { * @returns {Boolean} */ function isValidIdentity(identity) { - if (!isValidAddress(identity.street)) { + if (!isValidAddress(identity.street) || identity.state === '') { Growl.error(translateLocal('bankAccount.error.address')); return false; } diff --git a/src/pages/ReimbursementAccount/CompanyStep.js b/src/pages/ReimbursementAccount/CompanyStep.js index de561fa37249..5b02d34fab5a 100644 --- a/src/pages/ReimbursementAccount/CompanyStep.js +++ b/src/pages/ReimbursementAccount/CompanyStep.js @@ -33,14 +33,14 @@ class CompanyStep extends React.Component { companyName: lodashGet(props, ['achData', 'companyName'], ''), addressStreet: lodashGet(props, ['achData', 'addressStreet'], ''), addressCity: lodashGet(props, ['achData', 'addressCity'], ''), - addressState: lodashGet(props, ['achData', 'addressState']) || 'AK', + addressState: lodashGet(props, ['achData', 'addressState']) || '', addressZipCode: lodashGet(props, ['achData', 'addressZipCode'], ''), companyPhone: lodashGet(props, ['achData', 'companyPhone'], ''), website: lodashGet(props, ['achData', 'website'], 'https://'), companyTaxID: lodashGet(props, ['achData', 'companyTaxID'], ''), incorporationType: lodashGet(props, ['achData', 'incorporationType'], ''), incorporationDate: lodashGet(props, ['achData', 'incorporationDate'], ''), - incorporationState: lodashGet(props, ['achData', 'incorporationState']) || 'AK', + incorporationState: lodashGet(props, ['achData', 'incorporationState']) || '', industryCode: lodashGet(props, ['achData', 'industryCode'], ''), hasNoConnectionToCannabis: lodashGet(props, ['achData', 'hasNoConnectionToCannabis'], false), password: '', diff --git a/src/pages/ReimbursementAccount/RequestorStep.js b/src/pages/ReimbursementAccount/RequestorStep.js index 812926397c50..2287724daa9b 100644 --- a/src/pages/ReimbursementAccount/RequestorStep.js +++ b/src/pages/ReimbursementAccount/RequestorStep.js @@ -28,7 +28,7 @@ class RequestorStep extends React.Component { lastName: lodashGet(props, ['achData', 'lastName'], ''), requestorAddressStreet: lodashGet(props, ['achData', 'requestorAddressStreet'], ''), requestorAddressCity: lodashGet(props, ['achData', 'requestorAddressCity'], ''), - requestorAddressState: lodashGet(props, ['achData', 'requestorAddressState']) || 'AK', + requestorAddressState: lodashGet(props, ['achData', 'requestorAddressState']) || '', requestorAddressZipCode: lodashGet(props, ['achData', 'requestorAddressZipCode'], ''), dob: lodashGet(props, ['achData', 'dob'], ''), ssnLast4: lodashGet(props, ['achData', 'ssnLast4'], ''), @@ -60,6 +60,7 @@ class RequestorStep extends React.Component { if (!isValidIdentity({ street: this.state.requestorAddressStreet, + state: this.state.requestorAddressState, zipCode: this.state.requestorAddressZipCode, dob: this.state.dob, ssnLast4: this.state.ssnLast4, From c3656067c036be8df90448137039138ef3683bd6 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Wed, 14 Jul 2021 13:42:54 -0400 Subject: [PATCH 2/2] Add state missing error to be more specific --- src/languages/en.js | 1 + src/languages/es.js | 1 + src/libs/ValidationUtils.js | 7 ++++++- src/pages/ReimbursementAccount/CompanyStep.js | 5 +++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/languages/en.js b/src/languages/en.js index caefe148d929..5850ac110598 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -333,6 +333,7 @@ export default { website: 'Please enter a valid website', zipCode: 'Please enter a valid zip code', addressStreet: 'Please enter a valid address street that is not a PO Box', + addressState: 'Please select a valid state', incorporationDate: 'Please enter a valid incorporation date', incorporationState: 'Please enter a valid Incorporation State', industryCode: 'Please enter a valid industry classification code', diff --git a/src/languages/es.js b/src/languages/es.js index 42dd0cb674dd..f51c726bc3fb 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -321,6 +321,7 @@ export default { website: 'Ingrese un sitio web válido', zipCode: 'Ingrese un código postal válido', addressStreet: 'Ingrese una calle de dirección válida que no sea un apartado postal', + addressState: 'Por favor, selecciona un estado', incorporationDate: 'Ingrese una fecha de incorporación válida', incorporationState: 'Ingrese un estado de incorporación válido', industryCode: 'Ingrese un código de clasificación de industria válido', diff --git a/src/libs/ValidationUtils.js b/src/libs/ValidationUtils.js index 7a46bbfba6c1..28b3075e45ab 100644 --- a/src/libs/ValidationUtils.js +++ b/src/libs/ValidationUtils.js @@ -73,11 +73,16 @@ function isValidSSNLastFour(ssnLast4) { * @returns {Boolean} */ function isValidIdentity(identity) { - if (!isValidAddress(identity.street) || identity.state === '') { + if (!isValidAddress(identity.street)) { Growl.error(translateLocal('bankAccount.error.address')); return false; } + if (identity.state === '') { + Growl.error(translateLocal('bankAccount.error.addressState')); + return false; + } + if (!isValidZipCode(identity.zipCode)) { Growl.error(translateLocal('bankAccount.error.zipCode')); return false; diff --git a/src/pages/ReimbursementAccount/CompanyStep.js b/src/pages/ReimbursementAccount/CompanyStep.js index 5b02d34fab5a..5f8732b881ef 100644 --- a/src/pages/ReimbursementAccount/CompanyStep.js +++ b/src/pages/ReimbursementAccount/CompanyStep.js @@ -61,6 +61,11 @@ class CompanyStep extends React.Component { return false; } + if (this.state.addressState === '') { + Growl.error(this.props.translate('bankAccount.error.addressState')); + return false; + } + if (!isValidZipCode(this.state.addressZipCode)) { Growl.error(this.props.translate('bankAccount.error.zipCode')); return false;