ordering-ui-react-native 0.24.1 → 0.24.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.24.1",
3
+ "version": "0.24.2",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -349,15 +349,50 @@ const AddressFormUI = (props: AddressFormParams) => {
349
349
  };
350
350
 
351
351
  const handleChangeAddress = (data: any, details: any) => {
352
- const addressSelected = {
353
- address: data?.description || data?.address,
354
- location: details?.geometry?.location,
355
- utc_offset: details?.utc_offset || null,
356
- map_data: { library: 'google', place_id: data.place_id },
357
- zip_code: data?.zip_code || null,
358
- };
359
- updateChanges(addressSelected);
360
- };
352
+ const addressObj : any = {}
353
+ if (details?.address_components) {
354
+ details.address_components.map((component: any) => {
355
+ const addressType = component.types[0]
356
+ if (addressType === 'postal_code') {
357
+ addressObj.zipcode = component.short_name
358
+ }
359
+ if (addressType === 'street_number') {
360
+ addressObj.street_number = component.long_name
361
+ }
362
+ if (addressType === 'neighborhood') {
363
+ addressObj.neighborhood = component.long_name
364
+ }
365
+ if (addressType === 'route') {
366
+ addressObj.route = component.short_name
367
+ }
368
+ if (addressType === 'locality') {
369
+ addressObj.locality = component.long_name
370
+ }
371
+ if (component.types?.includes('sublocality')) {
372
+ addressObj.sublocality = component.long_name
373
+ }
374
+ if (addressType === 'country') {
375
+ addressObj.country = component.long_name
376
+ addressObj.country_code = component.short_name
377
+ }
378
+ if (addressType === 'administrative_area_level_1') {
379
+ addressObj.state = component.long_name
380
+ }
381
+ if (addressType === 'administrative_area_level_2') {
382
+ addressObj.city = component.long_name
383
+ }
384
+ })
385
+ }
386
+ const addressSelected = {
387
+ address: data?.description || data?.address,
388
+ location: details?.geometry?.location,
389
+ utc_offset: details?.utc_offset || null,
390
+ map_data: { library: 'google', place_id: data.place_id },
391
+ zipcode: data?.zipcode || null,
392
+ ...addressObj
393
+ };
394
+ updateChanges(addressSelected);
395
+ };
361
396
 
362
397
  const handleAddressTag = (tag: string) => {
363
398
  setAddressTag(tag);
@@ -34,7 +34,8 @@ export const GPSButton = (props: any) => {
34
34
  }
35
35
  let data : any
36
36
  const details = {
37
- geometry: { location: { lat: pos.latitude, lng: pos.longitude } }
37
+ geometry: { location: { lat: pos.latitude, lng: pos.longitude } },
38
+ address_components: results[0]?.address_components
38
39
  }
39
40
  // if (isSetInputs) {
40
41
  data = {
@@ -82,7 +82,8 @@ export const GoogleMap = (props: GoogleMapsParams) => {
82
82
  place_id: results[0]?.place_id,
83
83
  }
84
84
  const details = {
85
- geometry: { location: { lat: pos.latitude, lng: pos.longitude } }
85
+ geometry: { location: { lat: pos.latitude, lng: pos.longitude } },
86
+ address_components: results[0]?.address_components,
86
87
  }
87
88
  handleChangeAddressMap && handleChangeAddressMap(address, details)
88
89
  setSaveLocation && setSaveLocation(false)