ordering-ui-react-native 0.8.3 → 0.8.7

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.
Files changed (47) hide show
  1. package/package.json +2 -1
  2. package/src/components/OrdersOption/index.tsx +1 -12
  3. package/src/navigators/HomeNavigator.tsx +27 -2
  4. package/src/pages/Checkout.tsx +3 -3
  5. package/src/types/react-native-background-timer/index.d.ts +1 -0
  6. package/themes/business/index.tsx +6 -0
  7. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +167 -240
  8. package/themes/business/src/components/Chat/index.tsx +68 -54
  9. package/themes/business/src/components/DriverMap/index.tsx +86 -116
  10. package/themes/business/src/components/GoogleMap/index.tsx +43 -39
  11. package/themes/business/src/components/MessagesOption/index.tsx +73 -59
  12. package/themes/business/src/components/MessagesOption/styles.tsx +1 -1
  13. package/themes/business/src/components/OrderDetails/index.tsx +104 -92
  14. package/themes/business/src/components/OrderDetails/styles.tsx +6 -2
  15. package/themes/business/src/components/OrderDetailsDelivery/index.tsx +816 -0
  16. package/themes/business/src/components/OrderDetailsDelivery/styles.tsx +144 -0
  17. package/themes/business/src/components/OrderMessage/index.tsx +122 -23
  18. package/themes/business/src/components/OrdersOption/index.tsx +52 -66
  19. package/themes/business/src/components/PreviousMessages/index.tsx +2 -2
  20. package/themes/business/src/components/PreviousOrders/index.tsx +5 -5
  21. package/themes/business/src/components/ProductItemAccordion/index.tsx +5 -1
  22. package/themes/business/src/components/StoresList/index.tsx +51 -49
  23. package/themes/business/src/components/UserFormDetails/index.tsx +2 -1
  24. package/themes/business/src/components/UserProfileForm/index.tsx +18 -30
  25. package/themes/business/src/components/UserProfileForm/styles.tsx +0 -2
  26. package/themes/business/src/components/shared/OInput.tsx +3 -2
  27. package/themes/business/src/hooks/useLocation.tsx +7 -3
  28. package/themes/business/src/layouts/SafeAreaContainer.tsx +43 -0
  29. package/themes/business/src/types/index.tsx +8 -0
  30. package/themes/doordash/index.tsx +4 -4
  31. package/themes/doordash/src/components/LoginForm/index.tsx +2 -5
  32. package/themes/doordash/src/components/SingleProductCard/index.tsx +1 -1
  33. package/themes/doordash/src/components/SocialShare/index.tsx +34 -5
  34. package/themes/doordash/src/components/shared/OModal.tsx +1 -6
  35. package/themes/instacart/src/components/AddressForm/index.tsx +2 -60
  36. package/themes/instacart/src/components/AddressList/index.tsx +6 -3
  37. package/themes/instacart/src/components/Home/index.tsx +39 -14
  38. package/themes/instacart/src/components/Home/styles.tsx +7 -0
  39. package/themes/instacart/src/components/LoginForm/index.tsx +3 -3
  40. package/themes/instacart/src/components/LoginForm/styles.tsx +1 -3
  41. package/themes/instacart/src/components/LogoutButton/index.tsx +7 -6
  42. package/themes/instacart/src/components/SocialShare/index.tsx +56 -19
  43. package/themes/instacart/src/components/SocialShare/styles.ts +0 -8
  44. package/themes/instacart/src/components/UserProfileForm/index.tsx +1 -1
  45. package/themes/instacart/src/components/shared/OIcon.tsx +2 -1
  46. package/themes/instacart/src/layouts/Container.tsx +1 -1
  47. package/themes/instacart/src/types/index.tsx +12 -12
@@ -1,5 +1,11 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import { View, Pressable, StyleSheet, Dimensions } from 'react-native';
2
+ import {
3
+ View,
4
+ Pressable,
5
+ StyleSheet,
6
+ Dimensions,
7
+ ScrollView,
8
+ } from 'react-native';
3
9
  import { Contacts, useLanguage } from 'ordering-components/native';
4
10
  import { useTheme } from 'styled-components/native';
5
11
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
@@ -152,7 +158,8 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
152
158
  loadButton: {
153
159
  borderRadius: 7.6,
154
160
  height: 44,
155
- marginBottom: 40,
161
+ marginRight: 10,
162
+ marginBottom: 10,
156
163
  marginTop: 5,
157
164
  },
158
165
  loadButtonText: {
@@ -240,19 +247,20 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
240
247
  />
241
248
  )}
242
249
 
243
- {!reload &&
244
- !error &&
245
- values.length > 0 &&
246
- JSON.stringify(tabsFilter) === JSON.stringify(tabs[0].tags) && (
247
- <PreviousMessages
248
- orders={values}
249
- setOrders={setOrders}
250
- messages={messages}
251
- onNavigationRedirect={onNavigationRedirect}
252
- />
253
- )}
250
+ <ScrollView showsVerticalScrollIndicator={false} style={{ flex: 1 }}>
251
+ {!reload &&
252
+ !error &&
253
+ values.length > 0 &&
254
+ JSON.stringify(tabsFilter) === JSON.stringify(tabs[0].tags) && (
255
+ <PreviousMessages
256
+ orders={values}
257
+ setOrders={setOrders}
258
+ messages={messages}
259
+ onNavigationRedirect={onNavigationRedirect}
260
+ />
261
+ )}
254
262
 
255
- {/* {!reload &&
263
+ {/* {!reload &&
256
264
  !error &&
257
265
  orders.length > 0 &&
258
266
  JSON.stringify(tabsFilter) === JSON.stringify(tabs[1].tags) && (
@@ -266,53 +274,54 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
266
274
  />
267
275
  )} */}
268
276
 
269
- {(loading || reload) && (
270
- <>
271
- <View>
272
- {[...Array(5)].map((item, i) => (
273
- <Placeholder key={i} Animation={Fade}>
274
- <View
275
- style={{
276
- width: '100%',
277
- flexDirection: 'row',
278
- marginBottom: 10,
279
- }}>
280
- <PlaceholderLine
281
- width={orientation === 'Portrait' ? 22 : 11}
282
- height={74}
277
+ {(loading || reload) && (
278
+ <>
279
+ <View>
280
+ {[...Array(5)].map((item, i) => (
281
+ <Placeholder key={i} Animation={Fade}>
282
+ <View
283
283
  style={{
284
- marginRight: 20,
285
- marginBottom: 20,
286
- borderRadius: 7.6,
287
- }}
288
- />
289
- <Placeholder>
290
- <PlaceholderLine width={30} style={{ marginTop: 5 }} />
291
- <PlaceholderLine width={50} />
292
- <PlaceholderLine width={20} />
293
- </Placeholder>
294
- </View>
295
- </Placeholder>
296
- ))}
297
- </View>
298
- </>
299
- )}
300
-
301
- {pagination?.totalPages &&
302
- !loading &&
303
- !reload &&
304
- JSON.stringify(tabsFilter) === JSON.stringify(tabs[0].tags) &&
305
- pagination?.currentPage < pagination?.totalPages && (
306
- <OButton
307
- onClick={() => loadMore && loadMore()}
308
- text={t('LOAD_MORE_ORDERS', 'Load more orders')}
309
- imgRightSrc={null}
310
- textStyle={styles.loadButtonText}
311
- style={styles.loadButton}
312
- bgColor={theme.colors.primary}
313
- borderColor={theme.colors.primary}
314
- />
284
+ width: '100%',
285
+ flexDirection: 'row',
286
+ marginBottom: 10,
287
+ }}>
288
+ <PlaceholderLine
289
+ width={orientation === 'Portrait' ? 22 : 11}
290
+ height={74}
291
+ style={{
292
+ marginRight: 20,
293
+ marginBottom: 20,
294
+ borderRadius: 7.6,
295
+ }}
296
+ />
297
+ <Placeholder>
298
+ <PlaceholderLine width={30} style={{ marginTop: 5 }} />
299
+ <PlaceholderLine width={50} />
300
+ <PlaceholderLine width={20} />
301
+ </Placeholder>
302
+ </View>
303
+ </Placeholder>
304
+ ))}
305
+ </View>
306
+ </>
315
307
  )}
308
+
309
+ {pagination?.totalPages &&
310
+ !loading &&
311
+ !reload &&
312
+ JSON.stringify(tabsFilter) === JSON.stringify(tabs[0].tags) &&
313
+ pagination?.currentPage < pagination?.totalPages && (
314
+ <OButton
315
+ onClick={() => loadMore && loadMore()}
316
+ text={t('LOAD_MORE_ORDERS', 'Load more orders')}
317
+ imgRightSrc={null}
318
+ textStyle={styles.loadButtonText}
319
+ style={styles.loadButton}
320
+ bgColor={theme.colors.primary}
321
+ borderColor={theme.colors.primary}
322
+ />
323
+ )}
324
+ </ScrollView>
316
325
  </>
317
326
  );
318
327
  };
@@ -325,6 +334,11 @@ export const MessagesOption = (props: MessagesOptionParams) => {
325
334
  param: 'last_direct_message_at',
326
335
  direction: 'asc',
327
336
  },
337
+ paginationSettings: {
338
+ page: 1,
339
+ pageSize: 45,
340
+ controlType: 'infinity',
341
+ },
328
342
  UIComponent: MessagesOptionUI,
329
343
  };
330
344
 
@@ -10,7 +10,7 @@ export const TabsContainer = styled.View`
10
10
  `;
11
11
 
12
12
  export const TagsContainer = styled.ScrollView`
13
- margin-bottom: 25px;
13
+ margin-bottom: 10px;
14
14
  `;
15
15
 
16
16
  export const Tag = styled.Pressable`
@@ -1,5 +1,10 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import { StyleSheet, View, TouchableOpacity } from 'react-native';
2
+ import {
3
+ StyleSheet,
4
+ View,
5
+ TouchableOpacity,
6
+ ActivityIndicator,
7
+ } from 'react-native';
3
8
  import Clipboard from '@react-native-clipboard/clipboard';
4
9
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
5
10
  import { useTheme } from 'styled-components/native';
@@ -66,7 +71,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
66
71
  business: false,
67
72
  driver: false,
68
73
  });
69
- const { order, businessData, driversGroupsData, loading } = props.order;
74
+ const { order, businessData, loading } = props.order;
75
+ const { drivers, loadingDriver } = props.drivers;
70
76
  const itemsDrivers: any = [];
71
77
  const [actionOrder, setActionOrder] = useState('');
72
78
  const [openModalForBusiness, setOpenModalForBusiness] = useState(false);
@@ -75,8 +81,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
75
81
  const [isDriverModalVisible, setIsDriverModalVisible] = useState(false);
76
82
 
77
83
  if (order?.status === 7 || order?.status === 4) {
78
- if (driversGroupsData?.length > 0) {
79
- driversGroupsData.forEach((driver: any) => {
84
+ if (drivers?.length > 0 && drivers) {
85
+ drivers.forEach((driver: any) => {
80
86
  itemsDrivers.push({
81
87
  available: driver?.available,
82
88
  key: driver?.id,
@@ -86,9 +92,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
86
92
  });
87
93
 
88
94
  if (
89
- !driversGroupsData?.some(
90
- (driver: any) => driver?.id === order?.driver?.id,
91
- ) &&
95
+ !drivers?.some((driver: any) => driver?.id === order?.driver?.id) &&
92
96
  order?.driver?.id
93
97
  ) {
94
98
  itemsDrivers.push({
@@ -100,10 +104,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
100
104
  }
101
105
  }
102
106
 
103
- if (
104
- order?.driver &&
105
- (!driversGroupsData.length || driversGroupsData.length === 0)
106
- ) {
107
+ if (order?.driver && (!drivers?.length || drivers?.length === 0)) {
107
108
  itemsDrivers.push({
108
109
  available: order?.driver?.available,
109
110
  key: order?.driver?.id,
@@ -403,11 +404,13 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
403
404
  icon:
404
405
  order?.driver?.photo ||
405
406
  'https://res.cloudinary.com/demo/image/fetch/c_thumb,g_face,r_max/https://www.freeiconspng.com/thumbs/driver-icon/driver-icon-14.png',
407
+ level: 4,
406
408
  },
407
409
  {
408
410
  ...order?.business?.location,
409
411
  title: order?.business?.name,
410
412
  icon: order?.business?.logo || theme.images.dummies.businessLogo,
413
+ level: 2,
411
414
  },
412
415
  {
413
416
  ...order?.customer?.location,
@@ -415,6 +418,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
415
418
  icon:
416
419
  order?.customer?.photo ||
417
420
  'https://res.cloudinary.com/demo/image/upload/c_thumb,g_face,r_max/d_avatar.png/non_existing_id.png',
421
+ level: 3,
418
422
  },
419
423
  ];
420
424
 
@@ -423,10 +427,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
423
427
  setOpenModalForAccept(false);
424
428
  }
425
429
 
426
- if (openModalForBusiness) {
427
- setOpenModalForBusiness(false);
428
- }
429
-
430
430
  if (openModalForMapView) {
431
431
  setOpenModalForMapView(false);
432
432
  }
@@ -438,7 +438,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
438
438
 
439
439
  useEffect(() => {
440
440
  if (driverLocation) {
441
- locations[0] = driverLocation;
441
+ locations[0] = { ...locations[0], driverLocation };
442
442
  }
443
443
  }, [driverLocation]);
444
444
 
@@ -487,7 +487,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
487
487
 
488
488
  return (
489
489
  <>
490
- {(!order || Object.keys(order).length === 0 || loading) && (
490
+ {(!order || Object.keys(order).length === 0) && (
491
491
  <View
492
492
  style={{
493
493
  padding: 20,
@@ -508,70 +508,68 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
508
508
  </View>
509
509
  )}
510
510
 
511
- {order && Object.keys(order).length > 0 && !loading && (
511
+ {order && Object.keys(order).length > 0 && (
512
512
  <>
513
+ <Header>
514
+ <OIconButton
515
+ icon={theme.images.general.arrow_left}
516
+ iconStyle={{ width: 20, height: 20 }}
517
+ borderColor={theme.colors.clear}
518
+ style={{ ...styles.icons, justifyContent: 'flex-end' }}
519
+ onClick={() => handleArrowBack()}
520
+ />
521
+
522
+ <Actions>
523
+ <OIconButton
524
+ icon={theme.images.general.map}
525
+ iconStyle={{
526
+ width: 20,
527
+ height: 20,
528
+ tintColor: theme.colors.backArrow,
529
+ }}
530
+ borderColor={theme.colors.clear}
531
+ style={styles.icons}
532
+ onClick={() => handleOpenMapView()}
533
+ />
534
+
535
+ <OIconButton
536
+ icon={theme.images.general.messages}
537
+ iconStyle={{
538
+ width: 20,
539
+ height: 20,
540
+ tintColor: theme.colors.backArrow,
541
+ }}
542
+ borderColor={theme.colors.clear}
543
+ style={styles.icons}
544
+ onClick={() => handleOpenMessagesForBusiness()}
545
+ />
546
+ </Actions>
547
+ </Header>
548
+ <OrderHeader>
549
+ <OText size={13} style={{ marginBottom: 5 }}>
550
+ {order?.delivery_datetime_utc
551
+ ? parseDate(order?.delivery_datetime_utc)
552
+ : parseDate(order?.delivery_datetime, { utc: false })}
553
+ </OText>
554
+
555
+ <OText numberOfLines={2} size={20} weight="600">
556
+ <>
557
+ {`${t('INVOICE_ORDER_NO', 'Order No.')} ${order.id} ${t(
558
+ 'IS',
559
+ 'is',
560
+ )} `}
561
+ <OText
562
+ size={20}
563
+ weight="600"
564
+ color={colors[order?.status] || theme.colors.primary}>
565
+ {getOrderStatus(order?.status)?.value}
566
+ </OText>
567
+ </>
568
+ </OText>
569
+ </OrderHeader>
513
570
  <OrderDetailsContainer keyboardShouldPersistTaps="handled">
514
571
  <>
515
- <Header>
516
- <OIconButton
517
- icon={theme.images.general.arrow_left}
518
- iconStyle={{ width: 20, height: 20 }}
519
- borderColor={theme.colors.clear}
520
- style={{ ...styles.icons, justifyContent: 'flex-end' }}
521
- onClick={() => handleArrowBack()}
522
- />
523
-
524
- <Actions>
525
- <OIconButton
526
- icon={theme.images.general.map}
527
- iconStyle={{
528
- width: 20,
529
- height: 20,
530
- tintColor: theme.colors.backArrow,
531
- }}
532
- borderColor={theme.colors.clear}
533
- style={styles.icons}
534
- onClick={() => handleOpenMapView()}
535
- />
536
-
537
- <OIconButton
538
- icon={theme.images.general.messages}
539
- iconStyle={{
540
- width: 20,
541
- height: 20,
542
- tintColor: theme.colors.backArrow,
543
- }}
544
- borderColor={theme.colors.clear}
545
- style={styles.icons}
546
- onClick={() => handleOpenMessagesForBusiness()}
547
- />
548
- </Actions>
549
- </Header>
550
-
551
572
  <OrderContent>
552
- <OrderHeader>
553
- <OText size={13} style={{ marginBottom: 5 }}>
554
- {order?.delivery_datetime_utc
555
- ? parseDate(order?.delivery_datetime_utc)
556
- : parseDate(order?.delivery_datetime, { utc: false })}
557
- </OText>
558
-
559
- <OText numberOfLines={2} size={20} weight="600">
560
- <>
561
- {`${t('INVOICE_ORDER_NO', 'Order No.')} ${order.id} ${t(
562
- 'IS',
563
- 'is',
564
- )} `}
565
- <OText
566
- size={20}
567
- weight="600"
568
- color={colors[order?.status] || theme.colors.primary}>
569
- {getOrderStatus(order?.status)?.value}
570
- </OText>
571
- </>
572
- </OText>
573
- </OrderHeader>
574
-
575
573
  <OrderBusiness>
576
574
  <OText style={{ marginBottom: 5 }} size={16} weight="600">
577
575
  {t('BUSINESS_DETAILS', 'Business details')}
@@ -761,21 +759,32 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
761
759
  <>
762
760
  <TouchableOpacity
763
761
  onPress={() => setIsDriverModalVisible(true)}
764
- disabled={itemsDrivers.length === 0}>
765
- <DriverItem justifyContent="space-between">
766
- <OText>
767
- {itemsDrivers.length > 0
768
- ? order?.driver?.name ||
769
- t('SELECT_DRIVER', 'Select Driver')
770
- : t('WITHOUT_DRIVERS', 'Without drivers')}
771
- </OText>
772
- <OIcon
773
- src={theme?.images?.general?.chevronDown}
774
- color={theme.colors.backArrow}
775
- width={20}
776
- height={20}
777
- />
778
- </DriverItem>
762
+ disabled={
763
+ itemsDrivers.length === 0 || loadingDriver
764
+ }>
765
+ {loadingDriver ? (
766
+ <DriverItem justifyContent="center">
767
+ <ActivityIndicator
768
+ size="small"
769
+ color={theme.colors.primary}
770
+ />
771
+ </DriverItem>
772
+ ) : (
773
+ <DriverItem justifyContent="space-between">
774
+ <OText>
775
+ {itemsDrivers.length > 0
776
+ ? order?.driver?.name ||
777
+ t('SELECT_DRIVER', 'Select Driver')
778
+ : t('WITHOUT_DRIVERS', 'Without drivers')}
779
+ </OText>
780
+ <OIcon
781
+ src={theme?.images?.general?.chevronDown}
782
+ color={theme.colors.backArrow}
783
+ width={20}
784
+ height={20}
785
+ />
786
+ </DriverItem>
787
+ )}
779
788
  </TouchableOpacity>
780
789
  </>
781
790
  )}
@@ -890,6 +899,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
890
899
  <GoogleMap
891
900
  location={order?.customer?.location}
892
901
  locations={locationsToSend}
902
+ driverLocation={driverLocation}
893
903
  navigation={navigation}
894
904
  handleViewActionOrder={handleViewActionOrder}
895
905
  handleOpenMapView={handleOpenMapView}
@@ -910,6 +920,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
910
920
  <>
911
921
  <FloatingButton
912
922
  btnText={t('REJECT', 'Reject')}
923
+ disabled={loading}
913
924
  isSecondaryBtn={false}
914
925
  secondButtonClick={() => handleViewActionOrder('accept')}
915
926
  firstButtonClick={() => handleViewActionOrder('reject')}
@@ -928,6 +939,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
928
939
  <FloatingButton
929
940
  btnText={t('COPY', 'Copy')}
930
941
  isSecondaryBtn={false}
942
+ disabled={loading}
931
943
  colorTxt1={theme.colors.primary}
932
944
  secondButtonClick={handleViewSummaryOrder}
933
945
  firstButtonClick={handleCopyClipboard}
@@ -17,6 +17,7 @@ export const Header = styled.View`
17
17
  flex-direction: row;
18
18
  justify-content: space-between;
19
19
  padding-top: 10px;
20
+ padding-horizontal: 20px;
20
21
  `;
21
22
 
22
23
  export const DriverItem = styled.View`
@@ -37,12 +38,15 @@ export const Logo = styled.View`
37
38
  margin-right: 20px;
38
39
  `;
39
40
 
40
- export const OrderContent = styled.View``;
41
+ export const OrderContent = styled.View`
42
+ flex: 1;
43
+ `;
41
44
 
42
45
  export const OrderHeader = styled.View`
43
46
  padding-vertical: 10px;
44
- border-bottom-width: 20px;
47
+ border-bottom-width: 10px;
45
48
  border-bottom-color: ${(props: any) => props.theme.colors.inputChat};
49
+ padding-horizontal: 20px;
46
50
  `;
47
51
 
48
52
  export const OrderBusiness = styled.View`