ordering-ui-react-native 0.17.89 → 0.17.90-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 (216) hide show
  1. package/package.json +8 -7
  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/OrderCreating/index.tsx +1 -21
  6. package/src/components/PaymentOptionsWebView/index.tsx +29 -8
  7. package/src/components/PhoneInputNumber/index.tsx +6 -2
  8. package/src/components/StripeMethodForm/index.tsx +136 -102
  9. package/src/components/VerifyPhone/styles.tsx +1 -2
  10. package/src/components/shared/OToast.tsx +3 -2
  11. package/src/types/index.tsx +5 -0
  12. package/src/utils/index.tsx +5 -0
  13. package/themes/business/index.tsx +2 -0
  14. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +37 -27
  15. package/themes/business/src/components/BusinessController/index.tsx +0 -1
  16. package/themes/business/src/components/Chat/index.tsx +163 -123
  17. package/themes/business/src/components/DriverMap/index.tsx +17 -6
  18. package/themes/business/src/components/DriverSchedule/index.tsx +45 -8
  19. package/themes/business/src/components/FloatingButton/index.tsx +34 -31
  20. package/themes/business/src/components/GoogleMap/index.tsx +58 -57
  21. package/themes/business/src/components/LoginForm/Otp/index.tsx +31 -3
  22. package/themes/business/src/components/LoginForm/index.tsx +15 -22
  23. package/themes/business/src/components/MapView/index.tsx +14 -10
  24. package/themes/business/src/components/MessagesOption/index.tsx +20 -93
  25. package/themes/business/src/components/NewOrderNotification/index.tsx +123 -96
  26. package/themes/business/src/components/NotFoundSource/index.tsx +2 -2
  27. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  28. package/themes/business/src/components/OrderDetails/Delivery.tsx +202 -12
  29. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +84 -37
  30. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +81 -66
  31. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +200 -0
  32. package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
  33. package/themes/business/src/components/OrderMessage/index.tsx +19 -18
  34. package/themes/business/src/components/OrderSummary/index.tsx +114 -123
  35. package/themes/business/src/components/OrdersOption/index.tsx +22 -22
  36. package/themes/business/src/components/PreviousMessages/FooterMessageComponent.tsx +103 -0
  37. package/themes/business/src/components/PreviousMessages/index.tsx +97 -55
  38. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +17 -12
  39. package/themes/business/src/components/PreviousOrders/OrderList.tsx +93 -0
  40. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +1 -1
  41. package/themes/business/src/components/PreviousOrders/index.tsx +198 -221
  42. package/themes/business/src/components/ProductItemAccordion/index.tsx +7 -1
  43. package/themes/business/src/components/ReviewCustomer/index.tsx +18 -13
  44. package/themes/business/src/components/StoresList/index.tsx +3 -4
  45. package/themes/business/src/components/UserProfileForm/index.tsx +14 -15
  46. package/themes/business/src/components/shared/OModal.tsx +16 -9
  47. package/themes/business/src/types/index.tsx +25 -10
  48. package/themes/business/src/utils/index.tsx +29 -2
  49. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  50. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  51. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  52. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  53. package/themes/kiosk/src/components/Intro/index.tsx +16 -1
  54. package/themes/kiosk/src/components/LoginForm/index.tsx +7 -9
  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/PhoneInputNumber/index.tsx +2 -2
  59. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  60. package/themes/original/index.tsx +1 -1
  61. package/themes/original/src/components/AddressDetails/index.tsx +19 -3
  62. package/themes/original/src/components/AddressForm/index.tsx +35 -17
  63. package/themes/original/src/components/AddressList/index.tsx +5 -8
  64. package/themes/original/src/components/AnalyticsSegment/index.tsx +193 -10
  65. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  66. package/themes/original/src/components/AppleLogin/styles.tsx +3 -1
  67. package/themes/original/src/components/BusinessBasicInformation/index.tsx +73 -37
  68. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +10 -12
  69. package/themes/original/src/components/BusinessController/index.tsx +35 -44
  70. package/themes/original/src/components/BusinessController/styles.tsx +12 -5
  71. package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
  72. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
  73. package/themes/original/src/components/BusinessInformation/index.tsx +140 -85
  74. package/themes/original/src/components/BusinessItemAccordion/index.tsx +15 -20
  75. package/themes/original/src/components/BusinessListingSearch/index.tsx +347 -336
  76. package/themes/original/src/components/BusinessListingSearch/styles.tsx +0 -18
  77. package/themes/original/src/components/BusinessPreorder/index.tsx +103 -19
  78. package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -2
  79. package/themes/original/src/components/BusinessProductsList/index.tsx +15 -7
  80. package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
  81. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +1 -1
  82. package/themes/original/src/components/BusinessProductsListing/index.tsx +663 -556
  83. package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -3
  84. package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
  85. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
  86. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
  87. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
  88. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +38 -405
  89. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  90. package/themes/original/src/components/Cart/index.tsx +60 -51
  91. package/themes/original/src/components/CartContent/index.tsx +102 -58
  92. package/themes/original/src/components/CartContent/styles.tsx +6 -6
  93. package/themes/original/src/components/Checkout/index.tsx +280 -35
  94. package/themes/original/src/components/CitiesControl/index.tsx +1 -1
  95. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  96. package/themes/original/src/components/DriverTips/index.tsx +52 -34
  97. package/themes/original/src/components/FacebookLogin/styles.tsx +3 -1
  98. package/themes/original/src/components/Favorite/index.tsx +1 -5
  99. package/themes/original/src/components/GPSButton/index.tsx +6 -4
  100. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +8 -3
  101. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +42 -5
  102. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +2 -0
  103. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +86 -10
  104. package/themes/original/src/components/GoogleLogin/styles.tsx +1 -1
  105. package/themes/original/src/components/GoogleMap/index.tsx +63 -7
  106. package/themes/original/src/components/Home/index.tsx +13 -4
  107. package/themes/original/src/components/LastOrder/index.tsx +2 -1
  108. package/themes/original/src/components/LastOrders/index.tsx +2 -1
  109. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -25
  110. package/themes/original/src/components/LoginForm/index.tsx +64 -34
  111. package/themes/original/src/components/LottieAnimation/index.tsx +88 -63
  112. package/themes/original/src/components/MessageListing/index.tsx +9 -2
  113. package/themes/original/src/components/Messages/index.tsx +15 -4
  114. package/themes/original/src/components/MomentOption/index.tsx +193 -92
  115. package/themes/original/src/components/MomentSelector/index.tsx +1 -1
  116. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +162 -50
  117. package/themes/original/src/components/MultiCheckout/index.tsx +385 -46
  118. package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
  119. package/themes/original/src/components/MultiOrdersDetails/index.tsx +23 -19
  120. package/themes/original/src/components/MyOrders/index.tsx +25 -16
  121. package/themes/original/src/components/NavBar/index.tsx +20 -13
  122. package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
  123. package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
  124. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +21 -5
  125. package/themes/original/src/components/OrderDetails/index.tsx +50 -38
  126. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  127. package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
  128. package/themes/original/src/components/OrderProgress/index.tsx +34 -25
  129. package/themes/original/src/components/OrderSummary/index.tsx +83 -57
  130. package/themes/original/src/components/OrderTypeSelector/index.tsx +5 -6
  131. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +14 -14
  132. package/themes/original/src/components/OrdersOption/index.tsx +59 -48
  133. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  134. package/themes/original/src/components/PageBanner/index.tsx +65 -29
  135. package/themes/original/src/components/PageBanner/styles.tsx +0 -3
  136. package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
  137. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +3 -0
  138. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  139. package/themes/original/src/components/PaymentOptions/index.tsx +100 -34
  140. package/themes/original/src/components/PhoneInputNumber/index.tsx +18 -4
  141. package/themes/original/src/components/ProductForm/index.tsx +87 -31
  142. package/themes/original/src/components/ProductForm/styles.tsx +3 -3
  143. package/themes/original/src/components/ProductItemAccordion/index.tsx +8 -6
  144. package/themes/original/src/components/ProductOptionSubOption/index.tsx +49 -20
  145. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +10 -9
  146. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  147. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
  148. package/themes/original/src/components/ProfessionalProfile/index.tsx +36 -7
  149. package/themes/original/src/components/Promotions/index.tsx +2 -2
  150. package/themes/original/src/components/Promotions/styles.tsx +3 -1
  151. package/themes/original/src/components/ReviewProducts/index.tsx +16 -7
  152. package/themes/original/src/components/ScheduleAccordion/index.tsx +3 -3
  153. package/themes/original/src/components/ServiceForm/index.tsx +63 -20
  154. package/themes/original/src/components/Sessions/styles.tsx +1 -0
  155. package/themes/original/src/components/SignupForm/index.tsx +43 -27
  156. package/themes/original/src/components/SingleOrderCard/index.tsx +42 -19
  157. package/themes/original/src/components/SingleOrderCard/styles.tsx +1 -1
  158. package/themes/original/src/components/SingleProductCard/index.tsx +14 -11
  159. package/themes/original/src/components/SingleProductCard/styles.tsx +8 -3
  160. package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
  161. package/themes/original/src/components/StripeCardsList/index.tsx +61 -5
  162. package/themes/original/src/components/StripeElementsForm/index.tsx +48 -34
  163. package/themes/original/src/components/StripeElementsForm/naked.tsx +12 -1
  164. package/themes/original/src/components/UpsellingProducts/index.tsx +5 -10
  165. package/themes/original/src/components/UserDetails/index.tsx +3 -1
  166. package/themes/original/src/components/UserFormDetails/index.tsx +78 -9
  167. package/themes/original/src/components/UserFormDetails/styles.tsx +1 -1
  168. package/themes/original/src/components/UserProfile/index.tsx +8 -26
  169. package/themes/original/src/components/UserProfileForm/index.tsx +30 -31
  170. package/themes/original/src/components/UserVerification/index.tsx +55 -50
  171. package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
  172. package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
  173. package/themes/original/src/components/Wallets/index.tsx +52 -62
  174. package/themes/original/src/components/Wallets/styles.tsx +2 -4
  175. package/themes/original/src/components/shared/OButton.tsx +3 -3
  176. package/themes/original/src/components/shared/OInput.tsx +4 -5
  177. package/themes/original/src/components/shared/OModal.tsx +3 -3
  178. package/themes/original/src/types/index.tsx +37 -10
  179. package/themes/original/src/utils/index.tsx +185 -13
  180. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  181. package/src/navigators/BottomNavigator.tsx +0 -117
  182. package/src/navigators/CheckoutNavigator.tsx +0 -66
  183. package/src/navigators/HomeNavigator.tsx +0 -202
  184. package/src/navigators/NavigationRef.tsx +0 -7
  185. package/src/navigators/RootNavigator.tsx +0 -269
  186. package/src/pages/Account.tsx +0 -34
  187. package/src/pages/AddressForm.tsx +0 -62
  188. package/src/pages/AddressList.tsx +0 -24
  189. package/src/pages/BusinessProductsList.tsx +0 -81
  190. package/src/pages/BusinessesListing.tsx +0 -43
  191. package/src/pages/CartList.tsx +0 -49
  192. package/src/pages/Checkout.tsx +0 -101
  193. package/src/pages/ForgotPassword.tsx +0 -24
  194. package/src/pages/Help.tsx +0 -23
  195. package/src/pages/HelpAccountAndPayment.tsx +0 -23
  196. package/src/pages/HelpGuide.tsx +0 -23
  197. package/src/pages/HelpOrder.tsx +0 -23
  198. package/src/pages/Home.tsx +0 -36
  199. package/src/pages/IntroductoryTutorial.tsx +0 -170
  200. package/src/pages/Login.tsx +0 -47
  201. package/src/pages/MomentOption.tsx +0 -30
  202. package/src/pages/MultiCheckout.tsx +0 -31
  203. package/src/pages/MultiOrdersDetails.tsx +0 -27
  204. package/src/pages/MyOrders.tsx +0 -40
  205. package/src/pages/NetworkError.tsx +0 -24
  206. package/src/pages/NotFound.tsx +0 -22
  207. package/src/pages/OrderDetails.tsx +0 -25
  208. package/src/pages/ProductDetails.tsx +0 -55
  209. package/src/pages/Profile.tsx +0 -36
  210. package/src/pages/ReviewDriver.tsx +0 -30
  211. package/src/pages/ReviewOrder.tsx +0 -32
  212. package/src/pages/ReviewProducts.tsx +0 -30
  213. package/src/pages/Sessions.tsx +0 -22
  214. package/src/pages/Signup.tsx +0 -53
  215. package/src/pages/SpinnerLoader.tsx +0 -10
  216. package/src/pages/Splash.tsx +0 -21
@@ -2,20 +2,17 @@ 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
+
19
16
  const MessagesOptionUI = (props: MessagesOptionParams) => {
20
17
  const {
21
18
  orders,
@@ -65,12 +62,6 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
65
62
  ),
66
63
  );
67
64
 
68
- const [orientation, setOrientation] = useState(
69
- Dimensions.get('window').width < Dimensions.get('window').height
70
- ? 'Portrait'
71
- : 'Landscape',
72
- );
73
-
74
65
  const getTagFilter = (key: number) => {
75
66
  return tags.find(value => value.key === key)?.text;
76
67
  };
@@ -114,14 +105,6 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
114
105
  );
115
106
  }, [orders]);
116
107
 
117
- Dimensions.addEventListener('change', ({ window: { width, height } }) => {
118
- if (width < height) {
119
- setOrientation('Portrait');
120
- } else {
121
- setOrientation('Landscape');
122
- }
123
- });
124
-
125
108
  const styles = StyleSheet.create({
126
109
  header: {
127
110
  marginBottom: 25,
@@ -242,35 +225,28 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
242
225
  !error
243
226
  ? t('NO_RESULTS_FOUND', 'Sorry, no results found')
244
227
  : error[0]?.message ||
245
- error[0] ||
246
- t('NETWORK_ERROR', 'Network Error')
228
+ error[0] ||
229
+ t('NETWORK_ERROR', 'Network Error')
247
230
  }
248
231
  image={theme.images.general.notFound}
249
232
  conditioned={false}
250
233
  />
251
234
  )}
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 &&
235
+ <PreviousMessages
236
+ orders={values}
237
+ messages={messages}
238
+ onNavigationRedirect={onNavigationRedirect}
239
+ getOrders={getOrders}
240
+ pagination={pagination}
241
+ loading={loading}
242
+ reload={reload}
243
+ tabs={tabs}
244
+ tabsFilter={tabsFilter}
245
+ setOrders={setOrders}
246
+ loadMore={loadMore}
247
+ error={error}
248
+ />
249
+ {/* {!reload &&
274
250
  !error &&
275
251
  orders.length > 0 &&
276
252
  JSON.stringify(tabsFilter) === JSON.stringify(tabs[1].tags) && (
@@ -283,55 +259,6 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
283
259
  onNavigationRedirect={onNavigationRedirect}
284
260
  />
285
261
  )} */}
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
262
  </>
336
263
  );
337
264
  };
@@ -1,71 +1,102 @@
1
- import React, { useState, useEffect } from 'react'
1
+ import React, { useEffect, useState } from 'react';
2
+ import {
3
+ Modal,
4
+ View,
5
+ StyleSheet,
6
+ Dimensions,
7
+ TouchableOpacity
8
+ } from 'react-native';
9
+ import { useTheme } from 'styled-components/native'
2
10
  import moment from 'moment'
3
- import { View, Modal, StyleSheet, TouchableOpacity, Dimensions } from 'react-native'
4
- import Sound from 'react-native-sound'
5
11
  import Icon from 'react-native-vector-icons/Feather'
6
- import { useTheme } from 'styled-components/native'
7
- import { useEvent, useLanguage, useSession, useApi, NewOrderNotification as NewOrderNotificationController } from 'ordering-components/native'
12
+ import SoundPlayer from 'react-native-sound-player'
8
13
 
9
- import { OText, OIcon } from '../shared'
14
+ import {
15
+ NewOrderNotification as NewOrderNotificationController,
16
+ useApi,
17
+ useEvent,
18
+ useLanguage,
19
+ useSession
20
+ } from 'ordering-components/native'
21
+
22
+ import { OIcon, OText } from '../shared'
10
23
  import { NotificationContainer } from './styles'
11
24
  import { useLocation } from '../../hooks/useLocation'
12
25
 
13
- Sound.setCategory('Playback')
14
-
26
+ const DELAY_SOUND = 2500 // 2 sec
15
27
  const windowWidth = Dimensions.get('screen').width
16
28
 
17
- const SOUND_LOOP = 3
29
+ const SoundPlayerComponent = (props: any) => {
30
+ const { evtList, currentEvent, handleCloseEvents } = props
18
31
 
19
- const NewOrderNotificationUI = (props: any) => {
20
- const { isBusinessApp } = props
21
- const [events] = useEvent()
22
32
  const theme = useTheme()
23
- const [, t] = useLanguage()
24
- const [{ user, token }] = useSession()
25
- const [ordering] = useApi()
26
- const { getCurrentLocation } = useLocation();
27
- const [currentEvent, setCurrentEvent] = useState<any>(null)
33
+ const [count, setCount] = useState(0);
28
34
 
29
- const evtList: any = {
30
- 1: {
31
- event: 'messages',
32
- message: t('NEW_MESSAGES_RECEIVED', 'New messages have been received!'),
33
- message2: t('ORDER_N_UNREAD_MESSAGES', 'Order #_order_id_ has unread messages.').replace('_order_id_', currentEvent?.orderId),
34
- },
35
- 2: {
36
- event: 'order_added',
37
- message: t('NEW_ORDERS_RECEIVED', 'New orders have been received!'),
38
- message2: t('ORDER_N_ORDERED', 'Order #_order_id_ has been ordered.').replace('_order_id_', currentEvent?.orderId),
39
- },
40
- 3: {
41
- event: 'order_updated',
42
- message: t('NEW_ORDERS_UPDATED', 'New orders have been updated!'),
43
- message2: t('ORDER_N_UPDATED', 'Order #_order_id_ has been updated.').replace('_order_id_', currentEvent?.orderId),
44
- },
45
- }
35
+ const URL_SOUND = 'https://d33aymufw4jvwf.cloudfront.net/notification.mp3' ?? theme.sounds.notification
46
36
 
47
- const notificationSound = new Sound(theme.sounds.notification);
37
+ useEffect(() => {
38
+ const id = setInterval(() => setCount(count + 1), 2500)
48
39
 
49
- let _timeout: any = null
40
+ const playSound = async () => {
41
+ SoundPlayer.playUrl(URL_SOUND)
42
+ await new Promise(resolve => setTimeout(resolve, DELAY_SOUND))
43
+ SoundPlayer.stop()
44
+ }
50
45
 
51
- const handleCloseEvents = () => {
52
- notificationSound.stop()
53
- setCurrentEvent(null)
54
- clearInterval(_timeout)
55
- }
46
+ playSound()
56
47
 
57
- const handlePlayNotificationSound = (eventObj: any = null) => {
58
- setCurrentEvent(eventObj)
59
- let times = 1
60
- if (times < SOUND_LOOP) {
61
- _timeout = setInterval(() => {
62
- notificationSound.setVolume(1).play(success => success && (times = times + 1))
63
- if (times === SOUND_LOOP) {
64
- clearInterval(_timeout)
65
- }
66
- }, 2500)
48
+ return () => {
49
+ SoundPlayer.stop()
50
+ clearInterval(id);
67
51
  }
68
- }
52
+ }, [count])
53
+
54
+ return (
55
+ <Modal
56
+ animationType='slide'
57
+ transparent={true}
58
+ visible={!!currentEvent?.orderId}
59
+ >
60
+ <NotificationContainer>
61
+ <View style={styles.modalView}>
62
+ <TouchableOpacity
63
+ style={styles.wrapperIcon}
64
+ onPress={() => handleCloseEvents()}
65
+ >
66
+ <Icon name="x" size={30} />
67
+ </TouchableOpacity>
68
+ <OText
69
+ size={18}
70
+ color={theme.colors.textGray}
71
+ weight={600}
72
+ >
73
+ {evtList(currentEvent)[currentEvent?.evt]?.message}
74
+ </OText>
75
+ <OIcon
76
+ src={theme.images.general.newOrder}
77
+ width={250}
78
+ height={200}
79
+ />
80
+ <OText
81
+ color={theme.colors.textGray}
82
+ mBottom={15}
83
+ >
84
+ {evtList(currentEvent)[currentEvent?.evt]?.message2}
85
+ </OText>
86
+ </View>
87
+ </NotificationContainer>
88
+ </Modal>
89
+ )
90
+ }
91
+
92
+ const NewOrderNotificationUI = (props: any) => {
93
+ const { isBusinessApp, evtList } = props
94
+
95
+ const [events] = useEvent()
96
+ const [{ user, token }] = useSession()
97
+ const [ordering] = useApi()
98
+ const { getCurrentLocation } = useLocation()
99
+ const [currentEvent, setCurrentEvent] = useState<any>(null)
69
100
 
70
101
  const handleEventNotification = async (evtType: number, value: any) => {
71
102
  if (value?.driver) {
@@ -74,21 +105,25 @@ const NewOrderNotificationUI = (props: any) => {
74
105
  await fetch(`${ordering.root}/users/${user.id}/locations`, {
75
106
  method: 'POST',
76
107
  body: JSON.stringify({
77
- location: JSON.stringify({location: `{lat: ${location.latitude}, lng: ${location.longitude}}`})
108
+ location: JSON.stringify({ location: `{lat: ${location.latitude}, lng: ${location.longitude}}` })
78
109
  }),
79
110
  headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }
80
111
  })
81
- } catch {}
112
+ } catch { }
82
113
  const duration = moment.duration(moment().diff(moment.utc(value?.last_driver_assigned_at)))
83
114
  const assignedSecondsDiff = duration.asSeconds()
84
- if (assignedSecondsDiff < 5 && !isBusinessApp) {
85
- handlePlayNotificationSound({ evt: 2, orderId: value?.id })
115
+ if (assignedSecondsDiff < 5 && !isBusinessApp && !value?.logistic_status) {
116
+ setCurrentEvent({ evt: 2, orderId: value?.id })
86
117
  }
87
118
  }
88
- if (evtType === 3 || value.author_id === user.id) return
89
- handlePlayNotificationSound({
119
+ if (evtType === 3 || value?.author_id === user.id) return
120
+ setCurrentEvent({
90
121
  evt: evtType,
91
- orderId: evtList[evtType].event === 'messages' ? value?.order_id : value?.id
122
+ orderId: value?.driver
123
+ ? value?.order_id
124
+ : evtList(currentEvent)[evtType].event === 'messages'
125
+ ? value?.order?.id
126
+ : value?.order_id ?? value?.id
92
127
  })
93
128
  }
94
129
 
@@ -109,48 +144,21 @@ const NewOrderNotificationUI = (props: any) => {
109
144
  }, [])
110
145
 
111
146
  useEffect(() => {
112
- return () => handleCloseEvents()
147
+ return () => setCurrentEvent(null)
113
148
  }, [])
114
149
 
115
150
  return (
116
151
  <>
117
- <Modal
118
- animationType='slide'
119
- transparent={true}
120
- visible={!!currentEvent?.orderId}
121
- >
122
- <NotificationContainer>
123
- <View style={styles.modalView}>
124
- <TouchableOpacity
125
- style={styles.wrapperIcon}
126
- onPress={() => handleCloseEvents()}
127
- >
128
- <Icon name="x" size={30} />
129
- </TouchableOpacity>
130
- <OText
131
- size={18}
132
- color={theme.colors.textGray}
133
- weight={600}
134
- >
135
- {evtList[currentEvent?.evt]?.message}
136
- </OText>
137
- <OIcon
138
- src={theme.images.general.newOrder}
139
- width={250}
140
- height={200}
141
- />
142
- <OText
143
- color={theme.colors.textGray}
144
- mBottom={15}
145
- >
146
- {evtList[currentEvent?.evt]?.message2}
147
- </OText>
148
- </View>
149
- </NotificationContainer>
150
- </Modal>
152
+ {!!currentEvent ? (
153
+ <SoundPlayerComponent
154
+ evtList={evtList}
155
+ currentEvent={currentEvent}
156
+ handleCloseEvents={() => setCurrentEvent(null)}
157
+ />
158
+ ) : null}
151
159
  </>
152
160
  )
153
- }
161
+ };
154
162
 
155
163
  const styles = StyleSheet.create({
156
164
  modalView: {
@@ -170,9 +178,28 @@ const styles = StyleSheet.create({
170
178
  })
171
179
 
172
180
  export const NewOrderNotification = (props: any) => {
181
+ const [, t] = useLanguage()
182
+
173
183
  const newOrderNotificationProps = {
174
184
  ...props,
175
- UIComponent: NewOrderNotificationUI
185
+ UIComponent: NewOrderNotificationUI,
186
+ evtList: (currentEvent: any) => ({
187
+ 1: {
188
+ event: 'messages',
189
+ message: t('NEW_MESSAGES_RECEIVED', 'New messages have been received!'),
190
+ message2: t('ORDER_N_UNREAD_MESSAGES', 'Order #_order_id_ has unread messages.').replace('_order_id_', currentEvent?.orderId),
191
+ },
192
+ 2: {
193
+ event: 'order_added',
194
+ message: t('NEW_ORDERS_RECEIVED', 'New orders have been received!'),
195
+ message2: t('ORDER_N_ORDERED', 'Order #_order_id_ has been ordered.').replace('_order_id_', currentEvent?.orderId),
196
+ },
197
+ 3: {
198
+ event: 'order_updated',
199
+ message: t('NEW_ORDERS_UPDATED', 'New orders have been updated!'),
200
+ message2: t('ORDER_N_UPDATED', 'Order #_order_id_ has been updated.').replace('_order_id_', currentEvent?.orderId),
201
+ },
202
+ })
176
203
  };
177
204
 
178
205
  return <NewOrderNotificationController {...newOrderNotificationProps} />;
@@ -18,7 +18,7 @@ export const NotFoundSource = (props: NotFoundSourceParams) => {
18
18
  <OIcon src={errorImage} width={260} height={220} />
19
19
  </NotFoundImage>
20
20
  )}
21
- {content && conditioned && !errorImage && (
21
+ {!!content && conditioned && !errorImage && (
22
22
  <OText
23
23
  color={theme.colors.textSecondary}
24
24
  size={textSize ?? 18}
@@ -26,7 +26,7 @@ export const NotFoundSource = (props: NotFoundSourceParams) => {
26
26
  {content}
27
27
  </OText>
28
28
  )}
29
- {content && !conditioned && (
29
+ {!!content && !conditioned && (
30
30
  <OText
31
31
  color={theme.colors.textSecondary}
32
32
  size={textSize ?? 18}
@@ -410,7 +410,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
410
410
  </View>
411
411
  )}
412
412
 
413
- {(!!error || error) && (
413
+ {(!!error || error?.length > 0) && (
414
414
  <NotFoundSource
415
415
  btnTitle={t('GO_TO_MY_ORDERS', 'Go to my orders')}
416
416
  content={