ordering-ui-react-native 0.24.4 → 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
|
@@ -76,6 +76,8 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
76
76
|
|
|
77
77
|
const [autoCompleteInputFocused, setAutoCompleteInputFocused] = useState(false)
|
|
78
78
|
|
|
79
|
+
const isEmptyField = (key: any, str: any) => isRequiredField && isRequiredField(key) && (!str || str.trim().length === 0)
|
|
80
|
+
|
|
79
81
|
const tagsName = [
|
|
80
82
|
{ icon: theme.images.general.tag_home, value: 'home' },
|
|
81
83
|
{ icon: theme.images.general.tag_building, value: 'office' },
|
|
@@ -349,50 +351,50 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
349
351
|
};
|
|
350
352
|
|
|
351
353
|
const handleChangeAddress = (data: any, details: any) => {
|
|
352
|
-
const addressObj
|
|
353
|
-
|
|
354
|
-
|
|
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
|
-
|
|
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
|
+
};
|
|
396
398
|
|
|
397
399
|
const handleAddressTag = (tag: string) => {
|
|
398
400
|
setAddressTag(tag);
|
|
@@ -497,9 +499,9 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
497
499
|
}, [formState]);
|
|
498
500
|
|
|
499
501
|
useEffect(() => {
|
|
500
|
-
if (formState?.result
|
|
501
|
-
if (formState
|
|
502
|
-
showToast(ToastType.Error, formState.
|
|
502
|
+
if (formState?.result && !formState?.loading) {
|
|
503
|
+
if (formState?.error) {
|
|
504
|
+
showToast(ToastType.Error, formState.error[0]);
|
|
503
505
|
} else {
|
|
504
506
|
showToast(
|
|
505
507
|
ToastType.Success,
|
|
@@ -748,9 +750,9 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
748
750
|
<OInput
|
|
749
751
|
name="internal_number"
|
|
750
752
|
placeholder={t('INTERNAL_NUMBER', 'Internal number')}
|
|
751
|
-
onChange={(
|
|
752
|
-
handleChangeInput(
|
|
753
|
-
setValue('internal_number',
|
|
753
|
+
onChange={(data: any) => {
|
|
754
|
+
handleChangeInput(data);
|
|
755
|
+
setValue('internal_number', isEmptyField('internal_number', data?.target?.value) ? null : data);
|
|
754
756
|
}}
|
|
755
757
|
value={
|
|
756
758
|
address?.internal_number ||
|
|
@@ -795,9 +797,9 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
795
797
|
<OInput
|
|
796
798
|
name="zipcode"
|
|
797
799
|
placeholder={t('ZIP_CODE', 'Zip code')}
|
|
798
|
-
onChange={(
|
|
799
|
-
handleChangeInput(
|
|
800
|
-
setValue('zipcode',
|
|
800
|
+
onChange={(data: any) => {
|
|
801
|
+
handleChangeInput(data);
|
|
802
|
+
setValue('zipcode', isEmptyField('zipcode', data?.target?.value) ? null : data);
|
|
801
803
|
}}
|
|
802
804
|
value={
|
|
803
805
|
address?.zipcode ||
|