ordering-ui-react-native 0.24.5 → 0.24.6
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/package.json
CHANGED
|
@@ -351,50 +351,50 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
351
351
|
};
|
|
352
352
|
|
|
353
353
|
const handleChangeAddress = (data: any, details: any) => {
|
|
354
|
-
const addressObj
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
354
|
+
const addressObj: any = {}
|
|
355
|
+
if (details?.address_components) {
|
|
356
|
+
details.address_components.map((component: any) => {
|
|
357
|
+
const addressType = component.types[0]
|
|
358
|
+
if (addressType === 'postal_code') {
|
|
359
|
+
addressObj.zipcode = component.short_name
|
|
360
|
+
}
|
|
361
|
+
if (addressType === 'street_number') {
|
|
362
|
+
addressObj.street_number = component.long_name
|
|
363
|
+
}
|
|
364
|
+
if (addressType === 'neighborhood') {
|
|
365
|
+
addressObj.neighborhood = component.long_name
|
|
366
|
+
}
|
|
367
|
+
if (addressType === 'route') {
|
|
368
|
+
addressObj.route = component.short_name
|
|
369
|
+
}
|
|
370
|
+
if (addressType === 'locality') {
|
|
371
|
+
addressObj.locality = component.long_name
|
|
372
|
+
}
|
|
373
|
+
if (component.types?.includes('sublocality')) {
|
|
374
|
+
addressObj.sublocality = component.long_name
|
|
375
|
+
}
|
|
376
|
+
if (addressType === 'country') {
|
|
377
|
+
addressObj.country = component.long_name
|
|
378
|
+
addressObj.country_code = component.short_name
|
|
379
|
+
}
|
|
380
|
+
if (addressType === 'administrative_area_level_1') {
|
|
381
|
+
addressObj.state = component.long_name
|
|
382
|
+
}
|
|
383
|
+
if (addressType === 'administrative_area_level_2') {
|
|
384
|
+
addressObj.city = component.long_name
|
|
385
|
+
}
|
|
386
|
+
})
|
|
387
|
+
}
|
|
388
|
+
const addressSelected = {
|
|
389
|
+
address: data?.description || data?.address,
|
|
390
|
+
location: details?.geometry?.location,
|
|
391
|
+
utc_offset: details?.utc_offset || null,
|
|
392
|
+
map_data: { library: 'google', place_id: data.place_id },
|
|
393
|
+
zipcode: data?.zipcode || null,
|
|
394
|
+
...addressObj
|
|
395
|
+
};
|
|
396
|
+
updateChanges(addressSelected);
|
|
397
|
+
};
|
|
398
398
|
|
|
399
399
|
const handleAddressTag = (tag: string) => {
|
|
400
400
|
setAddressTag(tag);
|
|
@@ -499,9 +499,9 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
499
499
|
}, [formState]);
|
|
500
500
|
|
|
501
501
|
useEffect(() => {
|
|
502
|
-
if (formState?.result
|
|
503
|
-
if (formState
|
|
504
|
-
showToast(ToastType.Error, formState.
|
|
502
|
+
if (formState?.result && !formState?.loading) {
|
|
503
|
+
if (formState?.error) {
|
|
504
|
+
showToast(ToastType.Error, formState.error[0]);
|
|
505
505
|
} else {
|
|
506
506
|
showToast(
|
|
507
507
|
ToastType.Success,
|