ordering-ui-react-native 0.9.5 → 0.9.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
package/src/index.tsx CHANGED
@@ -64,6 +64,7 @@ import { UserDetails } from './components/UserDetails';
64
64
  import { UserFormDetailsUI } from './components/UserFormDetails';
65
65
  import { UserProfileForm } from './components/UserProfileForm';
66
66
  import { VerifyPhone } from './components/VerifyPhone';
67
+ import { HelpParams } from './types';
67
68
  import {
68
69
  OAlert,
69
70
  OBottomPopup,
@@ -181,4 +182,6 @@ export {
181
182
  useTheme,
182
183
  // hooks
183
184
  DeviceOrientationMethods,
185
+ //types
186
+ HelpParams,
184
187
  }
@@ -458,6 +458,7 @@ const ChatUI = (props: MessagesParams) => {
458
458
  messages?.messages.map((message: any) => {
459
459
  let newMessage;
460
460
  if (
461
+ parseInt(message.order_id) === order?.id &&
461
462
  message.type !== 0 &&
462
463
  (messagesToShow?.messages?.length ||
463
464
  message?.can_see?.includes('2') ||
@@ -33,6 +33,9 @@ export const DriverMap = (props: GoogleMapsParams) => {
33
33
  isBusinessMarker,
34
34
  isToFollow,
35
35
  handleViewActionOrder,
36
+ updateDriverPosition,
37
+ driverUpdateLocation,
38
+ setDriverUpdateLocation,
36
39
  } = props;
37
40
 
38
41
  const theme = useTheme();
@@ -73,7 +76,6 @@ export const DriverMap = (props: GoogleMapsParams) => {
73
76
  longitude: initialPosition.longitude,
74
77
  };
75
78
  const destination = { latitude: location.lat, longitude: location.lng };
76
-
77
79
  const { top } = useSafeAreaInsets();
78
80
 
79
81
  useEffect(() => {
@@ -189,6 +191,23 @@ export const DriverMap = (props: GoogleMapsParams) => {
189
191
  };
190
192
 
191
193
  useEffect(() => {
194
+ if (driverUpdateLocation.error) {
195
+ stopFollowUserLocation();
196
+ setAlertState({
197
+ open: true,
198
+ content: [
199
+ `${driverUpdateLocation.error[0] || driverUpdateLocation.error}. ${t(
200
+ 'TRY_AGAIN',
201
+ 'Try Again',
202
+ )}`,
203
+ ],
204
+ });
205
+ }
206
+ }, [driverUpdateLocation.error]);
207
+
208
+ useEffect(() => {
209
+ if (driverUpdateLocation.error) return;
210
+
192
211
  calculateDistance(
193
212
  { lat: userLocation.latitude, lng: userLocation.longitude },
194
213
  destination,
@@ -203,9 +222,19 @@ export const DriverMap = (props: GoogleMapsParams) => {
203
222
  mapRef.current?.animateCamera({
204
223
  center: { latitude, longitude },
205
224
  });
225
+
226
+ if (userLocation.latitude && userLocation.longitude)
227
+ updateDriverPosition({
228
+ location: { lat: userLocation.latitude, lng: userLocation.longitude },
229
+ });
206
230
  }, [userLocation]);
207
231
 
208
232
  const handleArrowBack: any = () => {
233
+ setDriverUpdateLocation({
234
+ ...driverUpdateLocation,
235
+ error: null,
236
+ newLocation: null,
237
+ });
209
238
  handleOpenMapView && handleOpenMapView();
210
239
  };
211
240
 
@@ -307,7 +336,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
307
336
  },
308
337
  facOrderStatus: {
309
338
  flexDirection: 'row',
310
- paddingTop: top + 5,
339
+ paddingTop: top + 13,
311
340
  borderBottomWidth: 11,
312
341
  borderBottomColor: theme.colors.inputChat,
313
342
  },
@@ -321,10 +350,6 @@ export const DriverMap = (props: GoogleMapsParams) => {
321
350
  },
322
351
  });
323
352
 
324
- const handleChangeRegion = (coordinates: Region) => {
325
- validateResult(coordinates);
326
- };
327
-
328
353
  return (
329
354
  <>
330
355
  <View style={{ flex: 1 }}>
@@ -43,6 +43,7 @@ import { OrderDetailsParams } from '../../types';
43
43
  import { verifyDecimals } from '../../utils';
44
44
  import { USER_TYPE } from '../../config/constants';
45
45
  import CountryPicker from 'react-native-country-picker-modal';
46
+ import { NotFoundSource } from '../NotFoundSource';
46
47
 
47
48
  export const OrderDetailsUI = (props: OrderDetailsParams) => {
48
49
  const {
@@ -71,7 +72,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
71
72
  business: false,
72
73
  driver: false,
73
74
  });
74
- const { order, businessData, loading } = props.order;
75
+ const { order, businessData, loading, error } = props.order;
75
76
  const { drivers, loadingDriver } = props.drivers;
76
77
  const itemsDrivers: any = [];
77
78
  const [actionOrder, setActionOrder] = useState('');
@@ -507,7 +508,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
507
508
 
508
509
  return (
509
510
  <>
510
- {(!order || Object.keys(order).length === 0) && (
511
+ {(!order || Object.keys(order).length === 0) && !error && (
511
512
  <View
512
513
  style={{
513
514
  padding: 20,
@@ -527,8 +528,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
527
528
  ))}
528
529
  </View>
529
530
  )}
530
-
531
- {order && Object.keys(order).length > 0 && (
531
+ {error?.length > 0 && (
532
+ <NotFoundSource
533
+ btnTitle={t('GO_TO_MY_ORDERS', 'Go to my orders')}
534
+ content={props.order.error[0]}
535
+ onClickButton={() => navigation.navigate('Orders')}
536
+ />
537
+ )}
538
+ {order && Object.keys(order).length > 0 && !error && (
532
539
  <>
533
540
  <Header>
534
541
  <OIconButton
@@ -978,7 +985,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
978
985
  export const OrderDetails = (props: OrderDetailsParams) => {
979
986
  const orderDetailsProps = {
980
987
  ...props,
981
- driverAndBusinessId: true,
982
988
  UIComponent: OrderDetailsUI,
983
989
  };
984
990
  return <OrderDetailsController {...orderDetailsProps} />;
@@ -27,6 +27,7 @@ import { ProductItemAccordion } from '../ProductItemAccordion';
27
27
  import { USER_TYPE } from '../../config/constants';
28
28
  import { useTheme } from 'styled-components/native';
29
29
  import { verifyDecimals } from '../../utils';
30
+ import { NotFoundSource } from '../NotFoundSource';
30
31
 
31
32
  //Styles
32
33
  import {
@@ -56,13 +57,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
56
57
  askLocationPermission,
57
58
  driverLocation,
58
59
  actions,
60
+ updateDriverPosition,
61
+ driverUpdateLocation,
62
+ setDriverUpdateLocation,
59
63
  titleAccept,
60
64
  titleReject,
61
65
  appTitle,
62
66
  } = props;
63
67
 
64
68
  const [, { showToast }] = useToast();
65
- const { order, loading } = props.order;
69
+ const { order, loading, error } = props.order;
66
70
  const theme = useTheme();
67
71
  const [, t] = useLanguage();
68
72
  const [{ parsePrice, parseNumber, parseDate }] = useUtils();
@@ -444,7 +448,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
444
448
 
445
449
  return (
446
450
  <>
447
- {(!order || Object.keys(order).length === 0) && (
451
+ {(!order || Object.keys(order).length === 0) && !error && (
448
452
  <View
449
453
  style={{
450
454
  padding: 20,
@@ -464,7 +468,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
464
468
  ))}
465
469
  </View>
466
470
  )}
467
- {order && Object.keys(order).length > 0 && (
471
+ {error?.length > 0 && (
472
+ <NotFoundSource
473
+ btnTitle={t('GO_TO_MY_ORDERS', 'Go to my orders')}
474
+ content={props.order.error[0]}
475
+ onClickButton={() => navigation.navigate('Orders')}
476
+ />
477
+ )}
478
+ {order && Object.keys(order).length > 0 && !error && (
468
479
  <>
469
480
  <Header>
470
481
  <OIconButton
@@ -760,6 +771,9 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
760
771
  orderStatus={getOrderStatus(order?.status)?.value || ''}
761
772
  location={locationMarker}
762
773
  readOnly
774
+ updateDriverPosition={updateDriverPosition}
775
+ driverUpdateLocation={driverUpdateLocation}
776
+ setDriverUpdateLocation={setDriverUpdateLocation}
763
777
  handleViewActionOrder={handleViewActionOrder}
764
778
  isBusinessMarker={isBusinessMarker}
765
779
  isToFollow={isToFollow}
@@ -828,7 +842,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
828
842
  export const OrderDetailsDelivery = (props: OrderDetailsParams) => {
829
843
  const orderDetailsProps = {
830
844
  ...props,
831
- driverAndBusinessId: true,
832
845
  UIComponent: OrderDetailsUI,
833
846
  };
834
847
  return <OrderDetailsConTableoller {...orderDetailsProps} />;
@@ -134,6 +134,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
134
134
  const scrollRefTab = useRef() as React.MutableRefObject<ScrollView>;
135
135
 
136
136
  const [ordersFilter, setOrdersFilter] = useState(tabs[0].tags);
137
+ const [ordersFiltered, setOrdersFiltered] = useState(
138
+ orders.filter((order: any) => ordersFilter.includes(order?.status)),
139
+ );
137
140
  const [tabsStatus, setTabStatus] = useState(tabs[0].tags);
138
141
  const [tagsStatus, setTagsStatus] = useState(tabs[0].tags);
139
142
  const [isLoadedOrders, setIsLoadedOrders] = useState<any>({
@@ -153,6 +156,14 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
153
156
  parseInt(parseFloat(String(Dimensions.get('window').width)).toFixed(0)),
154
157
  );
155
158
 
159
+ useEffect(() => {
160
+ setOrdersFiltered(
161
+ orders.filter((order: any) =>
162
+ rememberOrderStatus.includes(order?.status),
163
+ ),
164
+ );
165
+ }, [ordersFilter, orders, rememberOrderStatus]);
166
+
156
167
  const handleChangeTab = (tags: number[], tabTitle: string) => {
157
168
  if (!isLoadedOrders[tabTitle].isFetched) {
158
169
  loadOrders && loadOrders(true, tags);
@@ -373,6 +384,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
373
384
 
374
385
  {!loading &&
375
386
  (!ordersFilter.length ||
387
+ ordersFiltered?.length < 1 ||
376
388
  orderList.error ||
377
389
  !orderList.orders.length ||
378
390
  !rememberOrderStatus.length) && (
@@ -392,7 +404,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
392
404
  <ScrollView showsVerticalScrollIndicator={false} style={{ flex: 1 }}>
393
405
  {!reload && !error && orders.length > 0 && (
394
406
  <PreviousOrders
395
- orders={orders}
407
+ orders={ordersFiltered}
396
408
  onNavigationRedirect={onNavigationRedirect}
397
409
  getOrderStatus={getOrderStatus}
398
410
  tabsFilter={rememberOrderStatus}
@@ -7,7 +7,7 @@ import { Card, Logo, Information, MyOrderOptions } from './styles';
7
7
  import { PreviousOrdersParams } from '../../types';
8
8
 
9
9
  export const PreviousOrders = (props: any) => {
10
- const { orders, onNavigationRedirect, getOrderStatus, tabsFilter } = props;
10
+ const { orders, onNavigationRedirect, getOrderStatus } = props;
11
11
  const [, t] = useLanguage();
12
12
  const [{ parseDate, optimizeImage }] = useUtils();
13
13
  const theme = useTheme();
@@ -76,63 +76,61 @@ export const PreviousOrders = (props: any) => {
76
76
  })
77
77
  ?.map((order: any) => (
78
78
  <React.Fragment key={order.id}>
79
- {tabsFilter.includes(order.status) && (
80
- <TouchableOpacity
81
- onPress={() => handlePressOrder(order)}
82
- style={styles.cardButton}
83
- activeOpacity={1}>
84
- <Card key={order.id}>
85
- {!!order.business?.logo && (
86
- <Logo style={styles.logo}>
87
- <OIcon
88
- url={optimizeImage(
89
- order.business?.logo,
90
- 'h_300,c_limit',
91
- )}
92
- style={styles.icon}
93
- />
94
- </Logo>
95
- )}
79
+ <TouchableOpacity
80
+ onPress={() => handlePressOrder(order)}
81
+ style={styles.cardButton}
82
+ activeOpacity={1}>
83
+ <Card key={order.id}>
84
+ {!!order.business?.logo && (
85
+ <Logo style={styles.logo}>
86
+ <OIcon
87
+ url={optimizeImage(
88
+ order.business?.logo,
89
+ 'h_300,c_limit',
90
+ )}
91
+ style={styles.icon}
92
+ />
93
+ </Logo>
94
+ )}
96
95
 
97
- <Information>
98
- <OText numberOfLines={1} style={styles.title}>
99
- {order.business?.name}
100
- </OText>
96
+ <Information>
97
+ <OText numberOfLines={1} style={styles.title}>
98
+ {order.business?.name}
99
+ </OText>
100
+
101
+ <OText
102
+ style={styles.date}
103
+ numberOfLines={1}
104
+ adjustsFontSizeToFit
105
+ size={20}>
106
+ {t('INVOICE_ORDER_NO', 'Order No.') + order.id + ' · '}
107
+ {order?.delivery_datetime_utc
108
+ ? parseDate(order?.delivery_datetime_utc)
109
+ : parseDate(order?.delivery_datetime, { utc: false })}
110
+ </OText>
101
111
 
112
+ <MyOrderOptions>
102
113
  <OText
103
- style={styles.date}
114
+ style={styles.orderType}
115
+ mRight={5}
104
116
  numberOfLines={1}
105
117
  adjustsFontSizeToFit
106
- size={20}>
107
- {t('INVOICE_ORDER_NO', 'Order No.') + order.id + ' · '}
108
- {order?.delivery_datetime_utc
109
- ? parseDate(order?.delivery_datetime_utc)
110
- : parseDate(order?.delivery_datetime, { utc: false })}
118
+ size={18}>
119
+ {order.delivery_type === 1
120
+ ? t('DELIVERY', 'Delivery')
121
+ : order.delivery_type === 2
122
+ ? t('PICKUP', 'Pickup')
123
+ : order.delivery_type === 3
124
+ ? t('EAT_IN', 'Eat in')
125
+ : order.delivery_type === 4
126
+ ? t('CURBSIDE', 'Curbside')
127
+ : t('DRIVER_THRU', 'Driver thru')}
128
+ {` · ${getOrderStatus(order.status)}`}
111
129
  </OText>
112
-
113
- <MyOrderOptions>
114
- <OText
115
- style={styles.orderType}
116
- mRight={5}
117
- numberOfLines={1}
118
- adjustsFontSizeToFit
119
- size={18}>
120
- {order.delivery_type === 1
121
- ? t('DELIVERY', 'Delivery')
122
- : order.delivery_type === 2
123
- ? t('PICKUP', 'Pickup')
124
- : order.delivery_type === 3
125
- ? t('EAT_IN', 'Eat in')
126
- : order.delivery_type === 4
127
- ? t('CURBSIDE', 'Curbside')
128
- : t('DRIVER_THRU', 'Driver thru')}
129
- {` · ${getOrderStatus(order.status)}`}
130
- </OText>
131
- </MyOrderOptions>
132
- </Information>
133
- </Card>
134
- </TouchableOpacity>
135
- )}
130
+ </MyOrderOptions>
131
+ </Information>
132
+ </Card>
133
+ </TouchableOpacity>
136
134
  </React.Fragment>
137
135
  ))}
138
136
  </>
@@ -45,6 +45,7 @@ export const UserFormDetailsUI = (props: any) => {
45
45
 
46
46
  const [{ user }] = useSession();
47
47
  const [passwordSee, setPasswordSee] = useState(false);
48
+ const [confirmSee, setConfirmSee] = useState(false);
48
49
  const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null);
49
50
  const [phoneInputData, setPhoneInputData] = useState({
50
51
  error: '',
@@ -388,7 +389,7 @@ export const UserFormDetailsUI = (props: any) => {
388
389
  control={control}
389
390
  render={({ onChange, value }: any) => (
390
391
  <OInput
391
- isSecured={!passwordSee ? true : false}
392
+ isSecured={!confirmSee ? true : false}
392
393
  placeholder={t(
393
394
  'MOBILE_CONFIRM_PASSWORD',
394
395
  'Confirm Password',
@@ -396,19 +397,19 @@ export const UserFormDetailsUI = (props: any) => {
396
397
  style={styles.inputStyle}
397
398
  placeholderTextColor={theme.colors.arrowColor}
398
399
  iconCustomRight={
399
- passwordSee ? (
400
+ confirmSee ? (
400
401
  <MaterialCommunityIcons
401
402
  name="eye-outline"
402
403
  color={theme.colors.arrowColor}
403
404
  size={24}
404
- onPress={() => setPasswordSee(!passwordSee)}
405
+ onPress={() => setConfirmSee(!confirmSee)}
405
406
  />
406
407
  ) : (
407
408
  <MaterialCommunityIcons
408
409
  name="eye-off-outline"
409
410
  color={theme.colors.arrowColor}
410
411
  size={24}
411
- onPress={() => setPasswordSee(!passwordSee)}
412
+ onPress={() => setConfirmSee(!confirmSee)}
412
413
  />
413
414
  )
414
415
  }
@@ -104,20 +104,21 @@ const ProfileUI = (props: ProfileParams) => {
104
104
  };
105
105
 
106
106
  useEffect(() => {
107
- if (userState.result.result && !isAvailableLoading) {
107
+ const isLoadingDriver = userState?.loadingDriver ?? true;
108
+
109
+ if (userState?.result?.result && !isLoadingDriver) {
108
110
  if (userState?.result?.error) {
109
- showToast(
110
- ToastType.Error,
111
- t(userState.result.error, userState.result.error),
112
- );
111
+ const messageError =
112
+ userState.result.error || userState.result.error[0];
113
+ showToast(ToastType.Error, t(messageError, messageError));
113
114
  } else {
114
115
  showToast(
115
116
  ToastType.Success,
116
- t('UPDATE_SUCCESSFULLY', 'Update successfully'),
117
+ t('AVAILABLE_STATE_IS_UPDATED', 'Available state is updated'),
117
118
  );
118
119
  }
119
120
  }
120
- }, [isAvailableLoading]);
121
+ }, [userState?.loadingDriver]);
121
122
 
122
123
  useEffect(() => {
123
124
  if (formState.result.result && !formState.loading) {
@@ -301,7 +302,7 @@ const ProfileUI = (props: ProfileParams) => {
301
302
  )}
302
303
  </OText>
303
304
 
304
- {isAvailableLoading ? (
305
+ {userState.loadingDriver ? (
305
306
  <ActivityIndicator size="small" color={theme.colors.primary} />
306
307
  ) : (
307
308
  <ToggleSwitch
@@ -67,7 +67,7 @@ export const useLocation = () => {
67
67
  setRoutesLines(routes => [...routes, location]);
68
68
  },
69
69
  err => console.log(err),
70
- { enableHighAccuracy: true, distanceFilter: 1 },
70
+ { enableHighAccuracy: true, distanceFilter: 3 },
71
71
  );
72
72
  };
73
73
 
@@ -349,6 +349,9 @@ export interface OrderDetailsParams {
349
349
  permissions?: any;
350
350
  askLocationPermission?: any;
351
351
  redirectToSettings?: any;
352
+ updateDriverPosition?: any;
353
+ driverUpdateLocation?: any;
354
+ setDriverUpdateLocation?: any;
352
355
  }
353
356
  export interface ProductItemAccordionParams {
354
357
  isCartPending?: boolean;
@@ -488,6 +491,9 @@ export interface GoogleMapsParams {
488
491
  setSaveLocation?: (val: boolean) => void;
489
492
  handleToggleMap?: () => void;
490
493
  navigation: any;
494
+ updateDriverPosition?: any;
495
+ driverUpdateLocation?: any;
496
+ setDriverUpdateLocation: any;
491
497
  }
492
498
 
493
499
  export interface TagsParams {
@@ -60,7 +60,20 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
60
60
  }
61
61
 
62
62
  const handleClickOrderReview = (order: any) => {
63
- onNavigationRedirect && onNavigationRedirect('ReviewOrder', { order: { id: order?.id, business_id: order?.business_id, logo: order.business?.logo } })
63
+ onNavigationRedirect && onNavigationRedirect(
64
+ 'ReviewOrder',
65
+ {
66
+ order: {
67
+ id: order?.id,
68
+ business_id: order?.business_id,
69
+ logo: order.business?.logo,
70
+ driver: order?.driver,
71
+ products: order?.products,
72
+ review: order?.review,
73
+ user_review: order?.user_review
74
+ }
75
+ }
76
+ )
64
77
  }
65
78
 
66
79
  const handleReorderClick = (id: number) => {
@@ -56,7 +56,20 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
56
56
  }
57
57
 
58
58
  const handleClickOrderReview = (order: any) => {
59
- onNavigationRedirect && onNavigationRedirect('ReviewOrder', { order: { id: order?.id, business_id: order?.business_id, logo: order.business?.logo } })
59
+ onNavigationRedirect && onNavigationRedirect(
60
+ 'ReviewOrder',
61
+ {
62
+ order: {
63
+ id: order?.id,
64
+ business_id: order?.business_id,
65
+ logo: order.business?.logo,
66
+ driver: order?.driver,
67
+ products: order?.products,
68
+ review: order?.review,
69
+ user_review: order?.user_review
70
+ }
71
+ }
72
+ )
60
73
  }
61
74
 
62
75
  const handleReorderClick = (id: number) => {
@@ -86,6 +86,10 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
86
86
  id: order?.id,
87
87
  business_id: order?.business_id,
88
88
  logo: order.business?.logo,
89
+ driver: order?.driver,
90
+ products: order?.products,
91
+ review: order?.review,
92
+ user_review: order?.user_review
89
93
  },
90
94
  });
91
95
  };
@@ -56,7 +56,20 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
56
56
  }
57
57
 
58
58
  const handleClickOrderReview = (order: any) => {
59
- onNavigationRedirect && onNavigationRedirect('ReviewOrder', { order: { id: order?.id, business_id: order?.business_id, logo: order.business?.logo } })
59
+ onNavigationRedirect && onNavigationRedirect(
60
+ 'ReviewOrder',
61
+ {
62
+ order: {
63
+ id: order?.id,
64
+ business_id: order?.business_id,
65
+ logo: order.business?.logo,
66
+ driver: order?.driver,
67
+ products: order?.products,
68
+ review: order?.review,
69
+ user_review: order?.user_review
70
+ }
71
+ }
72
+ )
60
73
  }
61
74
 
62
75
  const handleReorderClick = (id : number) => {