ordering-ui-react-native 0.22.98 → 0.23.0

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.98",
3
+ "version": "0.23.0",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -69,15 +69,12 @@ export const DriverMap = (props: GoogleMapsParams) => {
69
69
  stopFollowUserLocation,
70
70
  } = useLocation();
71
71
 
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
- };
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
- }
72
+ const parsedInitialPosition = useCallback(() => {
73
+ return {
74
+ latitude: typeof initialPosition.latitude === 'string' ? parseFloat(initialPosition.latitude) || 0 : initialPosition.latitude || 0,
75
+ longitude: typeof initialPosition.longitude === 'string' ? parseFloat(initialPosition.longitude) || 0 : initialPosition.longitude || 0,
76
+ }
77
+ }, [JSON.stringify(initialPosition)])
81
78
 
82
79
  const parsedUserLocation = useCallback(() => {
83
80
  return {
@@ -86,6 +83,13 @@ export const DriverMap = (props: GoogleMapsParams) => {
86
83
  }
87
84
  }, [JSON.stringify(userLocation)])
88
85
 
86
+ const parsedDestination = useCallback(() => {
87
+ return {
88
+ latitude: typeof location?.lat === 'string' ? parseFloat(location?.lat) || 0 : location?.lat || 0,
89
+ longitude: typeof location?.lng === 'string' ? parseFloat(location?.lng) || 0 : location?.lng || 0
90
+ }
91
+ }, [JSON.stringify(location)])
92
+
89
93
  useEffect(() => {
90
94
  if (isToFollow) {
91
95
  fitCoordinates();
@@ -172,8 +176,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
172
176
  if (driverUpdateLocation.error) return;
173
177
 
174
178
  calculateDistance(
175
- { lat: parsedUserLocation().latitude, lng: parsedUserLocation().longitude },
176
- destination,
179
+ { lat: parsedUserLocation()?.latitude, lng: parsedUserLocation()?.longitude },
180
+ parsedDestination(),
177
181
  );
178
182
  // geocodePosition(userLocation);
179
183
 
@@ -252,8 +256,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
252
256
  [
253
257
  { latitude: location.lat, longitude: location.lng },
254
258
  {
255
- latitude: parsedInitialPosition.latitude,
256
- longitude: parsedInitialPosition.longitude,
259
+ latitude: parsedInitialPosition()?.latitude,
260
+ longitude: parsedInitialPosition()?.longitude,
257
261
  },
258
262
  ],
259
263
  {
@@ -266,7 +270,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
266
270
 
267
271
  useEffect(() => {
268
272
  const interval = setInterval(() => {
269
- if (parsedInitialPosition.latitude !== 0 && autoFit.current) {
273
+ if (parsedInitialPosition()?.latitude !== 0 && autoFit.current) {
270
274
  if (mapRef.current) {
271
275
  fitCoordinates();
272
276
  autoFit.current = false;
@@ -274,7 +278,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
274
278
  }
275
279
  }, 1000);
276
280
  return () => clearInterval(interval);
277
- }, [parsedInitialPosition]);
281
+ }, [parsedInitialPosition()]);
278
282
 
279
283
  const fitCoordinatesZoom = () => {
280
284
  following.current = false;
@@ -357,8 +361,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
357
361
  ref={mapRef}
358
362
  provider={PROVIDER_GOOGLE}
359
363
  initialRegion={{
360
- latitude: parsedInitialPosition.latitude,
361
- longitude: parsedInitialPosition.longitude,
364
+ latitude: parsedInitialPosition()?.latitude,
365
+ longitude: parsedInitialPosition()?.longitude,
362
366
  latitudeDelta: 0.001,
363
367
  longitudeDelta: 0.001 * ASPECT_RATIO,
364
368
  }}
@@ -380,8 +384,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
380
384
  <>
381
385
  <Marker
382
386
  coordinate={{
383
- latitude: typeof destination?.latitude !== 'object' ? destination?.latitude : 0,
384
- longitude: typeof destination?.longitude !== 'object' ? destination?.latitude : 0
387
+ latitude: parsedDestination()?.latitude,
388
+ longitude: parsedDestination()?.longitude
385
389
  }}
386
390
  title={location.title}>
387
391
  <Icon
@@ -415,8 +419,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
415
419
  ) : (
416
420
  <Marker
417
421
  coordinate={{
418
- latitude: typeof parsedUserLocation()?.latitude !== 'object' ? parsedUserLocation()?.latitude : 0,
419
- longitude: typeof parsedUserLocation()?.longitude !== 'object' ? parsedUserLocation()?.latitude : 0
422
+ latitude: parsedUserLocation()?.latitude,
423
+ longitude: parsedUserLocation()?.longitude
420
424
  }}
421
425
  title={markerTitle || t('YOUR_LOCATION', 'Your Location')}
422
426
  />
@@ -528,10 +532,10 @@ export const DriverMap = (props: GoogleMapsParams) => {
528
532
  animationIn: 'slideInUp'
529
533
  }}
530
534
  options={{
531
- latitude: destination.latitude,
532
- longitude: destination.longitude,
533
- sourceLatitude: parsedUserLocation().latitude,
534
- sourceLongitude: parsedUserLocation().longitude,
535
+ latitude: parsedDestination()?.latitude,
536
+ longitude: parsedDestination()?.longitude,
537
+ sourceLatitude: parsedUserLocation()?.latitude,
538
+ sourceLongitude: parsedUserLocation()?.longitude,
535
539
  naverCallerName: 'com.deliveryapp',
536
540
  dialogTitle: t('SHOW_IN_OTHER_MAPS', 'Show in other maps'),
537
541
  dialogMessage: t('WHAT_APP_WOULD_YOU_USE', 'What app would you like to use?'),
@@ -53,19 +53,23 @@ const MapViewComponent = (props: MapViewParams) => {
53
53
 
54
54
  const fitCoordinates = (location?: any) => {
55
55
  if (mapRef.current) {
56
- mapRef.current.fitToCoordinates(
57
- [
58
- {
59
- latitude: typeof location?.latitude !== 'object' ? location?.latitude : 0,
60
- longitude: typeof location?.longitude !== 'object' ? location?.latitude : 0
61
- },
62
- {
63
- latitude: typeof userLocation?.latitude !== 'object' ? userLocation?.latitude : 0,
64
- longitude: typeof userLocation?.longitude !== 'object' ? userLocation?.latitude : 0
65
- },
66
- ],
56
+ const isSendCoordinates =
57
+ location &&
58
+ userLocation &&
59
+ location.latitude !== userLocation.latitude &&
60
+ location.longitude !== userLocation.longitude &&
61
+ location.latitude !== 0 &&
62
+ location.longitude !== 0 &&
63
+ userLocation.latitude !== 0 &&
64
+ userLocation.longitude !== 0
65
+
66
+ isSendCoordinates && mapRef.current.fitToCoordinates(
67
+ [location, userLocation].map(_location => ({
68
+ latitude: _location.latitude,
69
+ longitude: _location.longitude
70
+ })),
67
71
  {
68
- edgePadding: { top: 120, right: 120, bottom: 120, left: 120 },
72
+ edgePadding: { top: 120, right: 120, bottom: 120, left: 120 }
69
73
  },
70
74
  );
71
75
  }
@@ -53,7 +53,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
53
53
  actions,
54
54
  orderTitle,
55
55
  appTitle,
56
- loadMessages
56
+ loadMessages,
57
+ notificationApp
57
58
  } = props;
58
59
 
59
60
  const theme = useTheme();
@@ -594,6 +595,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
594
595
  messages={messages}
595
596
  order={order}
596
597
  setMessages={setMessages}
598
+ notificationApp={notificationApp}
597
599
  />
598
600
  </OModal>
599
601
 
@@ -415,7 +415,8 @@ export interface OrderDetailsParams {
415
415
  orderTitle?: any;
416
416
  forceUpdate?: number;
417
417
  getPermissions?: any
418
- loadMessages?: any
418
+ loadMessages?: any;
419
+ notificationApp?: string
419
420
  }
420
421
  export interface ProductItemAccordionParams {
421
422
  isCartPending?: boolean;
@@ -451,6 +452,7 @@ export interface MessagesParams {
451
452
  sendMessage?: any;
452
453
  canRead?: any;
453
454
  setCanRead?: any;
455
+ notificationApp?: string
454
456
  handleSend?: () => {};
455
457
  setImage?: (image: string | null) => {};
456
458
  setMessage?: (comment: string) => {};
@@ -376,6 +376,10 @@ const CheckoutUI = (props: any) => {
376
376
  setShowTitle(contentOffset.y > 30)
377
377
  }
378
378
 
379
+ const handleRedirect = () => {
380
+ props.fromProductsList ? navigation?.goBack() : onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)
381
+ }
382
+
379
383
  useEffect(() => {
380
384
  if (validationFields && validationFields?.fields?.checkout && !user?.guest_id) {
381
385
  checkValidationFields()
@@ -491,7 +495,7 @@ const CheckoutUI = (props: any) => {
491
495
  <SafeAreaView style={{ backgroundColor: theme.colors.backgroundPage }}>
492
496
  <View style={styles.wrapperNavbar}>
493
497
  <TopHeader>
494
- <TopActions onPress={() => onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)}>
498
+ <TopActions onPress={() => handleRedirect()}>
495
499
  <IconAntDesign
496
500
  name='arrowleft'
497
501
  size={26}
@@ -517,7 +521,7 @@ const CheckoutUI = (props: any) => {
517
521
  hideArrowLeft
518
522
  title={t('CHECKOUT', 'Checkout')}
519
523
  titleAlign={'center'}
520
- onActionLeft={() => onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)}
524
+ onActionLeft={() => handleRedirect()}
521
525
  showCall={false}
522
526
  btnStyle={{ paddingLeft: 0, paddingTop: Platform.OS == 'ios' ? 0 : 2 }}
523
527
  titleWrapStyle={{ paddingHorizontal: 0 }}