Skip to content

Commit 2587ce4

Browse files
committed
Fixes lint errors
1 parent 2ed5ff5 commit 2587ce4

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

src/AddressForm/AddressFormInternational.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ const AddressFormInternational = ({
5656
submitButtonLabel = 'Submit'
5757
}) => {
5858
const [form, setForm] = useState(defaultForm)
59-
const { primary_line, secondary_line, city, state, postal_code, country } = form
59+
const { primary_line, secondary_line, city, state, postal_code, country } =
60+
form
6061

6162
const handleChange = (e) => {
6263
setForm({ ...form, [e.target.id]: e.target.value })
@@ -69,26 +70,28 @@ const AddressFormInternational = ({
6970
if (!apiKey) {
7071
console.error(
7172
'[@lob/react-address-autocomplete] ' +
72-
'AddressFormInternational requires props apiKey for verifications'
73+
'AddressFormInternational requires props apiKey for verifications'
7374
)
7475
return
7576
}
7677

77-
verifyInternational(apiKey, form, form.country).then((verificationResult) => {
78-
const {
79-
primary_line,
80-
secondary_line,
81-
components: { city, state, postal_code }
82-
} = verificationResult
83-
setForm({
84-
primary_line,
85-
secondary_line,
86-
city,
87-
state,
88-
postal_code
89-
})
90-
onSubmit(verificationResult)
91-
})
78+
verifyInternational(apiKey, form, form.country).then(
79+
(verificationResult) => {
80+
const {
81+
primary_line,
82+
secondary_line,
83+
components: { city, state, postal_code }
84+
} = verificationResult
85+
setForm({
86+
primary_line,
87+
secondary_line,
88+
city,
89+
state,
90+
postal_code
91+
})
92+
onSubmit(verificationResult)
93+
}
94+
)
9295
}
9396

9497
const mergedStyles = useMergedStyles(styles, true /* isInternational */)

src/verify.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ const processApiResponse = (apiResponse) =>
2222
* @param {string} zip_code
2323
*/
2424

25-
26-
const validateArguments = (apiKey, address, countryCode = null) => {
25+
const validateArguments = (apiKey, address, countryCode, isInternational) => {
2726
if (!Object.keys(address || {}).length) {
2827
return new Error('Empty address was passed to verify function')
2928
}
@@ -32,7 +31,7 @@ const validateArguments = (apiKey, address, countryCode = null) => {
3231
return new Error('Missing API key')
3332
}
3433

35-
if (countryCode) {
34+
if (isInternational) {
3635
if (typeof countryCode !== 'string') {
3736
return new Error('Expected countryCode to be of type string')
3837
}
@@ -55,7 +54,7 @@ const validateArguments = (apiKey, address, countryCode = null) => {
5554
* https://docs.lob.com/#operation/us_verification
5655
*/
5756
export const verify = (apiKey, address) => {
58-
const error = validateArguments(apiKey, address)
57+
const error = validateArguments(apiKey, address, null, false)
5958
if (error) {
6059
return Promise.reject(error)
6160
}
@@ -87,7 +86,8 @@ export const verify = (apiKey, address) => {
8786
* https://docs.lob.com/#operation/us_verification
8887
*/
8988
export const verifyInternational = (apiKey, address, countryCode) => {
90-
const error = validateArguments(apiKey, address, countryCode)
89+
const error = validateArguments(apiKey, address, countryCode, true)
90+
9191
if (error) {
9292
return Promise.reject(error)
9393
}

0 commit comments

Comments
 (0)