ordering-ui-react-native 0.22.71 → 0.22.72-release

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 (141) hide show
  1. package/package.json +5 -7
  2. package/src/components/BusinessesListing/index.tsx +1 -1
  3. package/src/components/Checkout/index.tsx +40 -39
  4. package/src/components/VerifyPhone/styles.tsx +1 -2
  5. package/src/context/OfflineActions/index.tsx +236 -0
  6. package/src/providers/AlertProvider.tsx +3 -1
  7. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +5 -3
  8. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  9. package/themes/business/src/components/BusinessController/index.tsx +8 -3
  10. package/themes/business/src/components/BusinessProductList/index.tsx +3 -2
  11. package/themes/business/src/components/Chat/index.tsx +15 -3
  12. package/themes/business/src/components/DriverMap/index.tsx +44 -33
  13. package/themes/business/src/components/FloatingButton/index.tsx +3 -2
  14. package/themes/business/src/components/LanguageSelector/index.tsx +1 -1
  15. package/themes/business/src/components/LoginForm/index.tsx +123 -98
  16. package/themes/business/src/components/LogoutButton/index.tsx +13 -4
  17. package/themes/business/src/components/MapView/RenderMarker.tsx +146 -0
  18. package/themes/business/src/components/MapView/index.tsx +68 -142
  19. package/themes/business/src/components/NewOrderNotification/index.tsx +38 -54
  20. package/themes/business/src/components/OrderDetails/Business.tsx +56 -20
  21. package/themes/business/src/components/OrderDetails/Delivery.tsx +123 -54
  22. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +146 -36
  23. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +51 -28
  24. package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
  25. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +17 -16
  26. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
  27. package/themes/business/src/components/OrderSummary/index.tsx +271 -176
  28. package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
  29. package/themes/business/src/components/OrdersOption/index.tsx +219 -144
  30. package/themes/business/src/components/OrdersOption/styles.tsx +14 -0
  31. package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
  32. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +20 -8
  33. package/themes/business/src/components/PreviousOrders/index.tsx +74 -66
  34. package/themes/business/src/components/PreviousOrders/styles.tsx +2 -1
  35. package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
  36. package/themes/business/src/components/PrinterEdition/index.tsx +143 -75
  37. package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
  38. package/themes/business/src/components/PrinterSettings/index.tsx +1 -1
  39. package/themes/business/src/components/ProductItemAccordion/index.tsx +15 -16
  40. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  41. package/themes/business/src/components/StoresList/index.tsx +2 -2
  42. package/themes/business/src/components/UserProfileForm/index.tsx +48 -10
  43. package/themes/business/src/components/UserProfileForm/styles.tsx +7 -0
  44. package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
  45. package/themes/business/src/config/currency.tsx +1010 -0
  46. package/themes/business/src/hooks/useLocation.tsx +16 -12
  47. package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
  48. package/themes/business/src/types/index.tsx +28 -4
  49. package/themes/business/src/utils/index.tsx +28 -3
  50. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  51. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  52. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  53. package/themes/kiosk/src/components/Checkout/index.tsx +9 -5
  54. package/themes/kiosk/src/components/CustomerName/index.tsx +1 -1
  55. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  56. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  57. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  58. package/themes/kiosk/src/components/PaymentOptions/index.tsx +121 -57
  59. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  60. package/themes/original/index.tsx +223 -219
  61. package/themes/original/src/components/AddressForm/index.tsx +922 -885
  62. package/themes/original/src/components/AppleLogin/index.tsx +3 -4
  63. package/themes/original/src/components/BusinessController/index.tsx +4 -2
  64. package/themes/original/src/components/BusinessItemAccordion/index.tsx +10 -4
  65. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +103 -92
  66. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +7 -3
  67. package/themes/original/src/components/BusinessListingSearch/index.tsx +8 -13
  68. package/themes/original/src/components/BusinessPreorder/index.tsx +30 -17
  69. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +73 -70
  70. package/themes/original/src/components/BusinessProductsList/index.tsx +6 -7
  71. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  72. package/themes/original/src/components/BusinessProductsListing/index.tsx +5 -4
  73. package/themes/original/src/components/BusinessTypeFilter/index.tsx +9 -8
  74. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
  75. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  76. package/themes/original/src/components/Cart/index.tsx +44 -12
  77. package/themes/original/src/components/CartContent/index.tsx +0 -2
  78. package/themes/original/src/components/Checkout/index.tsx +126 -98
  79. package/themes/original/src/components/ForgotPasswordForm/index.tsx +1 -2
  80. package/themes/original/src/components/GPSButton/index.tsx +2 -1
  81. package/themes/original/src/components/GoogleMap/index.tsx +3 -2
  82. package/themes/original/src/components/Help/functions.tsx +76 -0
  83. package/themes/original/src/components/Help/index.tsx +74 -29
  84. package/themes/original/src/components/Help/styles.tsx +4 -1
  85. package/themes/original/src/components/HelpOptions/index.tsx +53 -0
  86. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
  87. package/themes/original/src/components/Home/index.tsx +36 -11
  88. package/themes/original/src/components/LastOrder/index.tsx +1 -1
  89. package/themes/original/src/components/LoginForm/index.tsx +11 -5
  90. package/themes/original/src/components/MessageListing/index.tsx +1 -1
  91. package/themes/original/src/components/Messages/index.tsx +562 -555
  92. package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
  93. package/themes/original/src/components/MomentOption/index.tsx +141 -61
  94. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  95. package/themes/original/src/components/MomentSelector/index.tsx +5 -2
  96. package/themes/original/src/components/MultiCheckout/index.tsx +78 -36
  97. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +2 -2
  98. package/themes/original/src/components/MultiOrdersDetails/index.tsx +2 -2
  99. package/themes/original/src/components/NavBar/index.tsx +6 -2
  100. package/themes/original/src/components/NotFoundSource/index.tsx +40 -39
  101. package/themes/original/src/components/NotFoundSource/styles.tsx +18 -9
  102. package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
  103. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +11 -4
  104. package/themes/original/src/components/OrderDetails/index.tsx +45 -21
  105. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  106. package/themes/original/src/components/OrderProgress/index.tsx +5 -4
  107. package/themes/original/src/components/OrderSummary/index.tsx +32 -11
  108. package/themes/original/src/components/OrderTypeSelector/index.tsx +120 -120
  109. package/themes/original/src/components/OrdersOption/index.tsx +325 -325
  110. package/themes/original/src/components/PaymentOptionWallet/index.tsx +1 -0
  111. package/themes/original/src/components/PaymentOptions/index.tsx +471 -459
  112. package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
  113. package/themes/original/src/components/ProductForm/ActionButton.tsx +6 -10
  114. package/themes/original/src/components/ProductItemAccordion/index.tsx +28 -37
  115. package/themes/original/src/components/ProductOptionSubOption/index.tsx +15 -14
  116. package/themes/original/src/components/ServiceForm/index.tsx +2 -2
  117. package/themes/original/src/components/SignupForm/index.tsx +40 -24
  118. package/themes/original/src/components/SingleOrderCard/index.tsx +8 -5
  119. package/themes/original/src/components/SingleProductCard/index.tsx +3 -4
  120. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  121. package/themes/original/src/components/StripeCardsList/index.tsx +9 -4
  122. package/themes/original/src/components/StripeElementsForm/index.tsx +2 -2
  123. package/themes/original/src/components/TaxInformation/index.tsx +3 -2
  124. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +7 -2
  125. package/themes/original/src/components/UserDetails/index.tsx +17 -16
  126. package/themes/original/src/components/UserFormDetails/index.tsx +109 -67
  127. package/themes/original/src/components/UserVerification/index.tsx +18 -5
  128. package/themes/original/src/components/VerifyPhone/index.tsx +1 -1
  129. package/themes/original/src/components/shared/OButton.tsx +2 -2
  130. package/themes/original/src/components/shared/OInput.tsx +97 -97
  131. package/themes/original/src/components/shared/OModal.tsx +7 -2
  132. package/themes/original/src/providers/AlertProvider.tsx +1 -1
  133. package/themes/original/src/types/index.tsx +700 -695
  134. package/themes/original/src/utils/index.tsx +50 -34
  135. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  136. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +0 -62
  137. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +0 -12
  138. package/themes/original/src/components/HelpGuide/index.tsx +0 -68
  139. package/themes/original/src/components/HelpGuide/styles.tsx +0 -12
  140. package/themes/original/src/components/HelpOrder/index.tsx +0 -71
  141. package/themes/original/src/components/HelpOrder/styles.tsx +0 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.22.71",
3
+ "version": "0.22.72-release",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -36,7 +36,7 @@
36
36
  "@fatnlazycat/react-native-recaptcha-v3": "^1.0.3",
37
37
  "@invertase/react-native-apple-authentication": "^2.1.5",
38
38
  "@react-native-async-storage/async-storage": "^1.15.5",
39
- "@react-native-clipboard/clipboard": "^1.8.4",
39
+ "@react-native-clipboard/clipboard": "1.14.0",
40
40
  "@react-native-community/checkbox": "^0.5.8",
41
41
  "@react-native-community/geolocation": "^2.0.2",
42
42
  "@react-native-community/masked-view": "^0.1.10",
@@ -51,14 +51,13 @@
51
51
  "@react-navigation/stack": "^5.9.3",
52
52
  "@segment/analytics-react-native": "2.1.11",
53
53
  "@segment/sovran-react-native": "0.2.6",
54
- "@sentry/react-native": "^2.6.0",
55
- "@stripe/stripe-react-native": "0.23.0",
54
+ "@stripe/stripe-react-native": "0.23.0",
56
55
  "@types/react-native-loading-spinner-overlay": "^0.5.2",
57
56
  "@types/react-native-snap-carousel": "^3.8.4",
58
57
  "@types/styled-components": "^5.1.3",
59
58
  "axios": "^0.21.0",
60
59
  "moment": "^2.29.1",
61
- "ordering-components": "github:Ordering-Inc/ordering-components#development",
60
+ "ordering-components": "github:Ordering-Inc/ordering-components#release",
62
61
  "patch-package": "^6.4.7",
63
62
  "postinstall-postinstall": "^2.1.0",
64
63
  "prop-types": "^15.7.2",
@@ -91,7 +90,7 @@
91
90
  "react-native-image-picker": "^4.0.6",
92
91
  "react-native-intersection-observer": "^0.0.9",
93
92
  "react-native-lightbox": "^0.8.1",
94
- "react-native-linear-gradient": "^2.5.6",
93
+ "react-native-linear-gradient": "2.7.3",
95
94
  "react-native-loading-spinner-overlay": "^2.0.0",
96
95
  "react-native-map-link": "^2.8.2",
97
96
  "react-native-maps": "^0.28.0",
@@ -102,7 +101,6 @@
102
101
  "react-native-phone-number-input": "^2.0.0",
103
102
  "react-native-picker-select": "^8.0.4",
104
103
  "react-native-print": "^0.9.0",
105
- "react-native-reanimated": "^1.13.1",
106
104
  "react-native-recaptcha-that-works": "^1.2.0",
107
105
  "react-native-restart": "^0.0.22",
108
106
  "react-native-safe-area-context": "^3.1.8",
@@ -191,7 +191,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
191
191
  {isFarAway && (
192
192
  <FarAwayMessage style={styles.farAwayMsg}>
193
193
  <Ionicons name='md-warning-outline' style={styles.iconStyle} />
194
- <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'You are far from this address')}</OText>
194
+ <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'Your are far from this address')}</OText>
195
195
  </FarAwayMessage>
196
196
  )}
197
197
  </OrderControlContainer>
@@ -295,6 +295,7 @@ const CheckoutUI = (props: any) => {
295
295
  </Placeholder>
296
296
  ) : (
297
297
  <AddressDetails
298
+ cart={cart}
298
299
  navigation={navigation}
299
300
  location={businessDetails?.business?.location}
300
301
  businessLogo={businessDetails?.business?.logo}
@@ -598,14 +599,14 @@ const CheckoutUI = (props: any) => {
598
599
  validationFields?.fields?.checkout?.driver_tip?.enabled &&
599
600
  validationFields?.fields?.checkout?.driver_tip?.required &&
600
601
  (Number(cart?.driver_tip) <= 0) && (
601
- <OText
602
- style={{ textAlign: 'center' }}
603
- color={theme.colors.error}
604
- size={14}
605
- >
606
- {t('WARNING_INVALID_DRIVER_TIP', 'Driver Tip is required.')}
607
- </OText>
608
- )}
602
+ <OText
603
+ style={{ textAlign: 'center' }}
604
+ color={theme.colors.error}
605
+ size={14}
606
+ >
607
+ {t('WARNING_INVALID_DRIVER_TIP', 'Driver Tip is required.')}
608
+ </OText>
609
+ )}
609
610
  </ChErrors>
610
611
  </ChSection>
611
612
  )}
@@ -617,15 +618,15 @@ const CheckoutUI = (props: any) => {
617
618
  <FloatingButton
618
619
  handleClick={() => handlePlaceOrder()}
619
620
  isSecondaryBtn={loading || !cart?.valid || !paymethodSelected || placing || errorCash || cart?.subtotal_to_calculate < cart?.minimum || paymethodSelected?.gateway === 'paypal' ||
620
- (options.type === 1 &&
621
- validationFields?.fields?.checkout?.driver_tip?.enabled &&
622
- validationFields?.fields?.checkout?.driver_tip?.required &&
623
- (Number(cart?.driver_tip) <= 0))}
621
+ (options.type === 1 &&
622
+ validationFields?.fields?.checkout?.driver_tip?.enabled &&
623
+ validationFields?.fields?.checkout?.driver_tip?.required &&
624
+ (Number(cart?.driver_tip) <= 0))}
624
625
  disabled={loading || !cart?.valid || !paymethodSelected || placing || errorCash || cart?.subtotal_to_calculate < cart?.minimum || paymethodSelected?.gateway === 'paypal' ||
625
- (options.type === 1 &&
626
- validationFields?.fields?.checkout?.driver_tip?.enabled &&
627
- validationFields?.fields?.checkout?.driver_tip?.required &&
628
- (Number(cart?.driver_tip) <= 0))}
626
+ (options.type === 1 &&
627
+ validationFields?.fields?.checkout?.driver_tip?.enabled &&
628
+ validationFields?.fields?.checkout?.driver_tip?.required &&
629
+ (Number(cart?.driver_tip) <= 0))}
629
630
  btnText={cart?.subtotal_to_calculate >= cart?.minimum
630
631
  ? (
631
632
  placing
@@ -641,31 +642,31 @@ const CheckoutUI = (props: any) => {
641
642
  </>
642
643
  )}
643
644
  {webviewPaymethod?.gateway === 'paypal' && showGateway.open && (
644
- <PaymentOptionsWebView
645
- onNavigationRedirect={onNavigationRedirect}
646
- uri={`${ordering.root}/html/paypal_react_native`}
647
- user={user}
648
- token={token}
649
- cart={cart}
650
- currency={currency}
651
- webviewPaymethod={webviewPaymethod}
652
- setShowGateway={setShowGateway}
653
- setOpenOrderCreating={setOpenOrderCreating}
654
- />
645
+ <PaymentOptionsWebView
646
+ onNavigationRedirect={onNavigationRedirect}
647
+ uri={`${ordering.root}/html/paypal_react_native`}
648
+ user={user}
649
+ token={token}
650
+ cart={cart}
651
+ currency={currency}
652
+ webviewPaymethod={webviewPaymethod}
653
+ setShowGateway={setShowGateway}
654
+ setOpenOrderCreating={setOpenOrderCreating}
655
+ />
655
656
  )}
656
657
  {webviewPaymethod?.gateway === 'square' && showGateway.open && (
657
- <PaymentOptionsWebView
658
- onNavigationRedirect={onNavigationRedirect}
659
- uri={`https://test-square-f50f7.web.app`}
660
- user={user}
661
- token={token}
662
- cart={cart}
663
- currency={currency}
664
- webviewPaymethod={webviewPaymethod}
665
- setShowGateway={setShowGateway}
666
- setOpenOrderCreating={setOpenOrderCreating}
667
- locationId={'L1NGAY5M6KJRX'}
668
- />
658
+ <PaymentOptionsWebView
659
+ onNavigationRedirect={onNavigationRedirect}
660
+ uri={`https://test-square-f50f7.web.app`}
661
+ user={user}
662
+ token={token}
663
+ cart={cart}
664
+ currency={currency}
665
+ webviewPaymethod={webviewPaymethod}
666
+ setShowGateway={setShowGateway}
667
+ setOpenOrderCreating={setOpenOrderCreating}
668
+ locationId={'L1NGAY5M6KJRX'}
669
+ />
669
670
  )}
670
671
  {openOrderCreating && (
671
672
  <View style={{ zIndex: 9999, height: '100%', width: '100%', position: 'absolute', backgroundColor: 'white' }}>
@@ -2,7 +2,7 @@ import styled from 'styled-components/native';
2
2
 
3
3
  export const Container = styled.View`
4
4
  width: 100%;
5
- padding: 0 43px;
5
+ padding: 0 30px;
6
6
  `
7
7
 
8
8
  export const CountDownContainer = styled.View`
@@ -20,7 +20,6 @@ export const ResendSection = styled.View`
20
20
  display: flex;
21
21
  flex-direction: row;
22
22
  justify-content: center;
23
- flex-wrap: wrap;
24
23
  `
25
24
 
26
25
  export const WrappCountdown = styled.View`
@@ -0,0 +1,236 @@
1
+ import React, { useState, createContext, useEffect, useContext } from 'react';
2
+ import { useApi, useSession, useEvent, useWebsocket } from 'ordering-components/native'
3
+ import { useNetInfo } from '@react-native-community/netinfo';
4
+
5
+ import { _retrieveStoreData, _setStoreData, _removeStoreData } from '../../providers/StoreUtil'
6
+
7
+ type State = {
8
+ isNetConnected: boolean | null
9
+ isCombinedTabs: boolean | null
10
+ canSaveChangesOffline: boolean | null
11
+ actions: { [key: string]: any }
12
+ orders: { [key: string]: any } | null
13
+ }
14
+
15
+ type Functions = {
16
+ applyOffAction: (changes: any) => any
17
+ registerOffOrder: (order: any) => any
18
+ setState: React.Dispatch<React.SetStateAction<State>>
19
+ }
20
+
21
+ const defaultState = {
22
+ isNetConnected: null,
23
+ isCombinedTabs: null,
24
+ canSaveChangesOffline: false,
25
+ actions: {},
26
+ orders: null,
27
+ }
28
+
29
+
30
+ export const OfflineActionsContext = createContext<[State, Functions]>([
31
+ defaultState,
32
+ {
33
+ applyOffAction: () => {},
34
+ registerOffOrder: () => {},
35
+ setState: () => {}
36
+ }
37
+ ]);
38
+
39
+ export const OfflineActionsProvider = (props: any) => {
40
+ const netInfo = useNetInfo()
41
+ const [ordering] = useApi()
42
+ const [{ token }] = useSession()
43
+ const [events] = useEvent()
44
+ const socket = useWebsocket()
45
+
46
+ const [state, setState] = useState<State>({
47
+ isNetConnected: netInfo.isConnected,
48
+ isCombinedTabs: false,
49
+ canSaveChangesOffline: false,
50
+ actions: [],
51
+ orders: null
52
+ })
53
+
54
+ const getStatusById = (id: number) => {
55
+ if (!id && id !== 0) return
56
+ const active = [0, 3, 4, 7, 8, 9, 13, 14, 18, 19, 20, 21]
57
+ const pending = [0, 13]
58
+ const inProgress = [3, 4, 7, 8, 9, 14, 18, 19, 20, 21]
59
+ const completed = [1, 11, 15]
60
+
61
+ const status = pending.includes(id)
62
+ ? 'pending'
63
+ : inProgress.includes(id)
64
+ ? 'inProgress'
65
+ : completed.includes(id)
66
+ ? 'completed'
67
+ : 'cancelled'
68
+
69
+ const combinedStatus = active.includes(id)
70
+ ? 'active'
71
+ : completed.includes(id)
72
+ ? 'completed'
73
+ : 'cancelled'
74
+
75
+ return state.isCombinedTabs ? combinedStatus : status
76
+ }
77
+
78
+ const applyOffAction = async (changes: any) => {
79
+ if (state.canSaveChangesOffline === false) return false
80
+
81
+ let _actions: any = state.actions?.[changes?.data?.orderId] ?? []
82
+
83
+ if (state.actions?.[changes?.data?.orderId]) {
84
+ _actions.push(changes)
85
+ } else {
86
+ _actions = [changes]
87
+ }
88
+ const actions = { ...state.actions, [changes?.data?.orderId]: _actions }
89
+
90
+ setState(state => ({ ...state, actions }))
91
+ await _setStoreData('offline_actions_array', actions)
92
+ return true
93
+ }
94
+
95
+ const registerOffOrder = async (order: any) => {
96
+ if (!order) return
97
+
98
+ const oldStatusString = getStatusById(order?.oldStatus)
99
+ const newStatusString = getStatusById(order?.status)
100
+
101
+ const orderStatuses: any = [oldStatusString]
102
+ oldStatusString !== newStatusString && orderStatuses.push(newStatusString)
103
+
104
+ const ordersStoraged: any = {}
105
+ for (const status of orderStatuses) {
106
+ ordersStoraged[status] = await _retrieveStoreData(`${status}_orders`)
107
+
108
+ if (ordersStoraged[status]) {
109
+ if (orderStatuses.length === 1) {
110
+ ordersStoraged[status] = [
111
+ ...ordersStoraged[status].filter((_order: any) => _order.id !== order.id),
112
+ order
113
+ ].sort((a: any, b: any) => b.id - a.id)
114
+ } else if (orderStatuses.length === 2) {
115
+ if (status === oldStatusString) {
116
+ ordersStoraged[status] = ordersStoraged[status]
117
+ .filter((_order: any) => _order.id !== order.id)
118
+ .sort((a: any, b: any) => b.id - a.id)
119
+ }
120
+ if (status === newStatusString) {
121
+ ordersStoraged[status] = [
122
+ ...ordersStoraged[status],
123
+ order
124
+ ].sort((a: any, b: any) => b.id - a.id)
125
+ }
126
+ }
127
+ await _setStoreData(`${status}_orders`, ordersStoraged[status]);
128
+ } else {
129
+ ordersStoraged[status] = [order]
130
+ }
131
+ }
132
+ if (Object.keys(ordersStoraged).length) {
133
+ setState(state => ({ ...state, orders: ordersStoraged }))
134
+ }
135
+ }
136
+
137
+ const syncChanges = async (changes: any) => {
138
+ const ordersIdUpdated: any = []
139
+
140
+ Object.keys(changes).forEach(async (orderId) => {
141
+ const arr = changes[orderId]
142
+
143
+ const [lastChange, ...restOfChanges] = arr.reverse();
144
+
145
+ if (restOfChanges.length > 0) {
146
+ const ordersString = restOfChanges
147
+ .map((obj: any) => (
148
+ Object.entries(obj?.data?.body).map(([clave, valor]) => `${clave}: '${valor}'`).join(', ')
149
+ ))
150
+ .join(', ')
151
+ handleSendMessage({ message: ordersString, orderId })
152
+ }
153
+ const id = await updateOrderStatus({ orderId, body: lastChange?.data?.body })
154
+ id && ordersIdUpdated.push(id);
155
+ });
156
+
157
+ ordersIdUpdated.length && events.emit('offline_order_updated', ordersIdUpdated)
158
+ await _removeStoreData('offline_actions_array');
159
+ setState(state => ({ ...state, actions: [] }));
160
+ }
161
+
162
+ const actionsFromStorage = async (isConnected: boolean) => {
163
+ setState(state => ({ ...state, isNetConnected: isConnected }))
164
+ const storedActions = await _retrieveStoreData('offline_actions_array');
165
+
166
+ if (isConnected && Object.keys(storedActions)?.length) {
167
+ syncChanges(storedActions)
168
+ return
169
+ }
170
+
171
+ Object.keys(storedActions)?.length && setState(state => ({ ...state, actions: storedActions }));
172
+ }
173
+
174
+ useEffect(() => {
175
+ if (netInfo.isConnected === null || state.canSaveChangesOffline === false) return
176
+ actionsFromStorage(netInfo.isConnected)
177
+ }, [netInfo.isConnected])
178
+
179
+ const functions: any = {
180
+ applyOffAction,
181
+ registerOffOrder,
182
+ setState
183
+ }
184
+
185
+ const updateOrderStatus = async (offlineData: any) => {
186
+ try {
187
+ const { content: { result: order, error } } = await ordering
188
+ .setAccessToken(token)
189
+ .orders(offlineData?.orderId)
190
+ .save(offlineData?.body)
191
+
192
+ return error ? null : order?.id
193
+ } catch {
194
+ return null
195
+ }
196
+ }
197
+
198
+ const handleSendMessage = async (offlineData: any) => {
199
+ try {
200
+ const _canRead = [0, 2, 3, 4]
201
+ const body = {
202
+ comment: offlineData?.message,
203
+ type: 2,
204
+ can_see: _canRead.join(',')
205
+ }
206
+ const response = await fetch(`${ordering.root}/orders/${offlineData?.orderId}/messages`, {
207
+ method: 'POST',
208
+ headers: {
209
+ 'Content-Type': 'application/json',
210
+ Authorization: `Bearer ${token}`,
211
+ 'X-App-X': ordering.appId,
212
+ 'X-Socket-Id-X': socket?.getId()
213
+ },
214
+ body: JSON.stringify(body)
215
+ })
216
+ const { error, result } = await response.json()
217
+ } catch {
218
+ return null
219
+ }
220
+ }
221
+
222
+ const eventsDictiorary: any = {
223
+ evt_off_change_order_status: updateOrderStatus
224
+ }
225
+
226
+ return (
227
+ <OfflineActionsContext.Provider value={[{ ...state, isNetConnected: netInfo.isConnected }, functions]}>
228
+ {props.children}
229
+ </OfflineActionsContext.Provider>
230
+ );
231
+ };
232
+
233
+ export const useOfflineActions = () => {
234
+ const actionsManager = useContext(OfflineActionsContext)
235
+ return actionsManager || [defaultState, {}]
236
+ }
@@ -8,7 +8,8 @@ interface Props {
8
8
  title: string,
9
9
  content: Array<string>,
10
10
  onClose: () => void,
11
- onAccept: () => void
11
+ onAccept: () => void,
12
+ onCancel: () => void
12
13
  }
13
14
 
14
15
  const Alert = (props: Props) => {
@@ -38,6 +39,7 @@ const Alert = (props: Props) => {
38
39
  confirmText={t('ACCEPT', 'Accept')}
39
40
  confirmButtonColor={theme.colors.primary}
40
41
  onCancelPressed={() => onClose()}
42
+ showCancelButton={!!props.onCancel}
41
43
  onConfirmPressed={() => onAccept()}
42
44
  />
43
45
  )
@@ -428,13 +428,15 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
428
428
  {action === 'accept' && (
429
429
  <View style={{ height: 300, justifyContent: 'center' }}>
430
430
  <Timer onPress={() => openTimerIOnput()}>
431
- <OText weight="600" style={{ textAlign: 'center' }} size={55}>
431
+ <OText weight="600" size={55}>
432
432
  {hour}
433
433
  </OText>
434
- {hour.length > 0 && <OText size={55}>:</OText>}
435
- <OText weight="600" style={{ textAlign: 'center' }} size={55}>
434
+ {hour.length > 0 && <OText size={55} style={{ marginBottom: 10 }}>:</OText>}
435
+ <OText weight="600" size={55}>
436
436
  {min}
437
437
  </OText>
438
+ {time?.length > 2 && <OText style={{ position: 'absolute', bottom: 60, left: 55 }}>{t('HOURS', 'Hours')}</OText>}
439
+ <OText style={{ position: 'absolute', bottom: 60, right: time?.length > 2 ? 55 : 95 }}>{t('MINUTES', 'Minutes')}</OText>
438
440
  </Timer>
439
441
  </View>
440
442
  )}
@@ -10,6 +10,7 @@ export const TopActions = styled.View`
10
10
  `
11
11
 
12
12
  export const Timer = styled.TouchableOpacity`
13
+ position: relative;
13
14
  padding: 40px;
14
15
  justify-content: center;
15
16
  flex-direction: row;
@@ -1,5 +1,6 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import { StyleSheet, View, ActivityIndicator, TouchableOpacity } from 'react-native';
3
+ import FastImage from 'react-native-fast-image'
3
4
  import ToggleSwitch from 'toggle-switch-react-native';
4
5
  import { useTheme } from 'styled-components/native';
5
6
  import {
@@ -99,10 +100,14 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
99
100
  onPress={() => navigation && business?.slug && navigation.navigate('BusinessProductListing', { slug: business?.slug })}
100
101
  >
101
102
  <Logo style={styles.logo}>
102
- <OIcon
103
- url={optimizeImage(business?.logo, 'h_300,c_limit')}
104
- src={!business?.logo && theme?.images?.dummies?.businessLogo}
103
+ <FastImage
105
104
  style={styles.icon}
105
+ source={business?.logo?.includes('https') ? {
106
+ uri: business?.logo,
107
+ priority: FastImage.priority.high,
108
+ cache: FastImage.cacheControl.immutable
109
+ } : business?.logo ?? theme?.images?.dummies?.businessLogo}
110
+ resizeMode={FastImage.resizeMode.cover}
106
111
  />
107
112
  </Logo>
108
113
  <Information>
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { View, StyleSheet, ScrollView, Dimensions, TouchableOpacity } from 'react-native';
2
+ import { View, StyleSheet, ScrollView, Dimensions, TouchableOpacity, Platform } from 'react-native';
3
3
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
4
4
  import { useTheme } from 'styled-components/native';
5
5
  import { SearchBar } from '../SearchBar';
@@ -115,7 +115,7 @@ const BusinessProductListUI = (props: any) => {
115
115
  <ScrollView
116
116
  showsVerticalScrollIndicator={false}
117
117
  style={styles.container}>
118
- {!loading && business?.categories?.length === 0 && (
118
+ {!loading && categories?.length === 0 && (
119
119
  <NotFoundSource
120
120
  content={t('NO_RESULTS_FOUND', 'Sorry, no results found')}
121
121
  image={theme.images.general.notFound}
@@ -190,6 +190,7 @@ export const BusinessProductList = (props: any) => {
190
190
  const businessProductListProps = {
191
191
  ...props,
192
192
  UIComponent: BusinessProductListUI,
193
+ isIos: Platform.OS === 'ios'
193
194
  };
194
195
 
195
196
  return <StoreProductList {...businessProductListProps} />;
@@ -36,6 +36,7 @@ import {
36
36
  useSession,
37
37
  useUtils,
38
38
  useLanguage,
39
+ useConfig
39
40
  } from 'ordering-components/native';
40
41
  import { Header, TitleHeader, Wrapper, QuickMessageContainer } from './styles';
41
42
  import { OIcon, OIconButton, OText, OButton } from '../shared';
@@ -68,8 +69,9 @@ const ChatUI = (props: MessagesParams) => {
68
69
  const [, t] = useLanguage();
69
70
  const [, { showToast }] = useToast();
70
71
  const theme = useTheme();
72
+ const [{ configs }] = useConfig();
71
73
  const [messageList, setMessageList] = useState<any>([])
72
- const previousStatus = [1, 2, 5, 6, 10, 11, 12, 16, 17]
74
+ const previousStatus = [1, 2, 5, 6, 10, 11, 12, 15, 16, 17]
73
75
  const chatDisabled = previousStatus.includes(order?.status)
74
76
 
75
77
  const ORDER_STATUS: any = {
@@ -96,7 +98,10 @@ const ChatUI = (props: MessagesParams) => {
96
98
  20: t('ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS', 'Order customer almost arrived to business'),
97
99
  21: t('ORDER_CUSTOMER_ARRIVED_BUSINESS', 'Order customer arrived to business'),
98
100
  22: t('ORDER_LOOKING_FOR_DRIVER', 'Order looking for driver'),
99
- 23: t('ORDER_DRIVER_ON_WAY', 'Driver on way')
101
+ 23: t('ORDER_DRIVER_ON_WAY', 'Driver on way'),
102
+ 24: t('ORDER_DRIVER_WAITING_FOR_ORDER', 'Driver waiting for order'),
103
+ 25: t('ORDER_ACCEPTED_BY_DRIVER_COMPANY', 'Accepted by driver company'),
104
+ 26: t('ORDER_DRIVER_ARRIVED_CUSTOMER', 'Driver arrived to customer')
100
105
  }
101
106
 
102
107
  const getLogisticTag = (status: any) => {
@@ -498,6 +503,7 @@ const ChatUI = (props: MessagesParams) => {
498
503
 
499
504
  const firstMessage = {
500
505
  _id: 0,
506
+ type: 0,
501
507
  text: console,
502
508
  createdAt: parseDate(order?.created_at, { outputFormat: 'YYYY-MM-DD HH:mm:ss' }),
503
509
  system: true,
@@ -517,6 +523,7 @@ const ChatUI = (props: MessagesParams) => {
517
523
  text: message.type === 1 ? messageConsole(message) : message.comment,
518
524
  createdAt: message.type !== 0 && parseDate(message?.created_at, { outputFormat: 'YYYY-MM-DD HH:mm:ss' }),
519
525
  image: message.source,
526
+ type: message.type,
520
527
  system: message.type === 1,
521
528
  user: {
522
529
  _id: message.author?.id,
@@ -537,7 +544,12 @@ const ChatUI = (props: MessagesParams) => {
537
544
  newMessages = [...newMessages, newMessage];
538
545
  }
539
546
  });
540
- setFormattedMessages([...newMessages.reverse()]);
547
+ let _arrayMessages = [...newMessages.reverse()]
548
+
549
+ if (configs?.order_logbook_enabled?.value === '0' && user?.level === 4) {
550
+ _arrayMessages = _arrayMessages.filter(msg => msg.type !== 1 && msg.type !== 0)
551
+ }
552
+ setFormattedMessages(_arrayMessages);
541
553
  }, [messages?.messages?.length]);
542
554
 
543
555
  useEffect(() => {