@nuskin/shipping-address-form 1.7.1 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -22
- package/dist/addressLookup/AddressLookup.js +0 -12
- package/dist/addressLookup/AddressLookup.js.map +1 -1
- package/dist/addressLookup/components/SmartyIntlResults.js +28 -21
- package/dist/addressLookup/components/SmartyIntlResults.js.map +1 -1
- package/dist/addressLookup/components/SmartyUSResults.js +17 -19
- package/dist/addressLookup/components/SmartyUSResults.js.map +1 -1
- package/dist/addressLookup/hooks/useInitialAddressVerification.js +1 -1
- package/dist/addressLookup/hooks/useInitialAddressVerification.js.map +1 -1
- package/dist/addressLookup/utils/addressForm.js +14 -2
- package/dist/addressLookup/utils/addressForm.js.map +1 -1
- package/dist/addressLookup/utils/addressStatus.js +41 -7
- package/dist/addressLookup/utils/addressStatus.js.map +1 -1
- package/dist/addressLookup/utils/addressVerification.js +2 -2
- package/dist/addressLookup/utils/addressVerification.js.map +1 -1
- package/dist/addressLookup/utils/componentPropTypes.js +8 -3
- package/dist/addressLookup/utils/componentPropTypes.js.map +1 -1
- package/dist/shippingAddressForm/ShippingAddressForm.js +6 -11
- package/dist/shippingAddressForm/ShippingAddressForm.js.map +1 -1
- package/dist/shippingAddressForm/components/ShippingField.js +18 -11
- package/dist/shippingAddressForm/components/ShippingField.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ The component:
|
|
|
9
9
|
- loads a shipping form definition from Contentstack based on the logged-in country and form type
|
|
10
10
|
- renders pre-address and post-address shipping fields in the order defined by content
|
|
11
11
|
- loads localized strings once and passes the derived `formStrings` subset into `AddressLookup`
|
|
12
|
-
- emits a single `onAction` callback for
|
|
12
|
+
- emits a single `onAction` callback for save, cancel, and AddressLookup service errors
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
@@ -86,9 +86,9 @@ import {
|
|
|
86
86
|
} from '@nuskin/shipping-address-form'
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
`AddressLookup` accepts `onAddressSelect`, `country`, `language`, `address`, `
|
|
90
|
-
`
|
|
91
|
-
|
|
89
|
+
`AddressLookup` accepts `onAddressSelect`, `country`, `language`, `address`, `readOnlyView`,
|
|
90
|
+
`validationRequestId`, `strings`, `formDefinition`, and `deferFormLookup`. It supports Smarty
|
|
91
|
+
autocomplete and validation for US and international
|
|
92
92
|
addresses. `normalizeAddressForm`, `DEFAULT_ADDRESS_FORM`, and `SUPPORTED_COUNTRIES` are exported
|
|
93
93
|
for consumers that need to provide or reuse address form definitions.
|
|
94
94
|
|
|
@@ -165,7 +165,7 @@ The incoming `address` object may also include `AddressLookup` verification meta
|
|
|
165
165
|
```js
|
|
166
166
|
{
|
|
167
167
|
verification: {
|
|
168
|
-
status: 'verified', // or 'autocomplete' | 'unverified'
|
|
168
|
+
status: 'verified', // or 'autocomplete' | 'partial' | 'unverified'
|
|
169
169
|
source: 'smarty-us', // or 'smarty-intl'
|
|
170
170
|
verifiedAt: '2026-05-01T15:01:07.905Z'
|
|
171
171
|
}
|
|
@@ -219,31 +219,49 @@ Readonly mode is intended for displaying an existing address without allowing ed
|
|
|
219
219
|
|
|
220
220
|
### Address Entry and Validation
|
|
221
221
|
|
|
222
|
-
|
|
222
|
+
Address entry and validation behavior are configured in the address form definition:
|
|
223
223
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
```js
|
|
225
|
+
addressEntry: {
|
|
226
|
+
entryMode: 'both', // 'both' | 'autocomplete' | 'manual'
|
|
227
|
+
validationMode: 'required', // 'required' | 'optional' | 'disabled'
|
|
228
|
+
minimumAcceptedLevel: 'verified' // 'verified' | 'partial'
|
|
229
|
+
}
|
|
230
|
+
```
|
|
227
231
|
|
|
228
|
-
`
|
|
229
|
-
|
|
230
|
-
and
|
|
232
|
+
`entryMode` defaults to `'both'`. `validationMode` defaults to `'required'`; `'optional'` allows
|
|
233
|
+
users to validate without making verification a requirement, while `'disabled'` hides validation
|
|
234
|
+
actions and does not call Smarty validation. The manual Verify Address button is shown whenever
|
|
235
|
+
manual entry and validation are both enabled.
|
|
231
236
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
237
|
+
`minimumAcceptedLevel` applies when validation is required. `'verified'` accepts only fully verified
|
|
238
|
+
addresses. `'partial'` also accepts Smarty International partial-verification results. The returned
|
|
239
|
+
`status.canProceed` is the primary signal for whether the selected address is complete and accepted
|
|
240
|
+
under this configuration. The status also includes `validationMode`, `minimumAcceptedLevel`, and
|
|
241
|
+
`meetsVerificationRequirement` for callers that need the underlying detail.
|
|
242
|
+
|
|
243
|
+
Individual address elements can opt into limited exceptions after an accepted verification result:
|
|
244
|
+
|
|
245
|
+
```js
|
|
246
|
+
{
|
|
247
|
+
field: 'postalCode',
|
|
248
|
+
required: true,
|
|
249
|
+
allowMissingAfterVerification: true,
|
|
250
|
+
trustVerifiedFormat: true
|
|
251
|
+
}
|
|
238
252
|
```
|
|
239
253
|
|
|
240
|
-
|
|
254
|
+
Both options default to `false`. `allowMissingAfterVerification` permits that required field to be
|
|
255
|
+
absent only after accepted verification. `trustVerifiedFormat` applies to `postalCode` and accepts
|
|
256
|
+
a verified API value that does not match the local postal-code regex. It also triggers verification
|
|
257
|
+
after autocomplete when the returned postal code fails that regex. When either exception is used,
|
|
258
|
+
the status includes `verificationExceptions` with the affected fields.
|
|
241
259
|
|
|
242
260
|
### `onAction`
|
|
243
261
|
|
|
244
262
|
- Type: `(payload) => void`
|
|
245
263
|
|
|
246
|
-
Single callback for form actions.
|
|
264
|
+
Single callback for form actions and AddressLookup service errors.
|
|
247
265
|
|
|
248
266
|
#### Cancel payload
|
|
249
267
|
|
|
@@ -256,7 +274,7 @@ Single callback for form actions.
|
|
|
256
274
|
Only emitted after:
|
|
257
275
|
|
|
258
276
|
- `AddressLookup` validation is triggered
|
|
259
|
-
- `AddressLookup` reports `status.
|
|
277
|
+
- `AddressLookup` reports `status.canProceed === true`
|
|
260
278
|
- required shipping fields are complete
|
|
261
279
|
- any `allowedCharacters` regex rules defined for shipping fields pass
|
|
262
280
|
|
|
@@ -279,6 +297,7 @@ Only emitted after:
|
|
|
279
297
|
},
|
|
280
298
|
validationStatus: {
|
|
281
299
|
verification: 'verified',
|
|
300
|
+
canProceed: true,
|
|
282
301
|
completeness: 'complete',
|
|
283
302
|
missingFields: [],
|
|
284
303
|
mode: 'manual',
|
|
@@ -291,6 +310,30 @@ Only emitted after:
|
|
|
291
310
|
|
|
292
311
|
The exact shipping-field keys in `data` depend on the current form definition.
|
|
293
312
|
|
|
313
|
+
#### AddressLookup error payload
|
|
314
|
+
|
|
315
|
+
When Smarty autocomplete or validation is unavailable, the wrapper forwards the AddressLookup error payload:
|
|
316
|
+
|
|
317
|
+
```js
|
|
318
|
+
{
|
|
319
|
+
type: 'lookup-error', // or 'validation-error'
|
|
320
|
+
address: {
|
|
321
|
+
address1: '123 Main St'
|
|
322
|
+
},
|
|
323
|
+
status: {
|
|
324
|
+
verification: 'unverified',
|
|
325
|
+
needsValidation: true
|
|
326
|
+
},
|
|
327
|
+
error: {
|
|
328
|
+
kind: 'api', // or 'rate-limited'
|
|
329
|
+
source: 'autocomplete', // or 'validation'
|
|
330
|
+
message: 'We could not validate that address right now.'
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Consumers can use this event to apply their own fail-open or fail-closed policy when Smarty is unavailable.
|
|
336
|
+
|
|
294
337
|
## Form Definition
|
|
295
338
|
|
|
296
339
|
Shipping form layout is loaded from Contentstack content type:
|
|
@@ -433,7 +476,7 @@ yarn dev
|
|
|
433
476
|
The local test app supports entry configuration and readonly mode through query params:
|
|
434
477
|
|
|
435
478
|
```text
|
|
436
|
-
?country=US&language=en&type=shipping&
|
|
479
|
+
?country=US&language=en&type=shipping&readOnlyView=true
|
|
437
480
|
```
|
|
438
481
|
|
|
439
482
|
Build the package:
|
|
@@ -15,10 +15,7 @@ const AddressLookup = ({
|
|
|
15
15
|
onAddressSelect,
|
|
16
16
|
country = 'US',
|
|
17
17
|
address = null,
|
|
18
|
-
entryMode = 'both',
|
|
19
|
-
requireValidation = true,
|
|
20
18
|
readOnlyView = false,
|
|
21
|
-
showManualValidateButton = false,
|
|
22
19
|
validationRequestId = 0,
|
|
23
20
|
language = 'en',
|
|
24
21
|
strings = null,
|
|
@@ -31,10 +28,7 @@ const AddressLookup = ({
|
|
|
31
28
|
children: isUS ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_SmartyUSResults.default, {
|
|
32
29
|
onSelect: onAddressSelect,
|
|
33
30
|
initialAddress: address,
|
|
34
|
-
entryMode: entryMode,
|
|
35
|
-
requireValidation: requireValidation,
|
|
36
31
|
readOnlyView: readOnlyView,
|
|
37
|
-
showManualValidateButton: showManualValidateButton,
|
|
38
32
|
validationRequestId: validationRequestId,
|
|
39
33
|
language: language,
|
|
40
34
|
strings: strings,
|
|
@@ -44,10 +38,7 @@ const AddressLookup = ({
|
|
|
44
38
|
countryCode: country,
|
|
45
39
|
onSelect: onAddressSelect,
|
|
46
40
|
initialAddress: address,
|
|
47
|
-
entryMode: entryMode,
|
|
48
|
-
requireValidation: requireValidation,
|
|
49
41
|
readOnlyView: readOnlyView,
|
|
50
|
-
showManualValidateButton: showManualValidateButton,
|
|
51
42
|
validationRequestId: validationRequestId,
|
|
52
43
|
language: language,
|
|
53
44
|
strings: strings,
|
|
@@ -60,10 +51,7 @@ AddressLookup.propTypes = {
|
|
|
60
51
|
onAddressSelect: _propTypes.default.func,
|
|
61
52
|
country: _propTypes.default.string,
|
|
62
53
|
address: _componentPropTypes.addressPropType,
|
|
63
|
-
entryMode: _propTypes.default.oneOf(['both', 'autocomplete', 'manual']),
|
|
64
|
-
requireValidation: _propTypes.default.bool,
|
|
65
54
|
readOnlyView: _propTypes.default.bool,
|
|
66
|
-
showManualValidateButton: _propTypes.default.bool,
|
|
67
55
|
validationRequestId: _propTypes.default.number,
|
|
68
56
|
language: _propTypes.default.string,
|
|
69
57
|
strings: _componentPropTypes.labelStringsPropType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddressLookup.js","names":["_propTypes","_interopRequireDefault","require","_SmartyUSResults","_SmartyIntlResults","_componentPropTypes","_jsxRuntime","e","__esModule","default","AddressLookup","onAddressSelect","country","address","
|
|
1
|
+
{"version":3,"file":"AddressLookup.js","names":["_propTypes","_interopRequireDefault","require","_SmartyUSResults","_SmartyIntlResults","_componentPropTypes","_jsxRuntime","e","__esModule","default","AddressLookup","onAddressSelect","country","address","readOnlyView","validationRequestId","language","strings","formDefinition","deferFormLookup","isUS","jsx","className","children","onSelect","initialAddress","countryCode","propTypes","PropTypes","func","string","addressPropType","bool","number","labelStringsPropType","formDefinitionPropType","_default","exports"],"sources":["../../src/addressLookup/AddressLookup.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport './styles/addressLookup.css';\nimport SmartyUSResults from './components/SmartyUSResults';\nimport SmartyIntlResults from './components/SmartyIntlResults';\nimport { addressPropType, formDefinitionPropType, labelStringsPropType } from './utils/componentPropTypes';\n\nconst AddressLookup = ({ \n onAddressSelect, \n country = 'US',\n address = null,\n readOnlyView = false,\n validationRequestId = 0,\n language = 'en',\n strings = null,\n formDefinition = null,\n deferFormLookup = false\n}) => {\n const isUS = country === 'US';\n\n return (\n <div className='ns-address-lookup'>\n {isUS ? (\n <SmartyUSResults \n onSelect={onAddressSelect}\n initialAddress={address}\n readOnlyView={readOnlyView}\n validationRequestId={validationRequestId}\n language={language}\n strings={strings}\n formDefinition={formDefinition}\n deferFormLookup={deferFormLookup}\n />\n ) : (\n <SmartyIntlResults \n countryCode={country}\n onSelect={onAddressSelect}\n initialAddress={address}\n readOnlyView={readOnlyView}\n validationRequestId={validationRequestId}\n language={language}\n strings={strings}\n formDefinition={formDefinition}\n deferFormLookup={deferFormLookup}\n />\n )}\n </div>\n );\n};\n\nAddressLookup.propTypes = {\n onAddressSelect: PropTypes.func,\n country: PropTypes.string,\n address: addressPropType,\n readOnlyView: PropTypes.bool,\n validationRequestId: PropTypes.number,\n language: PropTypes.string,\n strings: labelStringsPropType,\n formDefinition: formDefinitionPropType,\n deferFormLookup: PropTypes.bool\n};\n\nexport default AddressLookup;\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACAA,OAAA;AACA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,kBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAA2G,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE3G,MAAMG,aAAa,GAAGA,CAAC;EACrBC,eAAe;EACfC,OAAO,GAAG,IAAI;EACdC,OAAO,GAAG,IAAI;EACdC,YAAY,GAAG,KAAK;EACpBC,mBAAmB,GAAG,CAAC;EACvBC,QAAQ,GAAG,IAAI;EACfC,OAAO,GAAG,IAAI;EACdC,cAAc,GAAG,IAAI;EACrBC,eAAe,GAAG;AACpB,CAAC,KAAK;EACJ,MAAMC,IAAI,GAAGR,OAAO,KAAK,IAAI;EAE7B,oBACE,IAAAN,WAAA,CAAAe,GAAA;IAAKC,SAAS,EAAC,mBAAmB;IAAAC,QAAA,EAC/BH,IAAI,gBACH,IAAAd,WAAA,CAAAe,GAAA,EAAClB,gBAAA,CAAAM,OAAe;MACde,QAAQ,EAAEb,eAAgB;MAC1Bc,cAAc,EAAEZ,OAAQ;MACxBC,YAAY,EAAEA,YAAa;MAC3BC,mBAAmB,EAAEA,mBAAoB;MACzCC,QAAQ,EAAEA,QAAS;MACnBC,OAAO,EAAEA,OAAQ;MACjBC,cAAc,EAAEA,cAAe;MAC/BC,eAAe,EAAEA;IAAgB,CAClC,CAAC,gBAEF,IAAAb,WAAA,CAAAe,GAAA,EAACjB,kBAAA,CAAAK,OAAiB;MAChBiB,WAAW,EAAEd,OAAQ;MACrBY,QAAQ,EAAEb,eAAgB;MAC1Bc,cAAc,EAAEZ,OAAQ;MACxBC,YAAY,EAAEA,YAAa;MAC3BC,mBAAmB,EAAEA,mBAAoB;MACzCC,QAAQ,EAAEA,QAAS;MACnBC,OAAO,EAAEA,OAAQ;MACjBC,cAAc,EAAEA,cAAe;MAC/BC,eAAe,EAAEA;IAAgB,CAClC;EACF,CACE,CAAC;AAEV,CAAC;AAEDT,aAAa,CAACiB,SAAS,GAAG;EACxBhB,eAAe,EAAEiB,kBAAS,CAACC,IAAI;EAC/BjB,OAAO,EAAEgB,kBAAS,CAACE,MAAM;EACzBjB,OAAO,EAAEkB,mCAAe;EACxBjB,YAAY,EAAEc,kBAAS,CAACI,IAAI;EAC5BjB,mBAAmB,EAAEa,kBAAS,CAACK,MAAM;EACrCjB,QAAQ,EAAEY,kBAAS,CAACE,MAAM;EAC1Bb,OAAO,EAAEiB,wCAAoB;EAC7BhB,cAAc,EAAEiB,0CAAsB;EACtChB,eAAe,EAAES,kBAAS,CAACI;AAC7B,CAAC;AAAC,IAAAI,QAAA,GAAAC,OAAA,CAAA5B,OAAA,GAEaC,aAAa","ignoreList":[]}
|
|
@@ -31,20 +31,20 @@ const stripGeocode = (address = {}) => {
|
|
|
31
31
|
return nextAddress;
|
|
32
32
|
};
|
|
33
33
|
const FIELD_TEST_IDS = {
|
|
34
|
-
address1: 'qa-
|
|
35
|
-
address2: 'qa-
|
|
36
|
-
district: 'qa-address-
|
|
34
|
+
address1: 'qa-address1',
|
|
35
|
+
address2: 'qa-address2',
|
|
36
|
+
district: 'qa-address-county',
|
|
37
37
|
region: 'qa-address-region',
|
|
38
38
|
city: 'qa-address-city',
|
|
39
|
-
postalCode: 'qa-address-
|
|
39
|
+
postalCode: 'qa-address-zip'
|
|
40
40
|
};
|
|
41
41
|
const FIELD_IDS = {
|
|
42
|
-
address1: '
|
|
43
|
-
address2: '
|
|
44
|
-
district: 'address-
|
|
42
|
+
address1: 'qa-address1',
|
|
43
|
+
address2: 'qa-address2',
|
|
44
|
+
district: 'qa-address-county',
|
|
45
45
|
region: 'address-region',
|
|
46
46
|
city: 'address-city',
|
|
47
|
-
postalCode: 'address-
|
|
47
|
+
postalCode: 'qa-address-zip'
|
|
48
48
|
};
|
|
49
49
|
const getFieldTestId = field => FIELD_TEST_IDS[field] || `qa-address-${field}`;
|
|
50
50
|
const getFieldId = field => FIELD_IDS[field] || `address-${field}`;
|
|
@@ -53,10 +53,7 @@ const SmartyIntlResults = ({
|
|
|
53
53
|
countryCode,
|
|
54
54
|
onSelect,
|
|
55
55
|
initialAddress = null,
|
|
56
|
-
entryMode = 'both',
|
|
57
|
-
requireValidation = true,
|
|
58
56
|
readOnlyView = false,
|
|
59
|
-
showManualValidateButton = false,
|
|
60
57
|
validationRequestId = 0,
|
|
61
58
|
language = 'en',
|
|
62
59
|
strings = null,
|
|
@@ -64,7 +61,7 @@ const SmartyIntlResults = ({
|
|
|
64
61
|
deferFormLookup = false
|
|
65
62
|
}) => {
|
|
66
63
|
var _formDefinition$addre;
|
|
67
|
-
const [mode, setMode] = (0, _react.useState)(
|
|
64
|
+
const [mode, setMode] = (0, _react.useState)('autocomplete');
|
|
68
65
|
const [query, setQuery] = (0, _react.useState)('');
|
|
69
66
|
const [selectedAddress, setSelectedAddress] = (0, _react.useState)(null);
|
|
70
67
|
const [selectedIntlAddressId, setSelectedIntlAddressId] = (0, _react.useState)(null);
|
|
@@ -125,14 +122,18 @@ const SmartyIntlResults = ({
|
|
|
125
122
|
} = (0, _useAddressForm.default)(countryCode, shouldLoadAddressForm);
|
|
126
123
|
const providedAddressForm = formDefinition !== null && formDefinition !== void 0 && (_formDefinition$addre = formDefinition.addressElements) !== null && _formDefinition$addre !== void 0 && _formDefinition$addre.length ? formDefinition : null;
|
|
127
124
|
const resolvedAddressForm = providedAddressForm || loadedAddressForm;
|
|
128
|
-
const
|
|
125
|
+
const entryMode = (resolvedAddressForm === null || resolvedAddressForm === void 0 ? void 0 : resolvedAddressForm.entryMode) || 'both';
|
|
126
|
+
const allowValidation = (resolvedAddressForm === null || resolvedAddressForm === void 0 ? void 0 : resolvedAddressForm.validationMode) !== 'disabled' && !readOnlyView;
|
|
129
127
|
const lookupField = (resolvedAddressForm === null || resolvedAddressForm === void 0 ? void 0 : resolvedAddressForm.lookupField) || 'address1';
|
|
128
|
+
(0, _react.useEffect)(() => {
|
|
129
|
+
setMode(entryMode === 'manual' ? 'manual' : 'autocomplete');
|
|
130
|
+
}, [entryMode]);
|
|
130
131
|
const requiredFields = (0, _addressStatus.getRequiredFieldsFromAddressForm)(resolvedAddressForm);
|
|
131
132
|
const hasEmailField = ((resolvedAddressForm === null || resolvedAddressForm === void 0 ? void 0 : resolvedAddressForm.addressElements) || []).some(field => field.field === 'email');
|
|
132
133
|
const hasMapCoordinates = (formData === null || formData === void 0 ? void 0 : formData.latitude) !== undefined && (formData === null || formData === void 0 ? void 0 : formData.longitude) !== undefined;
|
|
133
134
|
const hasLookupValue = Boolean(String((formData === null || formData === void 0 ? void 0 : formData[lookupField]) || '').trim());
|
|
134
135
|
const canAttemptMap = Boolean(!isAutocompleteMode && hasLookupValue || isAutocompleteMode && ['autocomplete', 'verified'].includes(verificationStatus) && hasLookupValue);
|
|
135
|
-
const showMapAction = !readOnlyView && (hasMapCoordinates || canAttemptMap);
|
|
136
|
+
const showMapAction = !readOnlyView && (hasMapCoordinates || allowValidation && canAttemptMap);
|
|
136
137
|
const mapInfoLines = (mapAddressLines.length ? mapAddressLines : [formData.address1, formData.address2, formData.district, [formData.postalCode, formData.city].filter(Boolean).join(' '), formData.region]).filter(Boolean);
|
|
137
138
|
const {
|
|
138
139
|
mapContainerRef,
|
|
@@ -587,7 +588,7 @@ const SmartyIntlResults = ({
|
|
|
587
588
|
}
|
|
588
589
|
};
|
|
589
590
|
const handleValidationSelect = validatedAddress => {
|
|
590
|
-
var _validatedAddress$met, _validatedAddress$met2
|
|
591
|
+
var _validatedAddress$met, _validatedAddress$met2;
|
|
591
592
|
clearServiceErrors({
|
|
592
593
|
lookup: false,
|
|
593
594
|
validation: true,
|
|
@@ -616,7 +617,16 @@ const SmartyIntlResults = ({
|
|
|
616
617
|
latitude: (_validatedAddress$met = validatedAddress.metadata) === null || _validatedAddress$met === void 0 ? void 0 : _validatedAddress$met.latitude,
|
|
617
618
|
longitude: (_validatedAddress$met2 = validatedAddress.metadata) === null || _validatedAddress$met2 === void 0 ? void 0 : _validatedAddress$met2.longitude
|
|
618
619
|
};
|
|
619
|
-
const currentVerificationStatus = (
|
|
620
|
+
const currentVerificationStatus = (_validatedAddress$ana => {
|
|
621
|
+
switch ((_validatedAddress$ana = validatedAddress.analysis) === null || _validatedAddress$ana === void 0 ? void 0 : _validatedAddress$ana.verification_status) {
|
|
622
|
+
case 'Verified':
|
|
623
|
+
return 'verified';
|
|
624
|
+
case 'Partial':
|
|
625
|
+
return 'partial';
|
|
626
|
+
default:
|
|
627
|
+
return 'unverified';
|
|
628
|
+
}
|
|
629
|
+
})();
|
|
620
630
|
const normalizedFormData = buildTrackedAddress(updatedFormData, currentVerificationStatus, 'smarty-intl');
|
|
621
631
|
setShowValidationSuggestions(false);
|
|
622
632
|
setValidationTriggerSource(null);
|
|
@@ -706,7 +716,7 @@ const SmartyIntlResults = ({
|
|
|
706
716
|
setShowMapModal(true);
|
|
707
717
|
return;
|
|
708
718
|
}
|
|
709
|
-
if (!canAttemptMap || validationLoading) {
|
|
719
|
+
if (!allowValidation || !canAttemptMap || validationLoading) {
|
|
710
720
|
return;
|
|
711
721
|
}
|
|
712
722
|
clearServiceErrors({
|
|
@@ -731,7 +741,7 @@ const SmartyIntlResults = ({
|
|
|
731
741
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LocationPinIcon.default, {
|
|
732
742
|
className: "ns-address-lookup__icon"
|
|
733
743
|
})
|
|
734
|
-
}), !isAutocompleteMode && allowValidation &&
|
|
744
|
+
}), !isAutocompleteMode && allowValidation && /*#__PURE__*/(0, _jsxRuntime.jsx)(_foundationUiComponents.NsButton, {
|
|
735
745
|
type: "button",
|
|
736
746
|
onClick: handleValidate,
|
|
737
747
|
disabled: validationLoading || !String(formData[lookupField] || '').trim(),
|
|
@@ -1006,10 +1016,7 @@ SmartyIntlResults.propTypes = {
|
|
|
1006
1016
|
countryCode: _propTypes.default.string.isRequired,
|
|
1007
1017
|
onSelect: _propTypes.default.func,
|
|
1008
1018
|
initialAddress: _componentPropTypes.addressPropType,
|
|
1009
|
-
entryMode: _propTypes.default.oneOf(['both', 'autocomplete', 'manual']),
|
|
1010
|
-
requireValidation: _propTypes.default.bool,
|
|
1011
1019
|
readOnlyView: _propTypes.default.bool,
|
|
1012
|
-
showManualValidateButton: _propTypes.default.bool,
|
|
1013
1020
|
validationRequestId: _propTypes.default.number,
|
|
1014
1021
|
language: _propTypes.default.string,
|
|
1015
1022
|
strings: _componentPropTypes.labelStringsPropType,
|