ordering-ui-react-native 0.21.32-test → 0.21.33-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 (215) hide show
  1. package/package.json +7 -6
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessesListing/index.tsx +1 -1
  4. package/src/components/PaymentOptionsWebView/index.tsx +1 -0
  5. package/src/components/StripeMethodForm/index.tsx +6 -4
  6. package/src/components/VerifyPhone/styles.tsx +1 -2
  7. package/src/types/index.tsx +3 -1
  8. package/src/utils/index.tsx +2 -2
  9. package/themes/business/index.tsx +4 -0
  10. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -2
  11. package/themes/business/src/components/BusinessController/index.tsx +19 -17
  12. package/themes/business/src/components/BusinessProductList/AccordionDropdown.tsx +63 -0
  13. package/themes/business/src/components/BusinessProductList/IterateCategories.tsx +108 -0
  14. package/themes/business/src/components/BusinessProductList/ProductList.tsx +196 -0
  15. package/themes/business/src/components/BusinessProductList/index.tsx +196 -0
  16. package/themes/business/src/components/BusinessProductList/styles.tsx +10 -0
  17. package/themes/business/src/components/Chat/index.tsx +23 -14
  18. package/themes/business/src/components/DriverMap/index.tsx +36 -23
  19. package/themes/business/src/components/FloatingButton/index.tsx +34 -31
  20. package/themes/business/src/components/GoogleMap/index.tsx +15 -8
  21. package/themes/business/src/components/Home/index.tsx +5 -1
  22. package/themes/business/src/components/LanguageSelector/index.tsx +1 -2
  23. package/themes/business/src/components/LanguageSelector/lang_country.json +515 -70
  24. package/themes/business/src/components/MapView/index.tsx +16 -9
  25. package/themes/business/src/components/MessagesOption/index.tsx +2 -1
  26. package/themes/business/src/components/NewOrderNotification/index.tsx +143 -96
  27. package/themes/business/src/components/OrderDetails/Business.tsx +50 -2
  28. package/themes/business/src/components/OrderDetails/Delivery.tsx +23 -11
  29. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +61 -54
  30. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +52 -20
  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 +124 -48
  37. package/themes/business/src/components/PhoneInputNumber/index.tsx +8 -5
  38. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +36 -38
  39. package/themes/business/src/components/PreviousOrders/OrderList.tsx +18 -13
  40. package/themes/business/src/components/PreviousOrders/index.tsx +80 -66
  41. package/themes/business/src/components/PreviousOrders/styles.tsx +10 -0
  42. package/themes/business/src/components/PrinterSettings/index.tsx +279 -0
  43. package/themes/business/src/components/PrinterSettings/styles.tsx +17 -0
  44. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  45. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  46. package/themes/business/src/components/SearchBar/index.tsx +2 -1
  47. package/themes/business/src/components/Sessions/index.tsx +187 -0
  48. package/themes/business/src/components/Sessions/styles.tsx +20 -0
  49. package/themes/business/src/components/StoresList/index.tsx +5 -3
  50. package/themes/business/src/components/UserFormDetails/index.tsx +111 -107
  51. package/themes/business/src/components/UserProfileForm/index.tsx +107 -53
  52. package/themes/business/src/components/WebsocketStatus/index.tsx +171 -0
  53. package/themes/business/src/components/WebsocketStatus/styles.tsx +28 -0
  54. package/themes/business/src/components/shared/OInput.tsx +2 -0
  55. package/themes/business/src/hooks/useLocation.tsx +5 -4
  56. package/themes/business/src/types/index.tsx +15 -2
  57. package/themes/business/src/utils/index.tsx +5 -0
  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 +7 -4
  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 +27 -12
  70. package/themes/original/src/components/AddressForm/styles.tsx +1 -1
  71. package/themes/original/src/components/AddressList/index.tsx +18 -4
  72. package/themes/original/src/components/AddressList/styles.tsx +4 -4
  73. package/themes/original/src/components/AnalyticsSegment/index.tsx +6 -6
  74. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  75. package/themes/original/src/components/BusinessBasicInformation/index.tsx +7 -10
  76. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +1 -1
  77. package/themes/original/src/components/BusinessController/index.tsx +18 -10
  78. package/themes/original/src/components/BusinessController/styles.tsx +8 -7
  79. package/themes/original/src/components/BusinessInformation/styles.tsx +2 -2
  80. package/themes/original/src/components/BusinessItemAccordion/index.tsx +11 -7
  81. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +317 -0
  82. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +96 -0
  83. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +1 -1
  84. package/themes/original/src/components/BusinessListingSearch/index.tsx +47 -358
  85. package/themes/original/src/components/BusinessListingSearch/styles.tsx +1 -1
  86. package/themes/original/src/components/BusinessPreorder/index.tsx +2 -3
  87. package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -1
  88. package/themes/original/src/components/BusinessProductsList/index.tsx +3 -3
  89. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  90. package/themes/original/src/components/BusinessProductsListing/index.tsx +35 -19
  91. package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -2
  92. package/themes/original/src/components/BusinessReviews/index.tsx +1 -1
  93. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  94. package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +5 -5
  95. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
  96. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
  97. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
  98. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +24 -404
  99. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  100. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  101. package/themes/original/src/components/Cart/index.tsx +32 -9
  102. package/themes/original/src/components/CartContent/index.tsx +96 -58
  103. package/themes/original/src/components/CartStoresListing/styles.tsx +2 -2
  104. package/themes/original/src/components/Checkout/index.tsx +160 -63
  105. package/themes/original/src/components/Checkout/styles.tsx +17 -0
  106. package/themes/original/src/components/CitiesControl/styles.tsx +1 -1
  107. package/themes/original/src/components/DatePicker/index.tsx +33 -0
  108. package/themes/original/src/components/DatePicker/styles.tsx +20 -0
  109. package/themes/original/src/components/Favorite/index.tsx +9 -9
  110. package/themes/original/src/components/Favorite/styles.tsx +0 -2
  111. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  112. package/themes/original/src/components/ForgotPasswordForm/index.tsx +5 -0
  113. package/themes/original/src/components/GPSButton/index.tsx +1 -1
  114. package/themes/original/src/components/GiftCard/GiftCardOrdersList/index.tsx +64 -0
  115. package/themes/original/src/components/GiftCard/GiftCardOrdersList/styles.tsx +8 -0
  116. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +8 -3
  117. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +36 -3
  118. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +1 -1
  119. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +67 -4
  120. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +1 -1
  121. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +2 -2
  122. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +1 -1
  123. package/themes/original/src/components/GiftCard/SingleGiftCard/index.tsx +101 -0
  124. package/themes/original/src/components/GiftCard/SingleGiftCard/styles.tsx +4 -0
  125. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +83 -0
  126. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/styles.tsx +9 -0
  127. package/themes/original/src/components/GoogleMap/index.tsx +6 -5
  128. package/themes/original/src/components/Help/index.tsx +7 -0
  129. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +5 -0
  130. package/themes/original/src/components/HelpGuide/index.tsx +5 -0
  131. package/themes/original/src/components/HelpOrder/index.tsx +5 -0
  132. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +2 -2
  133. package/themes/original/src/components/HighestRatedBusinesses/styles.tsx +1 -1
  134. package/themes/original/src/components/Home/index.tsx +2 -1
  135. package/themes/original/src/components/LastOrder/index.tsx +2 -1
  136. package/themes/original/src/components/LastOrders/index.tsx +2 -1
  137. package/themes/original/src/components/LoginForm/Otp/index.tsx +4 -16
  138. package/themes/original/src/components/LoginForm/index.tsx +8 -3
  139. package/themes/original/src/components/MessageListing/index.tsx +6 -0
  140. package/themes/original/src/components/Messages/index.tsx +9 -7
  141. package/themes/original/src/components/Messages/styles.tsx +1 -1
  142. package/themes/original/src/components/MomentOption/index.tsx +19 -4
  143. package/themes/original/src/components/MultiCart/index.tsx +1 -1
  144. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +1 -0
  145. package/themes/original/src/components/MultiCheckout/index.tsx +208 -21
  146. package/themes/original/src/components/MultiCheckout/styles.tsx +17 -0
  147. package/themes/original/src/components/MultiOrdersDetails/index.tsx +20 -15
  148. package/themes/original/src/components/MyOrders/index.tsx +28 -28
  149. package/themes/original/src/components/NavBar/index.tsx +5 -1
  150. package/themes/original/src/components/NetworkError/index.tsx +2 -3
  151. package/themes/original/src/components/NetworkError/styles.tsx +2 -2
  152. package/themes/original/src/components/Notifications/index.tsx +9 -8
  153. package/themes/original/src/components/Notifications/styles.tsx +0 -1
  154. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +1 -1
  155. package/themes/original/src/components/OrderDetails/index.tsx +709 -665
  156. package/themes/original/src/components/OrderDetails/styles.tsx +24 -8
  157. package/themes/original/src/components/OrderProgress/index.tsx +24 -4
  158. package/themes/original/src/components/OrderProgress/styles.tsx +1 -1
  159. package/themes/original/src/components/OrderSummary/index.tsx +3 -1
  160. package/themes/original/src/components/OrderTypeSelector/index.tsx +10 -6
  161. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +1 -1
  162. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +1 -1
  163. package/themes/original/src/components/OrdersOption/index.tsx +3 -5
  164. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  165. package/themes/original/src/components/PaymentOptionCard/index.tsx +4 -2
  166. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +3 -0
  167. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  168. package/themes/original/src/components/PaymentOptions/index.tsx +53 -6
  169. package/themes/original/src/components/PreviousOrders/index.tsx +2 -0
  170. package/themes/original/src/components/ProductForm/ActionButton.tsx +122 -0
  171. package/themes/original/src/components/ProductForm/ExtraOptions.tsx +56 -0
  172. package/themes/original/src/components/ProductForm/index.tsx +67 -155
  173. package/themes/original/src/components/ProductItemAccordion/index.tsx +54 -44
  174. package/themes/original/src/components/ProductItemAccordion/styles.tsx +3 -4
  175. package/themes/original/src/components/ProductOptionSubOption/index.tsx +105 -91
  176. package/themes/original/src/components/ProfessionalProfile/styles.tsx +3 -3
  177. package/themes/original/src/components/Promotions/index.tsx +13 -11
  178. package/themes/original/src/components/Promotions/styles.tsx +0 -2
  179. package/themes/original/src/components/ReviewDriver/index.tsx +5 -0
  180. package/themes/original/src/components/ReviewDriver/styles.tsx +1 -1
  181. package/themes/original/src/components/ReviewOrder/index.tsx +5 -0
  182. package/themes/original/src/components/ReviewOrder/styles.tsx +1 -1
  183. package/themes/original/src/components/ReviewProducts/index.tsx +5 -0
  184. package/themes/original/src/components/ReviewProducts/styles.tsx +1 -1
  185. package/themes/original/src/components/ServiceForm/index.tsx +2 -2
  186. package/themes/original/src/components/ServiceForm/styles.tsx +4 -4
  187. package/themes/original/src/components/Sessions/index.tsx +5 -0
  188. package/themes/original/src/components/SignupForm/index.tsx +66 -59
  189. package/themes/original/src/components/SingleOrderCard/index.tsx +3 -2
  190. package/themes/original/src/components/SingleProductCard/index.tsx +2 -2
  191. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  192. package/themes/original/src/components/StripeCardsList/index.tsx +17 -36
  193. package/themes/original/src/components/StripeElementsForm/index.tsx +74 -59
  194. package/themes/original/src/components/StripeElementsForm/naked.tsx +47 -0
  195. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +170 -0
  196. package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +86 -0
  197. package/themes/original/src/components/UpsellingProducts/index.tsx +15 -199
  198. package/themes/original/src/components/UpsellingProducts/styles.tsx +19 -0
  199. package/themes/original/src/components/UserFormDetails/index.tsx +123 -75
  200. package/themes/original/src/components/UserFormDetails/styles.tsx +7 -0
  201. package/themes/original/src/components/UserProfile/index.tsx +3 -2
  202. package/themes/original/src/components/UserProfileForm/index.tsx +5 -0
  203. package/themes/original/src/components/WalletTransactions/styles.tsx +1 -0
  204. package/themes/original/src/components/Wallets/index.tsx +8 -4
  205. package/themes/original/src/components/Wallets/styles.tsx +1 -1
  206. package/themes/original/src/components/WebsocketStatus/index.tsx +172 -0
  207. package/themes/original/src/components/WebsocketStatus/styles.tsx +28 -0
  208. package/themes/original/src/components/shared/HeaderTitle.tsx +1 -1
  209. package/themes/original/src/components/shared/OButton.tsx +5 -5
  210. package/themes/original/src/components/shared/OInput.tsx +1 -4
  211. package/themes/original/src/components/shared/OModal.tsx +12 -14
  212. package/themes/original/src/layouts/Container.tsx +5 -3
  213. package/themes/original/src/types/index.tsx +1 -0
  214. package/themes/original/src/utils/index.tsx +12 -1
  215. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -55,10 +55,13 @@ const MapViewComponent = (props: MapViewParams) => {
55
55
  if (mapRef.current) {
56
56
  mapRef.current.fitToCoordinates(
57
57
  [
58
- { latitude: location.latitude, longitude: location.longitude },
59
58
  {
60
- latitude: userLocation?.latitude,
61
- longitude: userLocation?.longitude,
59
+ latitude: typeof location?.latitude !== 'object' ? location?.latitude : 0,
60
+ longitude: typeof location?.longitude !== 'object' ? location?.latitude : 0
61
+ },
62
+ {
63
+ latitude: typeof userLocation?.latitude !== 'object' ? userLocation?.latitude : 0,
64
+ longitude: typeof userLocation?.longitude !== 'object' ? userLocation?.latitude : 0
62
65
  },
63
66
  ],
64
67
  {
@@ -72,8 +75,8 @@ const MapViewComponent = (props: MapViewParams) => {
72
75
  const lastRegion = mapRef?.current?.__lastRegion
73
76
  mapRef?.current && mapRef.current.animateToRegion({
74
77
  ...mapRef?.current?.__lastRegion,
75
- longitudeDelta: lastRegion.longitudeDelta / 8,
76
- latitudeDelta: lastRegion.longitudeDelta / 8
78
+ longitudeDelta: lastRegion?.longitudeDelta / 8,
79
+ latitudeDelta: lastRegion?.longitudeDelta / 8
77
80
  })
78
81
  }
79
82
 
@@ -81,8 +84,8 @@ const MapViewComponent = (props: MapViewParams) => {
81
84
  const lastRegion = mapRef?.current?.__lastRegion
82
85
  mapRef?.current && mapRef.current.animateToRegion({
83
86
  ...lastRegion,
84
- longitudeDelta: lastRegion.longitudeDelta * 8,
85
- latitudeDelta: lastRegion.longitudeDelta * 8
87
+ longitudeDelta: lastRegion?.longitudeDelta * 8,
88
+ latitudeDelta: lastRegion?.longitudeDelta * 8
86
89
  })
87
90
  }
88
91
 
@@ -132,6 +135,10 @@ const MapViewComponent = (props: MapViewParams) => {
132
135
 
133
136
  const RenderMarker = ({ marker, customer, orderIds }: { marker: any, customer?: boolean, orderIds?: Array<number> }) => {
134
137
  const markerRef = useRef<any>()
138
+
139
+ let coordinateLat = (customer ? marker?.customer?.location?.lat || 0 : marker?.business?.location?.lat || 0) ?? (initialPosition?.latitude || 0)
140
+ let coordinateLng = (customer ? marker?.customer?.location?.lng || 0 : marker?.business?.location?.lng || 0) ?? (initialPosition?.longitude || 0)
141
+
135
142
  useEffect(() => {
136
143
  if (
137
144
  markerRef?.current?.props?.coordinate?.latitude === locationSelected?.latitude &&
@@ -145,8 +152,8 @@ const MapViewComponent = (props: MapViewParams) => {
145
152
  <Marker
146
153
  key={customer ? marker?.customer?.id : marker?.business?.id}
147
154
  coordinate={{
148
- latitude: customer ? marker?.customer?.location?.lat : marker?.business?.location?.lat,
149
- longitude: customer ? marker?.customer?.location?.lng : marker?.business?.location?.lng
155
+ latitude: coordinateLat,
156
+ longitude: coordinateLng
150
157
  }}
151
158
  onPress={() =>
152
159
  setLocationSelected({
@@ -12,6 +12,7 @@ import { PreviousMessages } from '../PreviousMessages';
12
12
  import { FiltersTab, TabsContainer, TagsContainer, Tag } from './styles';
13
13
  import { MessagesOptionParams } from '../../types';
14
14
  import { useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation';
15
+ import { WebsocketStatus } from '../WebsocketStatus'
15
16
 
16
17
  const MessagesOptionUI = (props: MessagesOptionParams) => {
17
18
  const {
@@ -163,7 +164,7 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
163
164
  <View style={styles.header}>
164
165
  <OText style={styles.title}>{t('MESSAGES', 'Messages')}</OText>
165
166
  </View>
166
-
167
+ <WebsocketStatus />
167
168
  <FiltersTab>
168
169
  <TabsContainer width={dimensions.width - 42}>
169
170
  {tabs.map((tab: any) => (
@@ -4,7 +4,10 @@ import {
4
4
  View,
5
5
  StyleSheet,
6
6
  Dimensions,
7
- TouchableOpacity
7
+ TouchableOpacity,
8
+ NativeModules,
9
+ PermissionsAndroid,
10
+ Platform
8
11
  } from 'react-native';
9
12
  import { useTheme } from 'styled-components/native'
10
13
  import moment from 'moment'
@@ -16,100 +19,152 @@ import {
16
19
  useApi,
17
20
  useEvent,
18
21
  useLanguage,
19
- useSession
22
+ useSession,
23
+ useConfig,
24
+ useToast,
25
+ ToastType
20
26
  } from 'ordering-components/native'
21
27
 
22
28
  import { OIcon, OText } from '../shared'
23
29
  import { NotificationContainer } from './styles'
24
30
  import { useLocation } from '../../hooks/useLocation'
25
31
 
26
- const SOUND_REPETITIONS = 3
27
- const DELAY_SOUND = 2000 // 2 sec
32
+ const DELAY_SOUND = 2500 // 2 sec
28
33
  const windowWidth = Dimensions.get('screen').width
29
34
 
30
- const NewOrderNotificationUI = (props: any) => {
31
- const { isBusinessApp } = props
32
- const [events] = useEvent()
33
- const theme = useTheme()
34
- const [, t] = useLanguage()
35
- const [{ user, token }] = useSession()
36
- const [ordering] = useApi()
37
- const { getCurrentLocation } = useLocation()
38
- const [currentEvent, setCurrentEvent] = useState<any>(null)
35
+ const SoundPlayerComponent = (props: any) => {
36
+ const { evtList, currentEvent, handleCloseEvents } = props
39
37
 
38
+ const theme = useTheme()
39
+ const [count, setCount] = useState(0);
40
+ const [isEnabledReadStorage, setIsEnabledReadStorage] = useState(true)
40
41
  const URL_SOUND = 'https://d33aymufw4jvwf.cloudfront.net/notification.mp3' ?? theme.sounds.notification
41
42
 
42
- const evtList: any = {
43
- 1: {
44
- event: 'messages',
45
- message: t('NEW_MESSAGES_RECEIVED', 'New messages have been received!'),
46
- message2: t('ORDER_N_UNREAD_MESSAGES', 'Order #_order_id_ has unread messages.').replace('_order_id_', currentEvent?.orderId),
47
- },
48
- 2: {
49
- event: 'order_added',
50
- message: t('NEW_ORDERS_RECEIVED', 'New orders have been received!'),
51
- message2: t('ORDER_N_ORDERED', 'Order #_order_id_ has been ordered.').replace('_order_id_', currentEvent?.orderId),
52
- },
53
- 3: {
54
- event: 'order_updated',
55
- message: t('NEW_ORDERS_UPDATED', 'New orders have been updated!'),
56
- message2: t('ORDER_N_UPDATED', 'Order #_order_id_ has been updated.').replace('_order_id_', currentEvent?.orderId),
57
- },
58
- }
59
-
60
- const handleCloseEvents = () => {
61
- setCurrentEvent(null)
62
- SoundPlayer.stop();
63
- }
43
+ useEffect(() => {
44
+ const id = setInterval(() => setCount(count + 1), 2500)
64
45
 
65
- const playSoundNotification = async () => {
66
- for (let i = 0; i < SOUND_REPETITIONS; i++) {
46
+ const playSound = async () => {
67
47
  SoundPlayer.playUrl(URL_SOUND)
68
- await new Promise(resolve => setTimeout(resolve, DELAY_SOUND));
69
- SoundPlayer.stop();
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()
70
53
  }
71
- }
72
54
 
73
- const handlePlayNotificationSound = (eventObj: any = null) => {
74
- setCurrentEvent(eventObj)
75
- playSoundNotification()
76
- }
55
+ return () => {
56
+ SoundPlayer.stop()
57
+ clearInterval(id);
58
+ }
59
+ }, [count, isEnabledReadStorage])
77
60
 
78
- const handleEventNotification = async (evtType: number, value: any) => {
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)
66
+ } else {
67
+ setIsEnabledReadStorage(true)
68
+ }
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, orderStatus } = props
113
+ const [, t] = useLanguage()
114
+ const [events] = useEvent()
115
+ const [{ user, token }] = useSession()
116
+ const [ordering] = useApi()
117
+ const [, { showToast }] = useToast()
118
+ const { getCurrentLocation } = useLocation()
119
+ const [currentEvent, setCurrentEvent] = useState<any>(null)
120
+
121
+ const handleEventNotification = async (evtType: number, value: any, orderStatus?: any) => {
79
122
  if (value?.driver) {
80
123
  try {
81
124
  const location = await getCurrentLocation()
125
+ if (!location?.latitude || !location?.longitude) {
126
+ showToast(t('ERROR_UPDATING_COORDS', 'Error updating coords'), ToastType.Error)
127
+ return
128
+ }
82
129
  await fetch(`${ordering.root}/users/${user.id}/locations`, {
83
130
  method: 'POST',
84
131
  body: JSON.stringify({
85
- location: JSON.stringify({ location: `{lat: ${location.latitude}, lng: ${location.longitude}}` })
132
+ location: JSON.stringify({
133
+ location: `{
134
+ lat: ${location.latitude},
135
+ lng: ${location.longitude}
136
+ }`
137
+ })
86
138
  }),
87
- headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }
139
+ headers: {
140
+ 'Content-Type': 'application/json',
141
+ Authorization: `Bearer ${token}`
142
+ }
88
143
  })
89
144
  } catch { }
90
145
  const duration = moment.duration(moment().diff(moment.utc(value?.last_driver_assigned_at)))
91
146
  const assignedSecondsDiff = duration.asSeconds()
92
- if (assignedSecondsDiff < 5 && !isBusinessApp && !value?.logistic_status) {
93
- handlePlayNotificationSound({ evt: 2, orderId: value?.id })
147
+ if (assignedSecondsDiff < 5 && !isBusinessApp && !value?.logistic_status && orderStatus.includes(value.status)) {
148
+ setCurrentEvent({ evt: 2, orderId: value?.id ?? value?.order_id })
94
149
  }
95
150
  }
96
- if (evtType === 3 || value?.author_id === user.id) return
97
- handlePlayNotificationSound({
151
+ if (!orderStatus.includes(value.status) || value?.author_id === user.id) return
152
+ setCurrentEvent({
98
153
  evt: evtType,
99
154
  orderId: value?.driver
100
- ? value?.order_id
101
- : evtList[evtType].event === 'messages'
155
+ ? value?.order_id ?? value?.id
156
+ : evtList(currentEvent)[evtType].event === 'messages'
102
157
  ? value?.order?.id
103
158
  : value?.order_id ?? value?.id
104
159
  })
105
160
  }
106
161
 
107
162
  useEffect(() => {
108
- events.on('message_added_notification', (o: any) => handleEventNotification(1, o))
109
- events.on('order_added_notification', (o: any) => handleEventNotification(2, o))
110
- events.on('order_updated_notification', (o: any) => handleEventNotification(3, o))
111
- events.on('request_register_notification', (o: any) => handleEventNotification(2, o))
112
- events.on('request_update_notification', (o: any) => handleEventNotification(3, o))
163
+ events.on('message_added_notification', (o: any) => handleEventNotification(1, o, orderStatus))
164
+ events.on('order_added_notification', (o: any) => handleEventNotification(2, o, orderStatus))
165
+ events.on('order_updated_notification', (o: any) => handleEventNotification(3, o, orderStatus))
166
+ events.on('request_register_notification', (o: any) => handleEventNotification(2, o, orderStatus))
167
+ events.on('request_update_notification', (o: any) => handleEventNotification(3, o, orderStatus))
113
168
 
114
169
  return () => {
115
170
  events.off('message_added_notification', (o: any) => handleEventNotification(1, o))
@@ -118,51 +173,24 @@ const NewOrderNotificationUI = (props: any) => {
118
173
  events.off('request_register_notification', (o: any) => handleEventNotification(2, o))
119
174
  events.off('request_update_notification', (o: any) => handleEventNotification(3, o))
120
175
  }
121
- }, [])
176
+ }, [orderStatus])
122
177
 
123
178
  useEffect(() => {
124
- return () => handleCloseEvents()
179
+ return () => setCurrentEvent(null)
125
180
  }, [])
126
181
 
127
182
  return (
128
183
  <>
129
- <Modal
130
- animationType='slide'
131
- transparent={true}
132
- visible={!!currentEvent?.orderId}
133
- >
134
- <NotificationContainer>
135
- <View style={styles.modalView}>
136
- <TouchableOpacity
137
- style={styles.wrapperIcon}
138
- onPress={() => handleCloseEvents()}
139
- >
140
- <Icon name="x" size={30} />
141
- </TouchableOpacity>
142
- <OText
143
- size={18}
144
- color={theme.colors.textGray}
145
- weight={600}
146
- >
147
- {evtList[currentEvent?.evt]?.message}
148
- </OText>
149
- <OIcon
150
- src={theme.images.general.newOrder}
151
- width={250}
152
- height={200}
153
- />
154
- <OText
155
- color={theme.colors.textGray}
156
- mBottom={15}
157
- >
158
- {evtList[currentEvent?.evt]?.message2}
159
- </OText>
160
- </View>
161
- </NotificationContainer>
162
- </Modal>
184
+ {!!currentEvent && (
185
+ <SoundPlayerComponent
186
+ evtList={evtList}
187
+ currentEvent={currentEvent}
188
+ handleCloseEvents={() => setCurrentEvent(null)}
189
+ />
190
+ )}
163
191
  </>
164
192
  )
165
- }
193
+ };
166
194
 
167
195
  const styles = StyleSheet.create({
168
196
  modalView: {
@@ -182,9 +210,28 @@ const styles = StyleSheet.create({
182
210
  })
183
211
 
184
212
  export const NewOrderNotification = (props: any) => {
213
+ const [, t] = useLanguage()
214
+
185
215
  const newOrderNotificationProps = {
186
216
  ...props,
187
- UIComponent: NewOrderNotificationUI
217
+ UIComponent: NewOrderNotificationUI,
218
+ evtList: (currentEvent: any) => ({
219
+ 1: {
220
+ event: 'messages',
221
+ message: t('NEW_MESSAGES_RECEIVED', 'New messages have been received!'),
222
+ message2: t('ORDER_N_UNREAD_MESSAGES', 'Order #_order_id_ has unread messages.').replace('_order_id_', currentEvent?.orderId),
223
+ },
224
+ 2: {
225
+ event: 'order_added',
226
+ message: t('NEW_ORDERS_RECEIVED', 'New orders have been received!'),
227
+ message2: t('ORDER_N_ORDERED', 'Order #_order_id_ has been ordered.').replace('_order_id_', currentEvent?.orderId),
228
+ },
229
+ 3: {
230
+ event: 'order_updated',
231
+ message: t('NEW_ORDERS_UPDATED', 'New orders have been updated!'),
232
+ message2: t('ORDER_N_UPDATED', 'Order #_order_id_ has been updated.').replace('_order_id_', currentEvent?.orderId),
233
+ },
234
+ })
188
235
  };
189
236
 
190
237
  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,10 @@ 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)
79
+
80
+ const orderToComplete = [4,20,21]
73
81
 
74
82
  if (order?.status === 7 || order?.status === 4) {
75
83
  if (drivers?.length > 0 && drivers) {
@@ -120,6 +128,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
120
128
  }
121
129
  }
122
130
 
131
+ const handleChangeOrderStatus = async (status: any, isAcceptOrReject: any = {}) => {
132
+ if (props.handleChangeOrderStatus) {
133
+ const order: any = await props.handleChangeOrderStatus(status, isAcceptOrReject)
134
+
135
+ if (order?.status === 7 && autoPrintEnabled && printerSettings) {
136
+ handleViewSummaryOrder()
137
+ }
138
+ }
139
+ }
140
+
123
141
  const getFormattedSubOptionName = ({ quantity, name, position, price }: any) => {
124
142
  if (name !== 'No') {
125
143
  const pos = position && position !== 'whole' ? `(${t(position.toUpperCase(), position)})` : '';
@@ -291,7 +309,26 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
291
309
  setOpenModalForAccept(true);
292
310
  };
293
311
 
312
+ const printAction = async (printerSettings: any, commands: any) => {
313
+ try {
314
+ var printResult = await StarPRNT.print(printerSettings?.emulation, commands, printerSettings?.portName);
315
+ showToast(ToastType.Info, t('ORDER_PRINTED_SUCCESS', 'Order printed'), 1000)
316
+ } catch (e) {
317
+ showToast(ToastType.Error, t('ORDER_PRINTED_FAILED', 'Order not printed, connection failed'), 1000)
318
+ }
319
+ }
320
+
294
321
  const handleViewSummaryOrder = () => {
322
+ if (printerSettings) {
323
+ const commands: any = generateCommands({
324
+ ...order,
325
+ orderStatus: getOrderStatus(order?.status, t)?.value
326
+ }, printerSettings?.printMode)
327
+ commands.push({ appendCutPaper: StarPRNT.CutPaperAction.PartialCutWithFeed })
328
+
329
+ printAction(printerSettings, commands)
330
+ return
331
+ }
295
332
  navigation?.navigate &&
296
333
  navigation.navigate('OrderSummary', {
297
334
  order,
@@ -372,6 +409,17 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
372
409
  }
373
410
  }, [driverLocation]);
374
411
 
412
+ useEffect(() => {
413
+ const getStorageData = async () => {
414
+ const printer = await _retrieveStoreData('printer')
415
+ const autoPrint = await _retrieveStoreData('auto_print_after_accept_order')
416
+ setPrinterSettings(printer)
417
+ setAutoPrintEnabled(!!autoPrint)
418
+ }
419
+
420
+ getStorageData()
421
+ }, [])
422
+
375
423
  const styles = StyleSheet.create({
376
424
  driverOff: {
377
425
  backgroundColor: theme.colors.notAvailable,
@@ -607,7 +655,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
607
655
  disabled={loading}
608
656
  />
609
657
  )}
610
- {order?.status === 4 && ![1].includes(order?.delivery_type) && (
658
+ {orderToComplete.includes(order?.status) && ![1].includes(order?.delivery_type) && (
611
659
  <FloatingButton
612
660
  btnText={t(
613
661
  'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
@@ -61,9 +61,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
61
61
  const [, { showToast }] = useToast();
62
62
  const [{ parsePrice, parseNumber }] = useUtils();
63
63
  const [{ configs }] = useConfig();
64
+
64
65
  const { order } = props.order
65
66
 
67
+ const hideTimer = configs?.hidden_driver_eta_time?.value === '1'
66
68
  const isAllowedDriverRejectOrder = configs?.allow_driver_reject_order?.value === '1'
69
+ const isHideRejectButtons = configs?.reject_orders_enabled && configs?.reject_orders_enabled?.value !== '1'
70
+ const isEnabledOrderNotReady = configs?.order_not_ready_enabled?.value === '1'
71
+ const isEnabledFailedPickupDriver = configs?.failed_pickup_by_driver_enabled?.value === '1'
67
72
  const theme = useTheme();
68
73
  const [, t] = useLanguage();
69
74
  const [session] = useSession();
@@ -88,9 +93,9 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
88
93
  const logisticOrderStatus = [4, 6, 7]
89
94
 
90
95
  const showFloatButtonsPickUp: any = {
91
- 8: true,
96
+ 8: !isHideRejectButtons,
92
97
  3: true,
93
- 18: true,
98
+ 18: !isHideRejectButtons,
94
99
  };
95
100
 
96
101
  const showFloatButtonsAcceptOrReject: any = {
@@ -113,6 +118,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
113
118
  readMessages && readMessages();
114
119
  };
115
120
 
121
+ const goToPermissionPage = () => {
122
+ navigation.navigate('RequestPermissions')
123
+ }
124
+
116
125
  const handleOpenMapView = async () => {
117
126
  if (!isGrantedPermissions) {
118
127
  navigation.navigate('RequestPermissions')
@@ -387,7 +396,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
387
396
  }, [props.order?.loading]);
388
397
 
389
398
  useEffect(() => {
390
- if (!order?.driver_id && session?.user?.level === 4) {
399
+ if (order?.driver_id === null && session?.user?.level === 4) {
391
400
  setAlertState({
392
401
  open: true,
393
402
  content: [
@@ -476,13 +485,13 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
476
485
  textStyle={{ color: theme.colors.primary }}
477
486
  text={t('ARRIVED_TO_BUSINESS', 'Arrived to bussiness')}
478
487
  onClick={() =>
479
- handleChangeOrderStatus && handleChangeOrderStatus(3)
488
+ handleChangeOrderStatus && isGrantedPermissions ? handleChangeOrderStatus(3) : goToPermissionPage()
480
489
  }
481
490
  imgLeftStyle={{ tintColor: theme.colors.backArrow }}
482
491
  />
483
492
  </Pickup>
484
493
  )}
485
- {order?.status === 3 && order?.delivery_type === 1 && (
494
+ {order?.status === 3 && order?.delivery_type === 1 && !isHideRejectButtons && isEnabledOrderNotReady && (
486
495
  <View style={{ paddingVertical: 20, marginBottom: 20 }}>
487
496
  <OButton
488
497
  style={styles.btnPickUp}
@@ -568,7 +577,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
568
577
  btnText={t('PICKUP_FAILED', 'Pickup failed')}
569
578
  isSecondaryBtn={false}
570
579
  secondButtonClick={() =>
571
- handleChangeOrderStatus && handleChangeOrderStatus(9)
580
+ handleChangeOrderStatus && isGrantedPermissions ? handleChangeOrderStatus(9) : goToPermissionPage()
572
581
  }
573
582
  firstButtonClick={() =>
574
583
  handleViewActionOrder && handleViewActionOrder('pickupFailed')
@@ -577,7 +586,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
577
586
  secondButton={true}
578
587
  firstColorCustom={theme.colors.red}
579
588
  secondColorCustom={theme.colors.green}
580
- widthButton={'45%'}
589
+ widthButton={isHideRejectButtons || !isEnabledFailedPickupDriver ? '100%' : '45%'}
590
+ isHideRejectButtons={isHideRejectButtons || !isEnabledFailedPickupDriver}
581
591
  />
582
592
  )}
583
593
  {(validStatusComplete.includes(order?.status)) && (
@@ -587,7 +597,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
587
597
  btnText={t('DELIVERY_FAILED', 'Delivery Failed')}
588
598
  isSecondaryBtn={false}
589
599
  secondButtonClick={() =>
590
- handleChangeOrderStatus && handleChangeOrderStatus(11)
600
+ handleChangeOrderStatus && isGrantedPermissions ? handleChangeOrderStatus(11) : goToPermissionPage()
591
601
  }
592
602
  firstButtonClick={() =>
593
603
  handleViewActionOrder && handleViewActionOrder('deliveryFailed')
@@ -596,7 +606,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
596
606
  secondButton={true}
597
607
  firstColorCustom={theme.colors.red}
598
608
  secondColorCustom={theme.colors.green}
599
- widthButton={'45%'}
609
+ widthButton={isHideRejectButtons ? '100%' : '45%'}
610
+ isHideRejectButtons={isHideRejectButtons}
600
611
  />
601
612
  </>
602
613
  )}
@@ -604,13 +615,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
604
615
  <FloatingButton
605
616
  btnText={t('REJECT', 'Reject')}
606
617
  isSecondaryBtn={false}
607
- secondButtonClick={() => (order?.isLogistic && (order?.order_group || logisticOrderStatus.includes(order?.status))) ? handleAcceptLogisticOrder(order) : handleViewActionOrder('accept')}
618
+ secondButtonClick={() => hideTimer ? handleChangeOrderStatus && handleChangeOrderStatus(8) : (order?.isLogistic && (order?.order_group || logisticOrderStatus.includes(order?.status))) ? handleAcceptLogisticOrder(order) : handleViewActionOrder('accept')}
608
619
  firstButtonClick={() => order?.isLogistic && (order?.order_group || logisticOrderStatus.includes(order?.status)) ? handleRejectLogisticOrder() : handleViewActionOrder('reject')}
609
620
  secondBtnText={t('ACCEPT', 'Accept')}
610
621
  secondButton={true}
611
622
  firstColorCustom={theme.colors.red}
612
623
  secondColorCustom={theme.colors.green}
613
- widthButton={'45%'}
624
+ widthButton={isHideRejectButtons ? '100%' : '45%'}
625
+ isHideRejectButtons={isHideRejectButtons}
614
626
  />
615
627
  )}
616
628
  </>