ordering-ui-react-native 0.21.9 → 0.21.10-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 (240) hide show
  1. package/package.json +6 -5
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessInformation/index.tsx +10 -9
  4. package/src/components/BusinessesListing/index.tsx +1 -1
  5. package/src/components/PaymentOptionsWebView/index.tsx +1 -0
  6. package/src/components/StripeMethodForm/index.tsx +4 -4
  7. package/src/components/VerifyPhone/styles.tsx +1 -2
  8. package/src/components/shared/OToast.tsx +3 -2
  9. package/src/types/index.tsx +2 -1
  10. package/src/utils/index.tsx +2 -2
  11. package/themes/business/index.tsx +4 -0
  12. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -2
  13. package/themes/business/src/components/BusinessController/index.tsx +19 -17
  14. package/themes/business/src/components/BusinessProductList/AccordionDropdown.tsx +63 -0
  15. package/themes/business/src/components/BusinessProductList/IterateCategories.tsx +108 -0
  16. package/themes/business/src/components/BusinessProductList/ProductList.tsx +196 -0
  17. package/themes/business/src/components/BusinessProductList/index.tsx +196 -0
  18. package/themes/business/src/components/BusinessProductList/styles.tsx +10 -0
  19. package/themes/business/src/components/Chat/index.tsx +41 -13
  20. package/themes/business/src/components/DriverMap/index.tsx +4 -2
  21. package/themes/business/src/components/DriverSchedule/index.tsx +5 -5
  22. package/themes/business/src/components/FloatingButton/index.tsx +34 -31
  23. package/themes/business/src/components/Home/index.tsx +5 -1
  24. package/themes/business/src/components/MapView/index.tsx +11 -7
  25. package/themes/business/src/components/MessagesOption/index.tsx +22 -94
  26. package/themes/business/src/components/NewOrderNotification/index.tsx +161 -106
  27. package/themes/business/src/components/OrderDetails/Business.tsx +47 -1
  28. package/themes/business/src/components/OrderDetails/Delivery.tsx +21 -11
  29. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +56 -50
  30. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +54 -23
  31. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +220 -0
  32. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +6 -1
  33. package/themes/business/src/components/OrderSummary/index.tsx +240 -76
  34. package/themes/business/src/components/OrdersListManager/index.tsx +7 -2
  35. package/themes/business/src/components/OrdersListManager/utils.tsx +1 -1
  36. package/themes/business/src/components/OrdersOption/index.tsx +125 -48
  37. package/themes/business/src/components/PreviousMessages/FooterMessageComponent.tsx +103 -0
  38. package/themes/business/src/components/PreviousMessages/index.tsx +97 -55
  39. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +26 -34
  40. package/themes/business/src/components/PreviousOrders/OrderList.tsx +93 -0
  41. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +1 -1
  42. package/themes/business/src/components/PreviousOrders/index.tsx +192 -220
  43. package/themes/business/src/components/PreviousOrders/styles.tsx +10 -0
  44. package/themes/business/src/components/PrinterSettings/index.tsx +279 -0
  45. package/themes/business/src/components/PrinterSettings/styles.tsx +17 -0
  46. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  47. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  48. package/themes/business/src/components/SearchBar/index.tsx +2 -1
  49. package/themes/business/src/components/Sessions/index.tsx +187 -0
  50. package/themes/business/src/components/Sessions/styles.tsx +20 -0
  51. package/themes/business/src/components/StoresList/index.tsx +5 -3
  52. package/themes/business/src/components/UserProfileForm/index.tsx +98 -44
  53. package/themes/business/src/components/WebsocketStatus/index.tsx +171 -0
  54. package/themes/business/src/components/WebsocketStatus/styles.tsx +28 -0
  55. package/themes/business/src/components/shared/OInput.tsx +2 -0
  56. package/themes/business/src/hooks/useLocation.tsx +5 -4
  57. package/themes/business/src/types/index.tsx +21 -1
  58. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  59. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  60. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  61. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  62. package/themes/kiosk/src/components/LoginForm/index.tsx +124 -96
  63. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  64. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  65. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  66. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  67. package/themes/original/index.tsx +9 -4
  68. package/themes/original/src/components/AddressDetails/index.tsx +20 -10
  69. package/themes/original/src/components/AddressForm/index.tsx +2 -2
  70. package/themes/original/src/components/AddressForm/styles.tsx +1 -1
  71. package/themes/original/src/components/AddressList/index.tsx +4 -7
  72. package/themes/original/src/components/AddressList/styles.tsx +4 -4
  73. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  74. package/themes/original/src/components/BusinessBasicInformation/index.tsx +4 -4
  75. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +1 -1
  76. package/themes/original/src/components/BusinessController/index.tsx +20 -12
  77. package/themes/original/src/components/BusinessController/styles.tsx +8 -7
  78. package/themes/original/src/components/BusinessInformation/styles.tsx +2 -2
  79. package/themes/original/src/components/BusinessItemAccordion/index.tsx +11 -7
  80. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +317 -0
  81. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +96 -0
  82. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +1 -1
  83. package/themes/original/src/components/BusinessListingSearch/index.tsx +56 -361
  84. package/themes/original/src/components/BusinessListingSearch/styles.tsx +1 -1
  85. package/themes/original/src/components/BusinessPreorder/index.tsx +2 -3
  86. package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -1
  87. package/themes/original/src/components/BusinessProductsList/index.tsx +3 -3
  88. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  89. package/themes/original/src/components/BusinessProductsListing/index.tsx +43 -20
  90. package/themes/original/src/components/BusinessProductsListing/styles.tsx +3 -4
  91. package/themes/original/src/components/BusinessReviews/index.tsx +1 -1
  92. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  93. package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +5 -5
  94. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
  95. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
  96. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
  97. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +30 -404
  98. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  99. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  100. package/themes/original/src/components/Cart/index.tsx +32 -9
  101. package/themes/original/src/components/CartContent/index.tsx +96 -58
  102. package/themes/original/src/components/CartStoresListing/styles.tsx +2 -2
  103. package/themes/original/src/components/Checkout/index.tsx +190 -66
  104. package/themes/original/src/components/Checkout/styles.tsx +17 -0
  105. package/themes/original/src/components/CitiesControl/styles.tsx +1 -1
  106. package/themes/original/src/components/DatePicker/index.tsx +33 -0
  107. package/themes/original/src/components/DatePicker/styles.tsx +20 -0
  108. package/themes/original/src/components/Favorite/index.tsx +4 -9
  109. package/themes/original/src/components/Favorite/styles.tsx +0 -2
  110. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  111. package/themes/original/src/components/GPSButton/index.tsx +1 -1
  112. package/themes/original/src/components/GiftCard/GiftCardOrdersList/index.tsx +64 -0
  113. package/themes/original/src/components/GiftCard/GiftCardOrdersList/styles.tsx +8 -0
  114. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +8 -3
  115. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +36 -3
  116. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +1 -1
  117. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +67 -4
  118. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +1 -1
  119. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +2 -2
  120. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +1 -1
  121. package/themes/original/src/components/GiftCard/SingleGiftCard/index.tsx +101 -0
  122. package/themes/original/src/components/GiftCard/SingleGiftCard/styles.tsx +4 -0
  123. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +83 -0
  124. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/styles.tsx +9 -0
  125. package/themes/original/src/components/GoogleMap/index.tsx +6 -5
  126. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +2 -2
  127. package/themes/original/src/components/HighestRatedBusinesses/styles.tsx +1 -1
  128. package/themes/original/src/components/Home/index.tsx +1 -1
  129. package/themes/original/src/components/LastOrder/index.tsx +2 -1
  130. package/themes/original/src/components/LastOrders/index.tsx +2 -1
  131. package/themes/original/src/components/LoginForm/Otp/index.tsx +53 -47
  132. package/themes/original/src/components/LoginForm/index.tsx +6 -1
  133. package/themes/original/src/components/Messages/index.tsx +9 -4
  134. package/themes/original/src/components/Messages/styles.tsx +1 -1
  135. package/themes/original/src/components/MomentOption/index.tsx +3 -3
  136. package/themes/original/src/components/MultiCart/index.tsx +1 -1
  137. package/themes/original/src/components/MultiCheckout/index.tsx +251 -53
  138. package/themes/original/src/components/MultiCheckout/styles.tsx +17 -0
  139. package/themes/original/src/components/MultiOrdersDetails/index.tsx +20 -15
  140. package/themes/original/src/components/MyOrders/index.tsx +24 -29
  141. package/themes/original/src/components/NavBar/index.tsx +3 -1
  142. package/themes/original/src/components/NetworkError/index.tsx +2 -3
  143. package/themes/original/src/components/NetworkError/styles.tsx +2 -2
  144. package/themes/original/src/components/Notifications/index.tsx +4 -8
  145. package/themes/original/src/components/Notifications/styles.tsx +0 -1
  146. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +7 -3
  147. package/themes/original/src/components/OrderDetails/index.tsx +716 -667
  148. package/themes/original/src/components/OrderDetails/styles.tsx +24 -8
  149. package/themes/original/src/components/OrderProgress/index.tsx +28 -9
  150. package/themes/original/src/components/OrderProgress/styles.tsx +1 -1
  151. package/themes/original/src/components/OrderSummary/index.tsx +3 -1
  152. package/themes/original/src/components/OrderTypeSelector/index.tsx +5 -6
  153. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +1 -1
  154. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +1 -1
  155. package/themes/original/src/components/OrdersOption/index.tsx +3 -5
  156. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  157. package/themes/original/src/components/PageBanner/index.tsx +3 -0
  158. package/themes/original/src/components/PaymentOptionCard/index.tsx +4 -2
  159. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +3 -0
  160. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  161. package/themes/original/src/components/PaymentOptions/index.tsx +72 -6
  162. package/themes/original/src/components/PhoneInputNumber/index.tsx +15 -1
  163. package/themes/original/src/components/ProductForm/ActionButton.tsx +120 -0
  164. package/themes/original/src/components/ProductForm/ExtraOptions.tsx +56 -0
  165. package/themes/original/src/components/ProductForm/index.tsx +74 -165
  166. package/themes/original/src/components/ProductItemAccordion/index.tsx +13 -9
  167. package/themes/original/src/components/ProductItemAccordion/styles.tsx +3 -1
  168. package/themes/original/src/components/ProductOptionSubOption/index.tsx +123 -82
  169. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +6 -1
  170. package/themes/original/src/components/ProfessionalProfile/styles.tsx +3 -3
  171. package/themes/original/src/components/Promotions/index.tsx +4 -4
  172. package/themes/original/src/components/Promotions/styles.tsx +0 -2
  173. package/themes/original/src/components/ReviewDriver/styles.tsx +1 -1
  174. package/themes/original/src/components/ReviewOrder/styles.tsx +1 -1
  175. package/themes/original/src/components/ReviewProducts/styles.tsx +1 -1
  176. package/themes/original/src/components/ServiceForm/index.tsx +2 -2
  177. package/themes/original/src/components/ServiceForm/styles.tsx +4 -4
  178. package/themes/original/src/components/SingleOrderCard/index.tsx +5 -4
  179. package/themes/original/src/components/SingleProductCard/index.tsx +2 -2
  180. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  181. package/themes/original/src/components/StripeCardsList/index.tsx +17 -36
  182. package/themes/original/src/components/StripeElementsForm/index.tsx +9 -4
  183. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +170 -0
  184. package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +86 -0
  185. package/themes/original/src/components/UpsellingProducts/index.tsx +15 -199
  186. package/themes/original/src/components/UpsellingProducts/styles.tsx +19 -0
  187. package/themes/original/src/components/UserFormDetails/index.tsx +52 -8
  188. package/themes/original/src/components/UserFormDetails/styles.tsx +7 -0
  189. package/themes/original/src/components/UserProfile/index.tsx +3 -2
  190. package/themes/original/src/components/UserProfileForm/index.tsx +30 -36
  191. package/themes/original/src/components/UserVerification/index.tsx +55 -50
  192. package/themes/original/src/components/WalletTransactions/styles.tsx +1 -0
  193. package/themes/original/src/components/Wallets/index.tsx +8 -9
  194. package/themes/original/src/components/Wallets/styles.tsx +1 -1
  195. package/themes/original/src/components/WebsocketStatus/index.tsx +172 -0
  196. package/themes/original/src/components/WebsocketStatus/styles.tsx +28 -0
  197. package/themes/original/src/components/shared/HeaderTitle.tsx +1 -1
  198. package/themes/original/src/components/shared/OButton.tsx +5 -5
  199. package/themes/original/src/components/shared/OInput.tsx +1 -4
  200. package/themes/original/src/components/shared/OModal.tsx +12 -14
  201. package/themes/original/src/layouts/Container.tsx +5 -3
  202. package/themes/original/src/types/index.tsx +6 -1
  203. package/themes/original/src/utils/index.tsx +124 -0
  204. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  205. package/src/navigators/BottomNavigator.tsx +0 -117
  206. package/src/navigators/CheckoutNavigator.tsx +0 -66
  207. package/src/navigators/HomeNavigator.tsx +0 -202
  208. package/src/navigators/NavigationRef.tsx +0 -7
  209. package/src/navigators/RootNavigator.tsx +0 -269
  210. package/src/pages/Account.tsx +0 -34
  211. package/src/pages/AddressForm.tsx +0 -62
  212. package/src/pages/AddressList.tsx +0 -24
  213. package/src/pages/BusinessProductsList.tsx +0 -81
  214. package/src/pages/BusinessesListing.tsx +0 -43
  215. package/src/pages/CartList.tsx +0 -49
  216. package/src/pages/Checkout.tsx +0 -101
  217. package/src/pages/ForgotPassword.tsx +0 -24
  218. package/src/pages/Help.tsx +0 -23
  219. package/src/pages/HelpAccountAndPayment.tsx +0 -23
  220. package/src/pages/HelpGuide.tsx +0 -23
  221. package/src/pages/HelpOrder.tsx +0 -23
  222. package/src/pages/Home.tsx +0 -36
  223. package/src/pages/IntroductoryTutorial.tsx +0 -170
  224. package/src/pages/Login.tsx +0 -47
  225. package/src/pages/MomentOption.tsx +0 -30
  226. package/src/pages/MultiCheckout.tsx +0 -31
  227. package/src/pages/MultiOrdersDetails.tsx +0 -27
  228. package/src/pages/MyOrders.tsx +0 -40
  229. package/src/pages/NetworkError.tsx +0 -24
  230. package/src/pages/NotFound.tsx +0 -22
  231. package/src/pages/OrderDetails.tsx +0 -25
  232. package/src/pages/ProductDetails.tsx +0 -55
  233. package/src/pages/Profile.tsx +0 -36
  234. package/src/pages/ReviewDriver.tsx +0 -30
  235. package/src/pages/ReviewOrder.tsx +0 -32
  236. package/src/pages/ReviewProducts.tsx +0 -30
  237. package/src/pages/Sessions.tsx +0 -22
  238. package/src/pages/Signup.tsx +0 -53
  239. package/src/pages/SpinnerLoader.tsx +0 -10
  240. package/src/pages/Splash.tsx +0 -21
@@ -55,7 +55,7 @@ const MapViewComponent = (props: MapViewParams) => {
55
55
  if (mapRef.current) {
56
56
  mapRef.current.fitToCoordinates(
57
57
  [
58
- { latitude: location.latitude, longitude: location.longitude },
58
+ { latitude: location.latitude ?? 0, longitude: location.longitude ?? 0},
59
59
  {
60
60
  latitude: userLocation?.latitude,
61
61
  longitude: userLocation?.longitude,
@@ -72,8 +72,8 @@ const MapViewComponent = (props: MapViewParams) => {
72
72
  const lastRegion = mapRef?.current?.__lastRegion
73
73
  mapRef?.current && mapRef.current.animateToRegion({
74
74
  ...mapRef?.current?.__lastRegion,
75
- longitudeDelta: lastRegion.longitudeDelta / 8,
76
- latitudeDelta: lastRegion.longitudeDelta / 8
75
+ longitudeDelta: lastRegion?.longitudeDelta / 8,
76
+ latitudeDelta: lastRegion?.longitudeDelta / 8
77
77
  })
78
78
  }
79
79
 
@@ -81,8 +81,8 @@ const MapViewComponent = (props: MapViewParams) => {
81
81
  const lastRegion = mapRef?.current?.__lastRegion
82
82
  mapRef?.current && mapRef.current.animateToRegion({
83
83
  ...lastRegion,
84
- longitudeDelta: lastRegion.longitudeDelta * 8,
85
- latitudeDelta: lastRegion.longitudeDelta * 8
84
+ longitudeDelta: lastRegion?.longitudeDelta * 8,
85
+ latitudeDelta: lastRegion?.longitudeDelta * 8
86
86
  })
87
87
  }
88
88
 
@@ -132,6 +132,10 @@ const MapViewComponent = (props: MapViewParams) => {
132
132
 
133
133
  const RenderMarker = ({ marker, customer, orderIds }: { marker: any, customer?: boolean, orderIds?: Array<number> }) => {
134
134
  const markerRef = useRef<any>()
135
+
136
+ let coordinateLat = (customer ? marker?.customer?.location?.lat : marker?.business?.location?.lat) ?? initialPosition?.latitude
137
+ let coordinateLng = (customer ? marker?.customer?.location?.lng : marker?.business?.location?.lng) ?? initialPosition?.longitude
138
+
135
139
  useEffect(() => {
136
140
  if (
137
141
  markerRef?.current?.props?.coordinate?.latitude === locationSelected?.latitude &&
@@ -145,8 +149,8 @@ const MapViewComponent = (props: MapViewParams) => {
145
149
  <Marker
146
150
  key={customer ? marker?.customer?.id : marker?.business?.id}
147
151
  coordinate={{
148
- latitude: customer ? marker?.customer?.location?.lat : marker?.business?.location?.lat,
149
- longitude: customer ? marker?.customer?.location?.lng : marker?.business?.location?.lng
152
+ latitude: coordinateLat,
153
+ longitude: coordinateLng
150
154
  }}
151
155
  onPress={() =>
152
156
  setLocationSelected({
@@ -2,20 +2,18 @@ import React, { useState, useEffect } from 'react';
2
2
  import {
3
3
  View,
4
4
  Pressable,
5
- StyleSheet,
6
- Dimensions,
7
- ScrollView,
8
- RefreshControl,
5
+ StyleSheet
9
6
  } from 'react-native';
10
7
  import { Contacts, useLanguage } from 'ordering-components/native';
11
8
  import { useTheme } from 'styled-components/native';
12
- import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
13
- import { OText, OButton } from '../shared';
9
+ import { OText } from '../shared';
14
10
  import { NotFoundSource } from '../NotFoundSource';
15
11
  import { PreviousMessages } from '../PreviousMessages';
16
12
  import { FiltersTab, TabsContainer, TagsContainer, Tag } from './styles';
17
13
  import { MessagesOptionParams } from '../../types';
18
14
  import { useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation';
15
+ import { WebsocketStatus } from '../WebsocketStatus'
16
+
19
17
  const MessagesOptionUI = (props: MessagesOptionParams) => {
20
18
  const {
21
19
  orders,
@@ -65,12 +63,6 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
65
63
  ),
66
64
  );
67
65
 
68
- const [orientation, setOrientation] = useState(
69
- Dimensions.get('window').width < Dimensions.get('window').height
70
- ? 'Portrait'
71
- : 'Landscape',
72
- );
73
-
74
66
  const getTagFilter = (key: number) => {
75
67
  return tags.find(value => value.key === key)?.text;
76
68
  };
@@ -114,14 +106,6 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
114
106
  );
115
107
  }, [orders]);
116
108
 
117
- Dimensions.addEventListener('change', ({ window: { width, height } }) => {
118
- if (width < height) {
119
- setOrientation('Portrait');
120
- } else {
121
- setOrientation('Landscape');
122
- }
123
- });
124
-
125
109
  const styles = StyleSheet.create({
126
110
  header: {
127
111
  marginBottom: 25,
@@ -180,7 +164,7 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
180
164
  <View style={styles.header}>
181
165
  <OText style={styles.title}>{t('MESSAGES', 'Messages')}</OText>
182
166
  </View>
183
-
167
+ <WebsocketStatus />
184
168
  <FiltersTab>
185
169
  <TabsContainer width={dimensions.width - 42}>
186
170
  {tabs.map((tab: any) => (
@@ -242,35 +226,28 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
242
226
  !error
243
227
  ? t('NO_RESULTS_FOUND', 'Sorry, no results found')
244
228
  : error[0]?.message ||
245
- error[0] ||
246
- t('NETWORK_ERROR', 'Network Error')
229
+ error[0] ||
230
+ t('NETWORK_ERROR', 'Network Error')
247
231
  }
248
232
  image={theme.images.general.notFound}
249
233
  conditioned={false}
250
234
  />
251
235
  )}
252
-
253
- <ScrollView
254
- showsVerticalScrollIndicator={false}
255
- style={{ flex: 1 }}
256
- refreshControl={<RefreshControl
257
- refreshing={refreshing}
258
- onRefresh={() => getOrders?.()}
259
- />}
260
- >
261
- {!reload &&
262
- !error &&
263
- values.length > 0 &&
264
- JSON.stringify(tabsFilter) === JSON.stringify(tabs[0].tags) && (
265
- <PreviousMessages
266
- orders={values}
267
- setOrders={setOrders}
268
- messages={messages}
269
- onNavigationRedirect={onNavigationRedirect}
270
- />
271
- )}
272
-
273
- {/* {!reload &&
236
+ <PreviousMessages
237
+ orders={values}
238
+ messages={messages}
239
+ onNavigationRedirect={onNavigationRedirect}
240
+ getOrders={getOrders}
241
+ pagination={pagination}
242
+ loading={loading}
243
+ reload={reload}
244
+ tabs={tabs}
245
+ tabsFilter={tabsFilter}
246
+ setOrders={setOrders}
247
+ loadMore={loadMore}
248
+ error={error}
249
+ />
250
+ {/* {!reload &&
274
251
  !error &&
275
252
  orders.length > 0 &&
276
253
  JSON.stringify(tabsFilter) === JSON.stringify(tabs[1].tags) && (
@@ -283,55 +260,6 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
283
260
  onNavigationRedirect={onNavigationRedirect}
284
261
  />
285
262
  )} */}
286
-
287
- {(loading || reload) && (
288
- <>
289
- <View>
290
- {[...Array(5)].map((item, i) => (
291
- <Placeholder key={i} Animation={Fade}>
292
- <View
293
- style={{
294
- width: '100%',
295
- flexDirection: 'row',
296
- marginBottom: 10,
297
- }}>
298
- <PlaceholderLine
299
- width={orientation === 'Portrait' ? 22 : 11}
300
- height={74}
301
- style={{
302
- marginRight: 20,
303
- marginBottom: 20,
304
- borderRadius: 7.6,
305
- }}
306
- />
307
- <Placeholder>
308
- <PlaceholderLine width={30} style={{ marginTop: 5 }} />
309
- <PlaceholderLine width={50} />
310
- <PlaceholderLine width={20} />
311
- </Placeholder>
312
- </View>
313
- </Placeholder>
314
- ))}
315
- </View>
316
- </>
317
- )}
318
-
319
- {pagination?.totalPages &&
320
- !loading &&
321
- !reload &&
322
- JSON.stringify(tabsFilter) === JSON.stringify(tabs[0].tags) &&
323
- pagination?.currentPage < pagination?.totalPages && (
324
- <OButton
325
- onClick={() => loadMore && loadMore()}
326
- text={t('LOAD_MORE_ORDERS', 'Load more orders')}
327
- imgRightSrc={null}
328
- textStyle={styles.loadButtonText}
329
- style={styles.loadButton}
330
- bgColor={theme.colors.primary}
331
- borderColor={theme.colors.primary}
332
- />
333
- )}
334
- </ScrollView>
335
263
  </>
336
264
  );
337
265
  };
@@ -1,104 +1,167 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import {
3
+ Modal,
4
+ View,
5
+ StyleSheet,
6
+ Dimensions,
7
+ TouchableOpacity,
8
+ NativeModules,
9
+ PermissionsAndroid,
10
+ Platform
11
+ } from 'react-native';
12
+ import { useTheme } from 'styled-components/native'
1
13
  import moment from 'moment'
2
- import { NewOrderNotification as NewOrderNotificationController, useApi, useEvent, useLanguage, useSession } from 'ordering-components/native'
3
- import React, { useEffect, useState } from 'react'
4
- import { Dimensions, Modal, StyleSheet, TouchableOpacity, View } from 'react-native'
5
- import Sound from 'react-native-sound'
6
14
  import Icon from 'react-native-vector-icons/Feather'
7
- import { useTheme } from 'styled-components/native'
15
+ import SoundPlayer from 'react-native-sound-player'
16
+
17
+ import {
18
+ NewOrderNotification as NewOrderNotificationController,
19
+ useApi,
20
+ useEvent,
21
+ useLanguage,
22
+ useSession,
23
+ useConfig,
24
+ useToast,
25
+ ToastType
26
+ } from 'ordering-components/native'
8
27
 
9
- import { useLocation } from '../../hooks/useLocation'
10
28
  import { OIcon, OText } from '../shared'
11
29
  import { NotificationContainer } from './styles'
30
+ import { useLocation } from '../../hooks/useLocation'
12
31
 
13
- Sound.setCategory('Playback', true)
14
- Sound.setMode('Default')
15
-
32
+ const DELAY_SOUND = 2500 // 2 sec
16
33
  const windowWidth = Dimensions.get('screen').width
17
34
 
18
- const SOUND_LOOP = 3
35
+ const SoundPlayerComponent = (props: any) => {
36
+ const { evtList, currentEvent, handleCloseEvents } = props
19
37
 
20
- const NewOrderNotificationUI = (props: any) => {
21
- const { isBusinessApp } = props
22
- const [events] = useEvent()
23
38
  const theme = useTheme()
24
- const [, t] = useLanguage()
25
- const [{ user, token }] = useSession()
26
- const [ordering] = useApi()
27
- const { getCurrentLocation } = useLocation();
28
- const [currentEvent, setCurrentEvent] = useState<any>(null)
39
+ const [count, setCount] = useState(0);
40
+ const [isEnabledReadStorage, setIsEnabledReadStorage] = useState(true)
41
+ const URL_SOUND = 'https://d33aymufw4jvwf.cloudfront.net/notification.mp3' ?? theme.sounds.notification
29
42
 
30
- const evtList: any = {
31
- 1: {
32
- event: 'messages',
33
- message: t('NEW_MESSAGES_RECEIVED', 'New messages have been received!'),
34
- message2: t('ORDER_N_UNREAD_MESSAGES', 'Order #_order_id_ has unread messages.').replace('_order_id_', currentEvent?.orderId),
35
- },
36
- 2: {
37
- event: 'order_added',
38
- message: t('NEW_ORDERS_RECEIVED', 'New orders have been received!'),
39
- message2: t('ORDER_N_ORDERED', 'Order #_order_id_ has been ordered.').replace('_order_id_', currentEvent?.orderId),
40
- },
41
- 3: {
42
- event: 'order_updated',
43
- message: t('NEW_ORDERS_UPDATED', 'New orders have been updated!'),
44
- message2: t('ORDER_N_UPDATED', 'Order #_order_id_ has been updated.').replace('_order_id_', currentEvent?.orderId),
45
- },
46
- }
47
-
48
- const notificationSound = new Sound(theme.sounds.notification, '', () => { });
49
-
50
- let _timeout: any = null
51
- let times = 0
43
+ useEffect(() => {
44
+ const id = setInterval(() => setCount(count + 1), 2500)
52
45
 
53
- const handleCloseEvents = () => {
54
- notificationSound.stop()
55
- setCurrentEvent(null)
56
- clearInterval(_timeout)
57
- }
46
+ const playSound = async () => {
47
+ SoundPlayer.playUrl(URL_SOUND)
48
+ await new Promise(resolve => setTimeout(resolve, DELAY_SOUND))
49
+ SoundPlayer.stop()
50
+ }
51
+ if (NativeModules?.RNSoundPlayer?.playUrl && typeof URL_SOUND === 'string' && isEnabledReadStorage) {
52
+ playSound()
53
+ }
58
54
 
59
- const handlePlayNotificationSound = (eventObj: any = null) => {
60
- setCurrentEvent(eventObj)
61
- if (times > 0) {
62
- if (times === 3) {
63
- times = 0
64
- return
65
- }
66
- return
55
+ return () => {
56
+ SoundPlayer.stop()
57
+ clearInterval(id);
67
58
  }
68
- _timeout = setInterval(() => {
69
- if (times < SOUND_LOOP) {
70
- notificationSound.play()
71
- times++
59
+ }, [count, isEnabledReadStorage])
60
+
61
+ useEffect(() => {
62
+ const checkSoundMedia = async () => {
63
+ if (Platform.OS === 'android') {
64
+ const enabled = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE)
65
+ setIsEnabledReadStorage(enabled)
72
66
  } else {
73
- clearInterval(_timeout)
74
- return
67
+ setIsEnabledReadStorage(true)
75
68
  }
76
- }, 2500)
77
- }
69
+ }
70
+ checkSoundMedia()
71
+
72
+ }, [])
73
+ return (
74
+ <Modal
75
+ animationType='slide'
76
+ transparent={true}
77
+ visible={!!currentEvent?.orderId}
78
+ >
79
+ <NotificationContainer>
80
+ <View style={styles.modalView}>
81
+ <TouchableOpacity
82
+ style={styles.wrapperIcon}
83
+ onPress={() => handleCloseEvents()}
84
+ >
85
+ <Icon name="x" size={30} />
86
+ </TouchableOpacity>
87
+ <OText
88
+ size={18}
89
+ color={theme.colors.textGray}
90
+ weight={600}
91
+ >
92
+ {evtList(currentEvent)[currentEvent?.evt]?.message}
93
+ </OText>
94
+ <OIcon
95
+ src={theme.images.general.newOrder}
96
+ width={250}
97
+ height={200}
98
+ />
99
+ <OText
100
+ color={theme.colors.textGray}
101
+ mBottom={15}
102
+ >
103
+ {evtList(currentEvent)[currentEvent?.evt]?.message2}
104
+ </OText>
105
+ </View>
106
+ </NotificationContainer>
107
+ </Modal>
108
+ )
109
+ }
110
+
111
+ const NewOrderNotificationUI = (props: any) => {
112
+ const { isBusinessApp, evtList } = props
113
+ const [, t] = useLanguage()
114
+ const [events] = useEvent()
115
+ const [{ user, token }] = useSession()
116
+ const [ordering] = useApi()
117
+ const [{ configs }] = useConfig()
118
+ const [, { showToast }] = useToast()
119
+ const { getCurrentLocation } = useLocation()
120
+ const [currentEvent, setCurrentEvent] = useState<any>(null)
121
+
122
+ const orderStatus = !!isBusinessApp
123
+ ? configs?.notification_business_states?.value.split('|').map((value: any) => Number(value)) || []
124
+ : configs?.notification_driver_states?.value.split('|').map((value: any) => Number(value)) || []
78
125
 
79
126
  const handleEventNotification = async (evtType: number, value: any) => {
80
127
  if (value?.driver) {
81
128
  try {
82
129
  const location = await getCurrentLocation()
130
+ if (!location?.latitude || !location?.longitude) {
131
+ showToast(t('ERROR_UPDATING_COORDS', 'Error updating coords'), ToastType.Error)
132
+ return
133
+ }
83
134
  await fetch(`${ordering.root}/users/${user.id}/locations`, {
84
135
  method: 'POST',
85
136
  body: JSON.stringify({
86
- location: JSON.stringify({ location: `{lat: ${location.latitude}, lng: ${location.longitude}}` })
137
+ location: JSON.stringify({
138
+ location: `{
139
+ lat: ${location.latitude},
140
+ lng: ${location.longitude}
141
+ }`
142
+ })
87
143
  }),
88
- headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }
144
+ headers: {
145
+ 'Content-Type': 'application/json',
146
+ Authorization: `Bearer ${token}`
147
+ }
89
148
  })
90
149
  } catch { }
91
150
  const duration = moment.duration(moment().diff(moment.utc(value?.last_driver_assigned_at)))
92
151
  const assignedSecondsDiff = duration.asSeconds()
93
- if (assignedSecondsDiff < 5 && !isBusinessApp && !value?.logistic_status) {
94
- handlePlayNotificationSound({ evt: 2, orderId: value?.id })
152
+ if (assignedSecondsDiff < 5 && !isBusinessApp && !value?.logistic_status && orderStatus.includes(value.status)) {
153
+ setCurrentEvent({ evt: 2, orderId: value?.id ?? value?.order_id })
95
154
  }
96
155
  }
97
- if (evtType === 3 || value.author_id === user.id) return
98
- setTimeout(() => handlePlayNotificationSound({
156
+ if (!orderStatus.includes(value.status) || value?.author_id === user.id) return
157
+ setCurrentEvent({
99
158
  evt: evtType,
100
- orderId: value?.driver ? value?.order_id : evtList[evtType].event === 'messages' ? value?.order?.id : value?.order_id
101
- }), 1000)
159
+ orderId: value?.driver
160
+ ? value?.order_id ?? value?.id
161
+ : evtList(currentEvent)[evtType].event === 'messages'
162
+ ? value?.order?.id
163
+ : value?.order_id ?? value?.id
164
+ })
102
165
  }
103
166
 
104
167
  useEffect(() => {
@@ -118,48 +181,21 @@ const NewOrderNotificationUI = (props: any) => {
118
181
  }, [])
119
182
 
120
183
  useEffect(() => {
121
- return () => handleCloseEvents()
184
+ return () => setCurrentEvent(null)
122
185
  }, [])
123
186
 
124
187
  return (
125
188
  <>
126
- <Modal
127
- animationType='slide'
128
- transparent={true}
129
- visible={!!currentEvent?.orderId}
130
- >
131
- <NotificationContainer>
132
- <View style={styles.modalView}>
133
- <TouchableOpacity
134
- style={styles.wrapperIcon}
135
- onPress={() => handleCloseEvents()}
136
- >
137
- <Icon name="x" size={30} />
138
- </TouchableOpacity>
139
- <OText
140
- size={18}
141
- color={theme.colors.textGray}
142
- weight={600}
143
- >
144
- {evtList[currentEvent?.evt]?.message}
145
- </OText>
146
- <OIcon
147
- src={theme.images.general.newOrder}
148
- width={250}
149
- height={200}
150
- />
151
- <OText
152
- color={theme.colors.textGray}
153
- mBottom={15}
154
- >
155
- {evtList[currentEvent?.evt]?.message2}
156
- </OText>
157
- </View>
158
- </NotificationContainer>
159
- </Modal>
189
+ {!!currentEvent ? (
190
+ <SoundPlayerComponent
191
+ evtList={evtList}
192
+ currentEvent={currentEvent}
193
+ handleCloseEvents={() => setCurrentEvent(null)}
194
+ />
195
+ ) : null}
160
196
  </>
161
197
  )
162
- }
198
+ };
163
199
 
164
200
  const styles = StyleSheet.create({
165
201
  modalView: {
@@ -179,9 +215,28 @@ const styles = StyleSheet.create({
179
215
  })
180
216
 
181
217
  export const NewOrderNotification = (props: any) => {
218
+ const [, t] = useLanguage()
219
+
182
220
  const newOrderNotificationProps = {
183
221
  ...props,
184
- UIComponent: NewOrderNotificationUI
222
+ UIComponent: NewOrderNotificationUI,
223
+ evtList: (currentEvent: any) => ({
224
+ 1: {
225
+ event: 'messages',
226
+ message: t('NEW_MESSAGES_RECEIVED', 'New messages have been received!'),
227
+ message2: t('ORDER_N_UNREAD_MESSAGES', 'Order #_order_id_ has unread messages.').replace('_order_id_', currentEvent?.orderId),
228
+ },
229
+ 2: {
230
+ event: 'order_added',
231
+ message: t('NEW_ORDERS_RECEIVED', 'New orders have been received!'),
232
+ message2: t('ORDER_N_ORDERED', 'Order #_order_id_ has been ordered.').replace('_order_id_', currentEvent?.orderId),
233
+ },
234
+ 3: {
235
+ event: 'order_updated',
236
+ message: t('NEW_ORDERS_UPDATED', 'New orders have been updated!'),
237
+ message2: t('ORDER_N_UPDATED', 'Order #_order_id_ has been updated.').replace('_order_id_', currentEvent?.orderId),
238
+ },
239
+ })
185
240
  };
186
241
 
187
242
  return <NewOrderNotificationController {...newOrderNotificationProps} />;
@@ -4,8 +4,10 @@ import {
4
4
  View,
5
5
  TouchableOpacity,
6
6
  ActivityIndicator,
7
+ Alert,
7
8
  } from 'react-native';
8
9
  import Clipboard from '@react-native-clipboard/clipboard';
10
+ import { StarPRNT } from 'react-native-star-prnt';
9
11
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
10
12
  import { useTheme } from 'styled-components/native';
11
13
  import {
@@ -35,6 +37,8 @@ import CountryPicker from 'react-native-country-picker-modal';
35
37
  import { NotFoundSource } from '../NotFoundSource';
36
38
  import { OrderHeaderComponent } from './OrderHeaderComponent';
37
39
  import { OrderContentComponent } from './OrderContentComponent';
40
+ import { _retrieveStoreData } from '../../providers/StoreUtil'
41
+ import { usePrinterCommands } from './usePrinterCommands'
38
42
 
39
43
  export const OrderDetailsUI = (props: OrderDetailsParams) => {
40
44
  const {
@@ -44,7 +48,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
44
48
  readMessages,
45
49
  messagesReadList,
46
50
  handleAssignDriver,
47
- handleChangeOrderStatus,
48
51
  isFromCheckout,
49
52
  driverLocation,
50
53
  actions,
@@ -57,6 +60,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
57
60
  const [{ parsePrice, parseNumber, parseDate }] = useUtils();
58
61
  const [{ user, token }] = useSession();
59
62
  const [{ configs }] = useConfig();
63
+ const { generateCommands } = usePrinterCommands()
60
64
  const [, { showToast }] = useToast();
61
65
  const [unreadAlert, setUnreadAlert] = useState({
62
66
  business: false,
@@ -70,6 +74,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
70
74
  const [openModalForAccept, setOpenModalForAccept] = useState(false);
71
75
  const [openModalForMapView, setOpenModalForMapView] = useState(false);
72
76
  const [isDriverModalVisible, setIsDriverModalVisible] = useState(false);
77
+ const [printerSettings, setPrinterSettings] = useState<any>('')
78
+ const [autoPrintEnabled, setAutoPrintEnabled] = useState<boolean>(false)
73
79
 
74
80
  if (order?.status === 7 || order?.status === 4) {
75
81
  if (drivers?.length > 0 && drivers) {
@@ -120,6 +126,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
120
126
  }
121
127
  }
122
128
 
129
+ const handleChangeOrderStatus = async (status: any, isAcceptOrReject: any = {}) => {
130
+ if (props.handleChangeOrderStatus) {
131
+ const order: any = await props.handleChangeOrderStatus(status, isAcceptOrReject)
132
+
133
+ if (order?.status === 7 && autoPrintEnabled && printerSettings) {
134
+ handleViewSummaryOrder()
135
+ }
136
+ }
137
+ }
138
+
123
139
  const getFormattedSubOptionName = ({ quantity, name, position, price }: any) => {
124
140
  if (name !== 'No') {
125
141
  const pos = position && position !== 'whole' ? `(${t(position.toUpperCase(), position)})` : '';
@@ -291,7 +307,26 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
291
307
  setOpenModalForAccept(true);
292
308
  };
293
309
 
310
+ const printAction = async (printerSettings: any, commands: any) => {
311
+ try {
312
+ var printResult = await StarPRNT.print(printerSettings?.emulation, commands, printerSettings?.portName);
313
+ showToast(ToastType.Info, t('ORDER_PRINTED_SUCCESS', 'Order printed'), 1000)
314
+ } catch (e) {
315
+ showToast(ToastType.Error, t('ORDER_PRINTED_FAILED', 'Order not printed, connection failed'), 1000)
316
+ }
317
+ }
318
+
294
319
  const handleViewSummaryOrder = () => {
320
+ if (printerSettings) {
321
+ const commands: any = generateCommands({
322
+ ...order,
323
+ orderStatus: getOrderStatus(order?.status, t)?.value
324
+ }, printerSettings?.printMode)
325
+ commands.push({ appendCutPaper: StarPRNT.CutPaperAction.PartialCutWithFeed })
326
+
327
+ printAction(printerSettings, commands)
328
+ return
329
+ }
295
330
  navigation?.navigate &&
296
331
  navigation.navigate('OrderSummary', {
297
332
  order,
@@ -372,6 +407,17 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
372
407
  }
373
408
  }, [driverLocation]);
374
409
 
410
+ useEffect(() => {
411
+ const getStorageData = async () => {
412
+ const printer = await _retrieveStoreData('printer')
413
+ const autoPrint = await _retrieveStoreData('auto_print_after_accept_order')
414
+ setPrinterSettings(printer)
415
+ setAutoPrintEnabled(!!autoPrint)
416
+ }
417
+
418
+ getStorageData()
419
+ }, [])
420
+
375
421
  const styles = StyleSheet.create({
376
422
  driverOff: {
377
423
  backgroundColor: theme.colors.notAvailable,