ordering-ui-react-native 0.18.57 → 0.18.58-test1
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 +1 -1
- package/themes/original/src/components/AddressForm/index.tsx +20 -3
- package/themes/original/src/components/Cart/index.tsx +7 -3
- package/themes/original/src/components/GPSButton/index.tsx +64 -3
- package/themes/original/src/components/GoogleMap/index.tsx +4 -2
- package/themes/original/src/components/OrderSummary/index.tsx +9 -3
- package/themes/original/src/types/index.tsx +2 -1
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
Keyboard,
|
|
7
7
|
TouchableWithoutFeedback,
|
|
8
8
|
Platform,
|
|
9
|
+
Text,
|
|
9
10
|
} from 'react-native';
|
|
10
11
|
import {
|
|
11
12
|
AddressForm as AddressFormController,
|
|
@@ -123,7 +124,7 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
123
124
|
},
|
|
124
125
|
wrapperNavbar: Platform.OS === 'ios'
|
|
125
126
|
? { paddingVertical: 0, paddingLeft: 40, paddingRight: 20 }
|
|
126
|
-
: { paddingVertical:
|
|
127
|
+
: { paddingVertical: 10, paddingLeft: 40, paddingRight: 20 }
|
|
127
128
|
});
|
|
128
129
|
|
|
129
130
|
const [, t] = useLanguage();
|
|
@@ -145,6 +146,7 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
145
146
|
address: null,
|
|
146
147
|
});
|
|
147
148
|
const [isFirstTime, setIsFirstTime] = useState(true);
|
|
149
|
+
const [errorState, setErrorState] = useState({});
|
|
148
150
|
const [locationChange, setLocationChange] = useState(
|
|
149
151
|
isEditing
|
|
150
152
|
? addressState?.address?.location
|
|
@@ -176,7 +178,6 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
176
178
|
|
|
177
179
|
const getAddressFormatted = (address: any) => {
|
|
178
180
|
const data: any = { address: null, error: null };
|
|
179
|
-
Geocoder.init(googleMapsApiKey);
|
|
180
181
|
Geocoder.from(address)
|
|
181
182
|
.then((json) => {
|
|
182
183
|
if (json.results && json.results?.length > 0) {
|
|
@@ -345,6 +346,10 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
345
346
|
};
|
|
346
347
|
|
|
347
348
|
const handleChangeAddress = (data: any, details: any) => {
|
|
349
|
+
setErrorState({
|
|
350
|
+
...errorState,
|
|
351
|
+
handleChangeAddress: {data: data, details: details}
|
|
352
|
+
})
|
|
348
353
|
const addressSelected = {
|
|
349
354
|
address: data?.description || data?.address,
|
|
350
355
|
location: details?.geometry?.location,
|
|
@@ -491,6 +496,10 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
491
496
|
}
|
|
492
497
|
}, []);
|
|
493
498
|
|
|
499
|
+
useEffect(() => {
|
|
500
|
+
Geocoder.init(googleMapsApiKey);
|
|
501
|
+
}, [googleMapsApiKey]);
|
|
502
|
+
|
|
494
503
|
useEffect(() => {
|
|
495
504
|
const keyboardDidShowListener = Keyboard.addListener(
|
|
496
505
|
'keyboardDidShow',
|
|
@@ -535,7 +544,7 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
535
544
|
/>
|
|
536
545
|
</View>
|
|
537
546
|
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
|
|
538
|
-
<AddressFormContainer style={{
|
|
547
|
+
<AddressFormContainer style={{ overflow: 'scroll' }}>
|
|
539
548
|
<View>
|
|
540
549
|
<FormInput>
|
|
541
550
|
<AutocompleteInput>
|
|
@@ -640,6 +649,9 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
640
649
|
}
|
|
641
650
|
}}
|
|
642
651
|
IconButton={<OIcon src={theme.images.general.pin} width={16} />}
|
|
652
|
+
isIntGeoCoder
|
|
653
|
+
errorState={errorState}
|
|
654
|
+
setErrorState={setErrorState}
|
|
643
655
|
/>
|
|
644
656
|
</View>
|
|
645
657
|
)}
|
|
@@ -661,6 +673,7 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
661
673
|
saveLocation={saveMapLocation}
|
|
662
674
|
setSaveLocation={setSaveMapLocation}
|
|
663
675
|
handleToggleMap={handleToggleMap}
|
|
676
|
+
isIntGeoCoder
|
|
664
677
|
/>
|
|
665
678
|
</GoogleMapContainer>
|
|
666
679
|
</View>
|
|
@@ -803,6 +816,9 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
803
816
|
/>
|
|
804
817
|
)}
|
|
805
818
|
</FormInput>
|
|
819
|
+
<Text>
|
|
820
|
+
{JSON.stringify(errorState)}
|
|
821
|
+
</Text>
|
|
806
822
|
{!isHideIcons && (
|
|
807
823
|
<IconsContainer>
|
|
808
824
|
{tagsName.map((tag) => (
|
|
@@ -871,6 +887,7 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
871
887
|
saveLocation={saveMapLocation}
|
|
872
888
|
setSaveLocation={setSaveMapLocation}
|
|
873
889
|
handleToggleMap={handleToggleMap}
|
|
890
|
+
isIntGeoCoder
|
|
874
891
|
/>
|
|
875
892
|
</GoogleMapContainer>
|
|
876
893
|
)}
|
|
@@ -281,7 +281,9 @@ const CartUI = (props: any) => {
|
|
|
281
281
|
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
|
|
282
282
|
<AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
|
|
283
283
|
</TouchableOpacity>
|
|
284
|
-
|
|
284
|
+
{!!offer?.id && (
|
|
285
|
+
<OfferAlert offerId={offer?.id} />
|
|
286
|
+
)}
|
|
285
287
|
</OSRow>
|
|
286
288
|
<OText size={12} lineHeight={18}>
|
|
287
289
|
- {parsePrice(offer?.summary?.discount)}
|
|
@@ -343,7 +345,7 @@ const CartUI = (props: any) => {
|
|
|
343
345
|
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
|
|
344
346
|
<AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
|
|
345
347
|
</TouchableOpacity>
|
|
346
|
-
{!offer?.type && (
|
|
348
|
+
{!offer?.type && !!offer?.id && (
|
|
347
349
|
<OfferAlert offerId={offer?.id} />
|
|
348
350
|
)}
|
|
349
351
|
</OSRow>
|
|
@@ -370,7 +372,9 @@ const CartUI = (props: any) => {
|
|
|
370
372
|
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
|
|
371
373
|
<AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
|
|
372
374
|
</TouchableOpacity>
|
|
373
|
-
|
|
375
|
+
{!!offer?.id && (
|
|
376
|
+
<OfferAlert offerId={offer?.id} />
|
|
377
|
+
)}
|
|
374
378
|
</OSRow>
|
|
375
379
|
<OText size={12} lineHeight={18}>
|
|
376
380
|
- {parsePrice(offer?.summary?.discount)}
|
|
@@ -3,6 +3,14 @@ import Geocoder from 'react-native-geocoding'
|
|
|
3
3
|
import { ActivityIndicator } from 'react-native-paper'
|
|
4
4
|
import Geolocation from '@react-native-community/geolocation'
|
|
5
5
|
import { getTrackingStatus, requestTrackingPermission } from 'react-native-tracking-transparency'
|
|
6
|
+
import { Platform } from 'react-native'
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
PERMISSIONS,
|
|
10
|
+
PermissionStatus,
|
|
11
|
+
request,
|
|
12
|
+
openSettings,
|
|
13
|
+
} from 'react-native-permissions';
|
|
6
14
|
|
|
7
15
|
import { OText } from '../shared'
|
|
8
16
|
import { GpsButtonStyle } from './styles'
|
|
@@ -12,7 +20,10 @@ export const GPSButton = (props: any) => {
|
|
|
12
20
|
handleGPS,
|
|
13
21
|
apiKey,
|
|
14
22
|
IconButton,
|
|
15
|
-
IconLoadingButton
|
|
23
|
+
IconLoadingButton,
|
|
24
|
+
isIntGeoCoder,
|
|
25
|
+
errorState,
|
|
26
|
+
setErrorState
|
|
16
27
|
} = props
|
|
17
28
|
|
|
18
29
|
const [isLoading, setLoading] = useState(false);
|
|
@@ -22,6 +33,10 @@ export const GPSButton = (props: any) => {
|
|
|
22
33
|
latitude: pos.latitude,
|
|
23
34
|
longitude: pos.longitude
|
|
24
35
|
}).then(({ results }: any) => {
|
|
36
|
+
setErrorState({
|
|
37
|
+
...errorState,
|
|
38
|
+
geoCodePosition: results
|
|
39
|
+
})
|
|
25
40
|
let zipcode = null
|
|
26
41
|
if (results && results.length > 0) {
|
|
27
42
|
for (const component of results[0].address_components) {
|
|
@@ -31,7 +46,7 @@ export const GPSButton = (props: any) => {
|
|
|
31
46
|
break
|
|
32
47
|
}
|
|
33
48
|
}
|
|
34
|
-
let data
|
|
49
|
+
let data : any
|
|
35
50
|
const details = {
|
|
36
51
|
geometry: { location: { lat: pos.latitude, lng: pos.longitude } }
|
|
37
52
|
}
|
|
@@ -51,6 +66,10 @@ export const GPSButton = (props: any) => {
|
|
|
51
66
|
setLoading(false);
|
|
52
67
|
}).catch((err: any) => {
|
|
53
68
|
console.log(err);
|
|
69
|
+
setErrorState({
|
|
70
|
+
...errorState,
|
|
71
|
+
fallbackGeoCodePosition: err
|
|
72
|
+
})
|
|
54
73
|
setLoading(false);
|
|
55
74
|
})
|
|
56
75
|
}
|
|
@@ -60,22 +79,64 @@ export const GPSButton = (props: any) => {
|
|
|
60
79
|
if (trackingStatus === 'not-determined') {
|
|
61
80
|
trackingStatus = await requestTrackingPermission()
|
|
62
81
|
}
|
|
82
|
+
setErrorState({
|
|
83
|
+
...errorState,
|
|
84
|
+
trackingStatus: trackingStatus
|
|
85
|
+
})
|
|
63
86
|
if (trackingStatus === 'authorized' || trackingStatus === 'unavailable') {
|
|
64
87
|
setLoading(true)
|
|
65
88
|
Geolocation.getCurrentPosition((pos) => {
|
|
89
|
+
setErrorState({
|
|
90
|
+
...errorState,
|
|
91
|
+
getCurrentPosition: pos
|
|
92
|
+
})
|
|
66
93
|
geoCodePosition(pos.coords)
|
|
67
94
|
}, (err) => {
|
|
95
|
+
setErrorState({
|
|
96
|
+
...errorState,
|
|
97
|
+
fallbackGetCurrentPosition: err
|
|
98
|
+
})
|
|
68
99
|
setLoading(false);
|
|
69
100
|
console.log(`ERROR(${err.code}): ${err.message}`)
|
|
70
101
|
}, {
|
|
71
102
|
enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
|
|
72
103
|
})
|
|
104
|
+
return
|
|
73
105
|
}
|
|
106
|
+
let permissionStatus: PermissionStatus;
|
|
107
|
+
setLoading(true)
|
|
108
|
+
if (Platform.OS === 'ios') {
|
|
109
|
+
permissionStatus = await request(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE);
|
|
110
|
+
} else {
|
|
111
|
+
permissionStatus = await request(
|
|
112
|
+
PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION,
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
if (permissionStatus === 'denied') {
|
|
116
|
+
openSettings();
|
|
117
|
+
}
|
|
118
|
+
Geolocation.getCurrentPosition((pos) => {
|
|
119
|
+
setErrorState({
|
|
120
|
+
...errorState,
|
|
121
|
+
getCurrentPositionNew: pos
|
|
122
|
+
})
|
|
123
|
+
geoCodePosition(pos.coords)
|
|
124
|
+
}, (err) => {
|
|
125
|
+
setErrorState({
|
|
126
|
+
...errorState,
|
|
127
|
+
fallbackGetCurrentPositionNew: err
|
|
128
|
+
})
|
|
129
|
+
setLoading(false);
|
|
130
|
+
console.log(`ERROR(${err.code}): ${err.message}`)
|
|
131
|
+
}, {
|
|
132
|
+
enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
|
|
133
|
+
})
|
|
74
134
|
}
|
|
75
135
|
|
|
76
136
|
useEffect(() => {
|
|
137
|
+
if (isIntGeoCoder) return
|
|
77
138
|
Geocoder.init(apiKey);
|
|
78
|
-
}, [])
|
|
139
|
+
}, [isIntGeoCoder])
|
|
79
140
|
|
|
80
141
|
return (
|
|
81
142
|
<GpsButtonStyle
|
|
@@ -18,7 +18,8 @@ export const GoogleMap = (props: GoogleMapsParams) => {
|
|
|
18
18
|
saveLocation,
|
|
19
19
|
setSaveLocation,
|
|
20
20
|
handleToggleMap,
|
|
21
|
-
locations
|
|
21
|
+
locations,
|
|
22
|
+
isIntGeoCoder
|
|
22
23
|
} = props
|
|
23
24
|
|
|
24
25
|
const [, t] = useLanguage()
|
|
@@ -161,8 +162,9 @@ export const GoogleMap = (props: GoogleMapsParams) => {
|
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
useEffect(() => {
|
|
165
|
+
if (isIntGeoCoder) return
|
|
164
166
|
Geocoder.init(googleMapsApiKey)
|
|
165
|
-
}, [])
|
|
167
|
+
}, [isIntGeoCoder])
|
|
166
168
|
|
|
167
169
|
useEffect(() => {
|
|
168
170
|
mapRef.current.animateToRegion({
|
|
@@ -169,7 +169,9 @@ const OrderSummaryUI = (props: any) => {
|
|
|
169
169
|
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
|
|
170
170
|
<AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
|
|
171
171
|
</TouchableOpacity>
|
|
172
|
-
|
|
172
|
+
{!!offer?.id && (
|
|
173
|
+
<OfferAlert offerId={offer?.id} />
|
|
174
|
+
)}
|
|
173
175
|
</OSRow>
|
|
174
176
|
<OText size={12}>
|
|
175
177
|
- {parsePrice(offer?.summary?.discount)}
|
|
@@ -233,7 +235,9 @@ const OrderSummaryUI = (props: any) => {
|
|
|
233
235
|
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
|
|
234
236
|
<AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
|
|
235
237
|
</TouchableOpacity>
|
|
236
|
-
|
|
238
|
+
{!!offer?.id && (
|
|
239
|
+
<OfferAlert offerId={offer?.id} />
|
|
240
|
+
)}
|
|
237
241
|
</OSRow>
|
|
238
242
|
<OText size={12}>
|
|
239
243
|
- {parsePrice(offer?.summary?.discount)}
|
|
@@ -258,7 +262,9 @@ const OrderSummaryUI = (props: any) => {
|
|
|
258
262
|
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
|
|
259
263
|
<AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
|
|
260
264
|
</TouchableOpacity>
|
|
261
|
-
|
|
265
|
+
{!!offer?.id && (
|
|
266
|
+
<OfferAlert offerId={offer?.id} />
|
|
267
|
+
)}
|
|
262
268
|
</OSRow>
|
|
263
269
|
<OText size={12}>
|
|
264
270
|
- {parsePrice(offer?.summary?.discount)}
|
|
@@ -629,7 +629,8 @@ export interface GoogleMapsParams {
|
|
|
629
629
|
isSetInputs?: boolean,
|
|
630
630
|
locations?: Array<any>,
|
|
631
631
|
setSaveLocation?: (val: boolean) => void,
|
|
632
|
-
handleToggleMap?: () => void
|
|
632
|
+
handleToggleMap?: () => void,
|
|
633
|
+
isIntGeoCoder: boolean
|
|
633
634
|
}
|
|
634
635
|
|
|
635
636
|
export interface HelpParams {
|