ordering-ui-react-native 0.22.39 → 0.22.40

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.22.39",
3
+ "version": "0.22.40",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -69,11 +69,20 @@ export const DriverMap = (props: GoogleMapsParams) => {
69
69
  stopFollowUserLocation,
70
70
  } = useLocation();
71
71
 
72
- const origin = {
73
- latitude: initialPosition.latitude,
74
- longitude: initialPosition.longitude,
72
+ const destination = {
73
+ latitude: typeof location?.lat === 'string' ? parseFloat(location?.lat) || 0 : location?.lat || 0,
74
+ longitude: typeof location?.lng === 'string' ? parseFloat(location?.lng) || 0 : location?.lng || 0
75
75
  };
76
- const destination = { latitude: location.lat, longitude: location.lng };
76
+
77
+ const parsedInitialPosition = {
78
+ latitude: typeof initialPosition.latitude === 'string' ? parseFloat(initialPosition.latitude) || 0 : initialPosition.latitude || 0,
79
+ longitude: typeof initialPosition.longitude === 'string' ? parseFloat(initialPosition.longitude) || 0 : initialPosition.longitude || 0,
80
+ }
81
+
82
+ const parsedUserLocation = {
83
+ latitude: typeof userLocation?.latitude === 'string' ? parseFloat(userLocation?.latitude) || 0 : userLocation?.latitude || 0,
84
+ longitude: typeof userLocation?.longitude === 'string' ? parseFloat(userLocation?.longitude) || 0 : userLocation?.longitude || 0
85
+ }
77
86
 
78
87
  useEffect(() => {
79
88
  if (isToFollow) {
@@ -161,7 +170,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
161
170
  if (driverUpdateLocation.error) return;
162
171
 
163
172
  calculateDistance(
164
- { lat: userLocation.latitude, lng: userLocation.longitude },
173
+ { lat: parsedUserLocation.latitude, lng: parsedUserLocation.longitude },
165
174
  destination,
166
175
  );
167
176
  // geocodePosition(userLocation);
@@ -169,13 +178,13 @@ export const DriverMap = (props: GoogleMapsParams) => {
169
178
  if (!following.current) return;
170
179
  fitCoordinates();
171
180
 
172
- const { latitude, longitude } = userLocation;
181
+ const { latitude, longitude } = parsedUserLocation;
173
182
 
174
183
  mapRef.current?.animateCamera({
175
184
  center: { latitude, longitude },
176
185
  });
177
186
 
178
- }, [userLocation]);
187
+ }, [parsedUserLocation]);
179
188
 
180
189
  const handleArrowBack: any = () => {
181
190
  setDriverUpdateLocation?.({
@@ -241,8 +250,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
241
250
  [
242
251
  { latitude: location.lat, longitude: location.lng },
243
252
  {
244
- latitude: initialPosition.latitude,
245
- longitude: initialPosition.longitude,
253
+ latitude: parsedInitialPosition.latitude,
254
+ longitude: parsedInitialPosition.longitude,
246
255
  },
247
256
  ],
248
257
  {
@@ -255,7 +264,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
255
264
 
256
265
  useEffect(() => {
257
266
  const interval = setInterval(() => {
258
- if (initialPosition.latitude !== 0 && autoFit.current) {
267
+ if (parsedInitialPosition.latitude !== 0 && autoFit.current) {
259
268
  if (mapRef.current) {
260
269
  fitCoordinates();
261
270
  autoFit.current = false;
@@ -263,7 +272,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
263
272
  }
264
273
  }, 1000);
265
274
  return () => clearInterval(interval);
266
- }, [initialPosition]);
275
+ }, [parsedInitialPosition]);
267
276
 
268
277
  const fitCoordinatesZoom = () => {
269
278
  following.current = false;
@@ -346,8 +355,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
346
355
  ref={mapRef}
347
356
  provider={PROVIDER_GOOGLE}
348
357
  initialRegion={{
349
- latitude: initialPosition.latitude,
350
- longitude: initialPosition.longitude,
358
+ latitude: parsedInitialPosition.latitude,
359
+ longitude: parsedInitialPosition.longitude,
351
360
  latitudeDelta: 0.001,
352
361
  longitudeDelta: 0.001 * ASPECT_RATIO,
353
362
  }}
@@ -369,8 +378,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
369
378
  <>
370
379
  <Marker
371
380
  coordinate={{
372
- latitude: location.lat,
373
- longitude: location.lng,
381
+ latitude: destination.latitude,
382
+ longitude: destination.longitude
374
383
  }}
375
384
  title={location.title}>
376
385
  <Icon
@@ -387,7 +396,10 @@ export const DriverMap = (props: GoogleMapsParams) => {
387
396
  />
388
397
  </View>
389
398
  </Marker>
390
- <Marker coordinate={userLocation}>
399
+ <Marker coordinate={{
400
+ latitude: parsedUserLocation.latitude,
401
+ longitude: parsedUserLocation.longitude
402
+ }}>
391
403
  <View style={styles.driverIcon}>
392
404
  <OIcon
393
405
  style={styles.image}
@@ -401,8 +413,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
401
413
  ) : (
402
414
  <Marker
403
415
  coordinate={{
404
- latitude: userLocation.latitude,
405
- longitude: userLocation.longitude,
416
+ latitude: parsedUserLocation.latitude,
417
+ longitude: parsedUserLocation.longitude
406
418
  }}
407
419
  title={markerTitle || t('YOUR_LOCATION', 'Your Location')}
408
420
  />
@@ -516,8 +528,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
516
528
  options={{
517
529
  latitude: destination.latitude,
518
530
  longitude: destination.longitude,
519
- sourceLatitude: userLocation.latitude,
520
- sourceLongitude: userLocation.longitude,
531
+ sourceLatitude: parsedUserLocation.latitude,
532
+ sourceLongitude: parsedUserLocation.longitude,
521
533
  naverCallerName: 'com.deliveryapp',
522
534
  dialogTitle: t('SHOW_IN_OTHER_MAPS', 'Show in other maps'),
523
535
  dialogMessage: t('WHAT_APP_WOULD_YOU_USE', 'What app would you like to use?'),
@@ -539,7 +551,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
539
551
  secondButton={true}
540
552
  firstColorCustom={theme.colors.red}
541
553
  secondColorCustom={theme.colors.green}
542
- widthButton={isHideRejectButtons ? '100%': '45%'}
554
+ widthButton={isHideRejectButtons ? '100%' : '45%'}
543
555
  isPadding
544
556
  isHideRejectButtons={isHideRejectButtons}
545
557
  />
@@ -50,12 +50,16 @@ export const GoogleMap = (props: GoogleMapsParams) => {
50
50
  const ASPECT_RATIO = width / height;
51
51
  const [isMapReady, setIsMapReady] = useState(false);
52
52
  const [markerPosition, setMarkerPosition] = useState({
53
- latitude: locations ? locations[locations.length - 1].lat : location.lat,
54
- longitude: locations ? locations[locations.length - 1].lng : location.lng,
53
+ latitude: locations
54
+ ? typeof locations[locations.length - 1].lat === 'string' ? parseFloat(locations[locations.length - 1].lat) || 0 : locations[locations.length - 1].lat || 0
55
+ : typeof location?.lat === 'string' ? parseFloat(location?.lat) || 0 : location?.lat || 0,
56
+ longitude: locations
57
+ ? typeof locations[locations.length - 1].lng === 'string' ? parseFloat(locations[locations.length - 1].lng) || 0 : locations[locations.length - 1].lng || 0
58
+ : typeof location?.lng === 'string' ? parseFloat(location?.lng) || 0 : location?.lng || 0,
55
59
  });
56
60
  const [region, setRegion] = useState({
57
- latitude: location.lat,
58
- longitude: location.lng,
61
+ latitude: typeof location?.lat === 'string' ? parseFloat(location?.lat) || 0 : location?.lat || 0,
62
+ longitude: typeof location?.lng === 'string' ? parseFloat(location?.lng) || 0 : location?.lng || 0,
59
63
  latitudeDelta: 0.001,
60
64
  longitudeDelta: 0.001 * ASPECT_RATIO,
61
65
  });
@@ -78,12 +82,15 @@ export const GoogleMap = (props: GoogleMapsParams) => {
78
82
  let MARKERS =
79
83
  locations &&
80
84
  locations.map((location: { lat: number; lng: number; level: number }) => {
81
- return location.level === 4 && driverLocation?.lat
85
+ return location.level === 4 && driverLocation?.lat && driverLocation?.lng
82
86
  ? {
83
- latitude: driverLocation?.lat,
84
- longitude: driverLocation?.lng,
87
+ latitude: typeof driverLocation?.lat === 'string' ? parseFloat(driverLocation?.lat) || 0 : driverLocation?.lat,
88
+ longitude: typeof driverLocation?.lng === 'string' ? parseFloat(driverLocation?.lng) || 0 : driverLocation?.lng,
85
89
  }
86
- : { latitude: location.lat, longitude: location.lng };
90
+ : {
91
+ latitude: typeof location?.lat === 'string' ? parseFloat(location?.lat) || 0 : location?.lat,
92
+ longitude: typeof location?.lng === 'string' ? parseFloat(location?.lng) || 0 : location?.lng
93
+ };
87
94
  });
88
95
 
89
96
  const handleArrowBack: any = () => {
@@ -182,7 +182,7 @@ const PromotionsUI = (props: PromotionParams) => {
182
182
  title={``}
183
183
  onClose={() => setOpenModal(false)}
184
184
  >
185
- <View style={{ padding: 20 }}>
185
+ <ScrollView style={{ padding: 20 }}>
186
186
  <OText style={{ alignSelf: 'center', fontWeight: '700' }} mBottom={20}>
187
187
  {offerSelected?.name} / {t('VALUE_OF_OFFER', 'Value of offer')}: {offerSelected?.rate_type === 1 ? `${offerSelected?.rate}%` : `${parsePrice(offerSelected?.rate)}`}
188
188
  </OText>
@@ -210,10 +210,7 @@ const PromotionsUI = (props: PromotionParams) => {
210
210
  <OText style={{ marginTop: 10, marginBottom: 10 }}>
211
211
  {t('AVAILABLE_BUSINESSES_FOR_OFFER', 'Available businesses for this offer')}:
212
212
  </OText>
213
- <ScrollView
214
- showsVerticalScrollIndicator={false}
215
- style={{ height: '68%' }}
216
- >
213
+ <View style={{ marginBottom: 70 }}>
217
214
  {offerSelected?.businesses?.map((business: any) => {
218
215
  return (
219
216
  <SingleBusinessOffer key={business.id}>
@@ -244,8 +241,8 @@ const PromotionsUI = (props: PromotionParams) => {
244
241
  </SingleBusinessOffer>
245
242
  )
246
243
  })}
247
- </ScrollView>
248
- </View>
244
+ </View>
245
+ </ScrollView>
249
246
  </OModal>
250
247
  </PromotionsContainer>
251
248
  </Container>