ordering-ui-react-native 0.17.94 → 0.17.95-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 (224) hide show
  1. package/package.json +9 -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 +0 -20
  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 +7 -2
  13. package/themes/business/index.tsx +2 -0
  14. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +36 -26
  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/index.tsx +5 -2
  22. package/themes/business/src/components/MapView/index.tsx +14 -10
  23. package/themes/business/src/components/MessagesOption/index.tsx +22 -94
  24. package/themes/business/src/components/NewOrderNotification/index.tsx +123 -96
  25. package/themes/business/src/components/NotFoundSource/index.tsx +2 -2
  26. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  27. package/themes/business/src/components/OrderDetails/Delivery.tsx +202 -12
  28. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +84 -37
  29. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +87 -66
  30. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +200 -0
  31. package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
  32. package/themes/business/src/components/OrderMessage/index.tsx +19 -18
  33. package/themes/business/src/components/OrderSummary/index.tsx +114 -123
  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 +44 -47
  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 +21 -29
  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 +198 -221
  43. package/themes/business/src/components/PreviousOrders/styles.tsx +10 -0
  44. package/themes/business/src/components/ProductItemAccordion/index.tsx +7 -1
  45. package/themes/business/src/components/ReviewCustomer/index.tsx +18 -13
  46. package/themes/business/src/components/StoresList/index.tsx +3 -4
  47. package/themes/business/src/components/UserProfileForm/index.tsx +14 -15
  48. package/themes/business/src/components/WebsocketStatus/index.tsx +171 -0
  49. package/themes/business/src/components/WebsocketStatus/styles.tsx +28 -0
  50. package/themes/business/src/components/shared/OModal.tsx +16 -9
  51. package/themes/business/src/types/index.tsx +24 -10
  52. package/themes/business/src/utils/index.tsx +29 -2
  53. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  54. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  55. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  56. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  57. package/themes/kiosk/src/components/Intro/index.tsx +16 -1
  58. package/themes/kiosk/src/components/LoginForm/index.tsx +7 -5
  59. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  60. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  61. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  62. package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +2 -2
  63. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  64. package/themes/original/index.tsx +7 -3
  65. package/themes/original/src/components/AddressDetails/index.tsx +19 -3
  66. package/themes/original/src/components/AddressForm/index.tsx +35 -17
  67. package/themes/original/src/components/AddressList/index.tsx +5 -8
  68. package/themes/original/src/components/AnalyticsSegment/index.tsx +193 -10
  69. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  70. package/themes/original/src/components/AppleLogin/styles.tsx +3 -1
  71. package/themes/original/src/components/BusinessBasicInformation/index.tsx +72 -36
  72. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +10 -12
  73. package/themes/original/src/components/BusinessController/index.tsx +35 -44
  74. package/themes/original/src/components/BusinessController/styles.tsx +12 -5
  75. package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
  76. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
  77. package/themes/original/src/components/BusinessInformation/index.tsx +140 -85
  78. package/themes/original/src/components/BusinessItemAccordion/index.tsx +21 -23
  79. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +1 -1
  80. package/themes/original/src/components/BusinessListingSearch/index.tsx +346 -340
  81. package/themes/original/src/components/BusinessListingSearch/styles.tsx +0 -18
  82. package/themes/original/src/components/BusinessPreorder/index.tsx +103 -19
  83. package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -2
  84. package/themes/original/src/components/BusinessProductsList/index.tsx +15 -7
  85. package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
  86. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +1 -1
  87. package/themes/original/src/components/BusinessProductsListing/index.tsx +137 -32
  88. package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -3
  89. package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
  90. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
  91. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
  92. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
  93. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +36 -403
  94. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  95. package/themes/original/src/components/Cart/index.tsx +51 -87
  96. package/themes/original/src/components/CartContent/index.tsx +70 -30
  97. package/themes/original/src/components/CartContent/styles.tsx +6 -6
  98. package/themes/original/src/components/Checkout/index.tsx +265 -32
  99. package/themes/original/src/components/CitiesControl/index.tsx +1 -1
  100. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  101. package/themes/original/src/components/DatePicker/index.tsx +17 -0
  102. package/themes/original/src/components/DatePicker/styles.tsx +20 -0
  103. package/themes/original/src/components/DriverTips/index.tsx +12 -4
  104. package/themes/original/src/components/FacebookLogin/styles.tsx +3 -1
  105. package/themes/original/src/components/Favorite/index.tsx +1 -5
  106. package/themes/original/src/components/GPSButton/index.tsx +6 -4
  107. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +8 -3
  108. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +42 -5
  109. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +2 -0
  110. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +84 -8
  111. package/themes/original/src/components/GoogleLogin/styles.tsx +1 -1
  112. package/themes/original/src/components/GoogleMap/index.tsx +63 -7
  113. package/themes/original/src/components/Home/index.tsx +13 -4
  114. package/themes/original/src/components/LastOrder/index.tsx +2 -1
  115. package/themes/original/src/components/LastOrders/index.tsx +2 -1
  116. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -25
  117. package/themes/original/src/components/LoginForm/index.tsx +64 -34
  118. package/themes/original/src/components/LottieAnimation/index.tsx +88 -63
  119. package/themes/original/src/components/MessageListing/index.tsx +9 -2
  120. package/themes/original/src/components/Messages/index.tsx +15 -4
  121. package/themes/original/src/components/MomentOption/index.tsx +41 -36
  122. package/themes/original/src/components/MomentOption/styles.tsx +0 -15
  123. package/themes/original/src/components/MomentSelector/index.tsx +1 -1
  124. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +161 -49
  125. package/themes/original/src/components/MultiCheckout/index.tsx +347 -69
  126. package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
  127. package/themes/original/src/components/MultiOrdersDetails/index.tsx +1 -1
  128. package/themes/original/src/components/MyOrders/index.tsx +12 -1
  129. package/themes/original/src/components/NavBar/index.tsx +20 -13
  130. package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
  131. package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
  132. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +21 -5
  133. package/themes/original/src/components/OrderDetails/index.tsx +50 -38
  134. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  135. package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
  136. package/themes/original/src/components/OrderProgress/index.tsx +34 -25
  137. package/themes/original/src/components/OrderSummary/index.tsx +59 -56
  138. package/themes/original/src/components/OrderTypeSelector/index.tsx +5 -6
  139. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +13 -13
  140. package/themes/original/src/components/OrdersOption/index.tsx +43 -20
  141. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  142. package/themes/original/src/components/PageBanner/index.tsx +65 -29
  143. package/themes/original/src/components/PageBanner/styles.tsx +0 -3
  144. package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
  145. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +3 -0
  146. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  147. package/themes/original/src/components/PaymentOptions/index.tsx +100 -34
  148. package/themes/original/src/components/PhoneInputNumber/index.tsx +18 -4
  149. package/themes/original/src/components/ProductForm/index.tsx +86 -30
  150. package/themes/original/src/components/ProductForm/styles.tsx +3 -3
  151. package/themes/original/src/components/ProductItemAccordion/index.tsx +8 -6
  152. package/themes/original/src/components/ProductOptionSubOption/index.tsx +49 -20
  153. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +10 -9
  154. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  155. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
  156. package/themes/original/src/components/ProfessionalProfile/index.tsx +36 -7
  157. package/themes/original/src/components/Promotions/index.tsx +2 -2
  158. package/themes/original/src/components/Promotions/styles.tsx +3 -1
  159. package/themes/original/src/components/ReviewProducts/index.tsx +16 -7
  160. package/themes/original/src/components/ScheduleAccordion/index.tsx +3 -3
  161. package/themes/original/src/components/ServiceForm/index.tsx +63 -20
  162. package/themes/original/src/components/SignupForm/index.tsx +43 -27
  163. package/themes/original/src/components/SingleOrderCard/index.tsx +44 -20
  164. package/themes/original/src/components/SingleOrderCard/styles.tsx +1 -1
  165. package/themes/original/src/components/SingleProductCard/index.tsx +13 -10
  166. package/themes/original/src/components/SingleProductCard/styles.tsx +8 -3
  167. package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
  168. package/themes/original/src/components/StripeCardsList/index.tsx +61 -5
  169. package/themes/original/src/components/StripeElementsForm/index.tsx +48 -34
  170. package/themes/original/src/components/StripeElementsForm/naked.tsx +12 -1
  171. package/themes/original/src/components/UpsellingProducts/index.tsx +5 -10
  172. package/themes/original/src/components/UserDetails/index.tsx +3 -1
  173. package/themes/original/src/components/UserFormDetails/index.tsx +113 -10
  174. package/themes/original/src/components/UserFormDetails/styles.tsx +1 -1
  175. package/themes/original/src/components/UserProfile/index.tsx +7 -25
  176. package/themes/original/src/components/UserProfileForm/index.tsx +30 -31
  177. package/themes/original/src/components/UserVerification/index.tsx +55 -50
  178. package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
  179. package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
  180. package/themes/original/src/components/Wallets/index.tsx +51 -61
  181. package/themes/original/src/components/Wallets/styles.tsx +2 -4
  182. package/themes/original/src/components/shared/OButton.tsx +3 -3
  183. package/themes/original/src/components/shared/OInput.tsx +4 -5
  184. package/themes/original/src/components/shared/OModal.tsx +3 -3
  185. package/themes/original/src/config/constants.tsx +0 -10
  186. package/themes/original/src/types/index.tsx +36 -17
  187. package/themes/original/src/utils/index.tsx +185 -13
  188. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  189. package/src/navigators/BottomNavigator.tsx +0 -117
  190. package/src/navigators/CheckoutNavigator.tsx +0 -66
  191. package/src/navigators/HomeNavigator.tsx +0 -202
  192. package/src/navigators/NavigationRef.tsx +0 -7
  193. package/src/navigators/RootNavigator.tsx +0 -269
  194. package/src/pages/Account.tsx +0 -34
  195. package/src/pages/AddressForm.tsx +0 -62
  196. package/src/pages/AddressList.tsx +0 -24
  197. package/src/pages/BusinessProductsList.tsx +0 -81
  198. package/src/pages/BusinessesListing.tsx +0 -43
  199. package/src/pages/CartList.tsx +0 -49
  200. package/src/pages/Checkout.tsx +0 -101
  201. package/src/pages/ForgotPassword.tsx +0 -24
  202. package/src/pages/Help.tsx +0 -23
  203. package/src/pages/HelpAccountAndPayment.tsx +0 -23
  204. package/src/pages/HelpGuide.tsx +0 -23
  205. package/src/pages/HelpOrder.tsx +0 -23
  206. package/src/pages/Home.tsx +0 -36
  207. package/src/pages/IntroductoryTutorial.tsx +0 -170
  208. package/src/pages/Login.tsx +0 -47
  209. package/src/pages/MomentOption.tsx +0 -30
  210. package/src/pages/MultiCheckout.tsx +0 -31
  211. package/src/pages/MultiOrdersDetails.tsx +0 -27
  212. package/src/pages/MyOrders.tsx +0 -40
  213. package/src/pages/NetworkError.tsx +0 -24
  214. package/src/pages/NotFound.tsx +0 -22
  215. package/src/pages/OrderDetails.tsx +0 -25
  216. package/src/pages/ProductDetails.tsx +0 -55
  217. package/src/pages/Profile.tsx +0 -36
  218. package/src/pages/ReviewDriver.tsx +0 -30
  219. package/src/pages/ReviewOrder.tsx +0 -32
  220. package/src/pages/ReviewProducts.tsx +0 -30
  221. package/src/pages/Sessions.tsx +0 -22
  222. package/src/pages/Signup.tsx +0 -53
  223. package/src/pages/SpinnerLoader.tsx +0 -10
  224. package/src/pages/Splash.tsx +0 -21
@@ -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={
@@ -4,6 +4,7 @@ import { StyleSheet, View } from 'react-native';
4
4
 
5
5
  // Thirds
6
6
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
7
+ import Clipboard from '@react-native-clipboard/clipboard';
7
8
 
8
9
  //OrderingComponent
9
10
  import {
@@ -12,6 +13,8 @@ import {
12
13
  useToast,
13
14
  useSession,
14
15
  ToastType,
16
+ useUtils,
17
+ useConfig
15
18
  } from 'ordering-components/native';
16
19
 
17
20
  //Components
@@ -26,7 +29,7 @@ import { OrderDetailsParams } from '../../types';
26
29
  import { USER_TYPE } from '../../config/constants';
27
30
  import { useTheme } from 'styled-components/native';
28
31
  import { NotFoundSource } from '../NotFoundSource';
29
- import { getOrderStatus } from '../../utils';
32
+ import { verifyDecimals, getProductPrice, getOrderStatus } from '../../utils';
30
33
  import { OrderHeaderComponent } from './OrderHeaderComponent';
31
34
  import { OrderContentComponent } from './OrderContentComponent';
32
35
  //Styles
@@ -52,10 +55,17 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
52
55
  handleClickLogisticOrder,
53
56
  forceUpdate,
54
57
  getPermissions,
55
- isGrantedPermissions
58
+ orderAssingId,
59
+ isGrantedPermissions,
56
60
  } = props;
57
61
  const [, { showToast }] = useToast();
62
+ const [{ parsePrice, parseNumber }] = useUtils();
63
+ const [{ configs }] = useConfig();
64
+
58
65
  const { order } = props.order
66
+
67
+ const isAllowedDriverRejectOrder = configs?.allow_driver_reject_order?.value === '1'
68
+ const isHideRejectButtons = configs?.reject_orders_enabled && configs?.reject_orders_enabled?.value !== '1'
59
69
  const theme = useTheme();
60
70
  const [, t] = useLanguage();
61
71
  const [session] = useSession();
@@ -75,12 +85,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
75
85
 
76
86
  const validStatusComplete = [9, 19, 23]
77
87
 
88
+ const pendingOrderStatus = [1, 4, 7, 13]
89
+
78
90
  const logisticOrderStatus = [4, 6, 7]
79
91
 
80
92
  const showFloatButtonsPickUp: any = {
81
- 8: true,
93
+ 8: !isHideRejectButtons,
82
94
  3: true,
83
- 18: true,
95
+ 18: !isHideRejectButtons,
84
96
  };
85
97
 
86
98
  const showFloatButtonsAcceptOrReject: any = {
@@ -133,7 +145,174 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
133
145
  }
134
146
  };
135
147
 
148
+ const getFormattedSubOptionName = ({ quantity, name, position, price }: any) => {
149
+ if (name !== 'No') {
150
+ const pos = position && position !== 'whole' ? `(${t(position.toUpperCase(), position)})` : '';
151
+ return pos
152
+ ? `${quantity} x ${name} ${pos} +${parsePrice(price)}\n`
153
+ : `${quantity} x ${name} +${parsePrice(price)}\n`;
154
+ } else {
155
+ return 'No\n';
156
+ }
157
+ };
158
+
159
+ const handleCopyClipboard = () => {
160
+ const businessName = !!order?.business?.name
161
+ ? `${order?.business?.name} \n`
162
+ : '';
163
+
164
+ const businessEmail = !!order?.business?.email
165
+ ? `${order?.business?.email} \n`
166
+ : '';
167
+
168
+ const businessCellphone = !!order?.business?.cellphone
169
+ ? `${order?.business?.cellphone} \n`
170
+ : '';
171
+
172
+ const businessPhone = !!order?.business?.phone
173
+ ? `${order?.business?.phone} \n`
174
+ : '';
175
+
176
+ const businessAddress = !!order?.business?.address
177
+ ? `${order?.business?.address} \n`
178
+ : '';
179
+
180
+ const businessSpecialAddress = !!order?.business?.address_notes
181
+ ? `${order?.business?.address_notes} \n \n`
182
+ : '';
183
+
184
+ const customerName = !!order?.customer?.name
185
+ ? `${order?.customer?.name} ${order?.customer?.middle_name || ''} ${order?.customer?.lastname || ''
186
+ } ${order?.customer?.second_lastname || ''} \n`
187
+ : '';
188
+
189
+ const customerEmail = !!order?.customer.email
190
+ ? `${order?.customer.email} \n`
191
+ : '';
192
+
193
+ const customerCellPhone = !!order?.customer?.cellphone
194
+ ? `${order?.customer?.cellphone} \n`
195
+ : '';
196
+
197
+ const customerPhone = !!order?.customer?.phone
198
+ ? `${order?.customer?.phone} \n`
199
+ : '';
200
+
201
+ const customerAddress = !!order?.customer?.address
202
+ ? `${order?.customer?.address} \n`
203
+ : '';
204
+
205
+ const customerSpecialAddress = !!order?.customer?.address_notes
206
+ ? `${order?.customer?.address_notes} \n`
207
+ : '';
208
+
209
+ const payment = order?.paymethod?.name
210
+ ? `${order?.paymethod?.name} - ${order.delivery_type === 1
211
+ ? t('DELIVERY', 'Delivery')
212
+ : order.delivery_type === 2
213
+ ? t('PICKUP', 'Pickup')
214
+ : order.delivery_type === 3
215
+ ? t('EAT_IN', 'Eat in')
216
+ : order.delivery_type === 4
217
+ ? t('CURBSIDE', 'Curbside')
218
+ : t('DRIVER_THRU', 'Driver thru')
219
+ }\n`
220
+ : '';
221
+
222
+ const getSuboptions = (suboptions: any) => {
223
+ const array: any = []
224
+ suboptions?.length > 0 &&
225
+ suboptions?.map((suboption: any) => {
226
+ const string = `${getFormattedSubOptionName(suboption)}`
227
+ array.push(string)
228
+ })
229
+
230
+ return array.join('')
231
+ }
232
+
233
+ const getOptions = (options: any, productComment: string = '') => {
234
+ const array: any = [];
235
+
236
+ options?.length &&
237
+ options?.map((option: any) => {
238
+ const string =
239
+ ` ${option.name}\n ${getSuboptions(option.suboptions)}`;
240
+
241
+ array.push(string)
242
+ })
243
+
244
+ if (productComment) {
245
+ array.push(` ${t('COMMENT', 'Comment')}\n ${productComment}\n`)
246
+ }
247
+
248
+ return array.join('')
249
+ }
250
+
251
+ const productsInArray =
252
+ order?.products.length &&
253
+ order?.products.map((product: any, i: number) => {
254
+ const string =
255
+ `${product?.quantity} X ${product?.name} ${parsePrice(product.total ?? getProductPrice(product))}\n${getOptions(product.options, product.comment)}`;
256
+
257
+ return i === 0 ? ` ${string}` : string
258
+ });
259
+
260
+ const productsInString = productsInArray.join(' ');
261
+ const orderDetails = `${t(
262
+ 'ORDER_DETAILS',
263
+ 'Order Details',
264
+ )}:\n${productsInString}\n`;
265
+
266
+ const subtotal = `${t('SUBTOTAL', 'Subtotal')}: ${parsePrice(
267
+ order?.subtotal,
268
+ )}\n`;
269
+
270
+ const drivertip = `${t('DRIVER_TIP', 'Driver tip')} ${parsePrice(
271
+ order?.summary?.driver_tip || order?.totalDriverTip,
272
+ )}\n`;
273
+
274
+ const deliveryFee = `${t('DELIVERY_FEE', 'Delivery fee')} ${verifyDecimals(
275
+ order?.service_fee,
276
+ parseNumber,
277
+ )}% ${parsePrice(order?.summary?.service_fee || order?.serviceFee || 0)}\n`;
278
+
279
+ const total = `${t('TOTAL', 'Total')} ${parsePrice(
280
+ order?.summary?.total || order?.total,
281
+ )}\n`;
282
+
283
+ const orderStatus = `${t('INVOICE_ORDER_NO', 'Order No.')} ${order.id} ${t(
284
+ 'IS',
285
+ 'is',
286
+ )} ${getOrderStatus(order?.status, t)?.value}\n`;
287
+
288
+ Clipboard.setString(
289
+ `${orderStatus} ${payment} ${t(
290
+ 'BUSINESS_DETAILS',
291
+ 'Business Details',
292
+ )}\n ${businessName} ${businessEmail} ${businessCellphone} ${businessPhone} ${businessAddress} ${businessSpecialAddress}${t(
293
+ 'CUSTOMER_DETAILS',
294
+ 'Customer Details',
295
+ )}\n ${customerName} ${customerEmail} ${customerCellPhone} ${customerPhone} ${customerAddress} ${customerSpecialAddress}\n${orderDetails} ${subtotal} ${drivertip} ${deliveryFee} ${total}`,
296
+ );
297
+
298
+ showToast(
299
+ ToastType.Info,
300
+ t('COPY_TO_CLIPBOARD', 'Copy to clipboard.'),
301
+ 1000,
302
+ );
303
+ };
304
+
136
305
  const handleViewActionOrder = (action: string) => {
306
+ if (action === 'reject' && !isAllowedDriverRejectOrder) {
307
+ setAlertState({
308
+ open: true,
309
+ content: [
310
+ t('DRIVER_NOT_ALLOWED_TO_REJECT_ORDER', 'The driver is not allowed to reject an order.'),
311
+ ],
312
+ key: null,
313
+ })
314
+ return
315
+ }
137
316
  if (!isGrantedPermissions) {
138
317
  navigation.navigate('RequestPermissions')
139
318
  return
@@ -150,16 +329,23 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
150
329
  };
151
330
 
152
331
  const handleArrowBack: any = () => {
332
+ if (alertState?.open && !isAllowedDriverRejectOrder && !pendingOrderStatus.includes(order?.status)) {
333
+ setAlertState({
334
+ ...alertState,
335
+ open: false
336
+ })
337
+ return
338
+ }
153
339
  navigation?.canGoBack() && navigation.goBack();
154
340
  };
155
341
 
156
342
  const handleRejectLogisticOrder = () => {
157
- handleClickLogisticOrder?.(2, order?.logistic_order_id)
343
+ handleClickLogisticOrder?.(2, orderAssingId || order?.logistic_order_id)
158
344
  handleArrowBack()
159
345
  }
160
346
 
161
347
  const handleAcceptLogisticOrder = (order: any) => {
162
- handleClickLogisticOrder?.(1, order?.logistic_order_id)
348
+ handleClickLogisticOrder?.(1, orderAssingId || order?.logistic_order_id)
163
349
  if (order?.order_group) {
164
350
  handleArrowBack()
165
351
  }
@@ -203,7 +389,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
203
389
  }, [props.order?.loading]);
204
390
 
205
391
  useEffect(() => {
206
- if (order?.driver === null && session?.user?.level === 4) {
392
+ if (!order?.driver_id && session?.user?.level === 4) {
207
393
  setAlertState({
208
394
  open: true,
209
395
  content: [
@@ -298,7 +484,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
298
484
  />
299
485
  </Pickup>
300
486
  )}
301
- {order?.status === 3 && order?.delivery_type === 1 && (
487
+ {order?.status === 3 && order?.delivery_type === 1 && !isHideRejectButtons && (
302
488
  <View style={{ paddingVertical: 20, marginBottom: 20 }}>
303
489
  <OButton
304
490
  style={styles.btnPickUp}
@@ -343,7 +529,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
343
529
  </View>
344
530
  )}
345
531
 
346
- {(!!props.order?.error || props.order?.error) && (
532
+ {(!!props.order?.error || props.order?.error?.length > 0) && (
347
533
  <NotFoundSource
348
534
  btnTitle={t('GO_TO_MY_ORDERS', 'Go to my orders')}
349
535
  content={
@@ -361,6 +547,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
361
547
  order={order}
362
548
  handleOpenMapView={handleOpenMapView}
363
549
  handleOpenMessagesForBusiness={handleOpenMessagesForBusiness}
550
+ handleCopyClipboard={handleCopyClipboard}
364
551
  getOrderStatus={getOrderStatus}
365
552
  handleArrowBack={handleArrowBack}
366
553
  logisticOrderStatus={logisticOrderStatus}
@@ -392,7 +579,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
392
579
  secondButton={true}
393
580
  firstColorCustom={theme.colors.red}
394
581
  secondColorCustom={theme.colors.green}
395
- widthButton={'45%'}
582
+ widthButton={isHideRejectButtons ? '100%': '45%'}
583
+ isHideRejectButtons={isHideRejectButtons}
396
584
  />
397
585
  )}
398
586
  {(validStatusComplete.includes(order?.status)) && (
@@ -411,7 +599,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
411
599
  secondButton={true}
412
600
  firstColorCustom={theme.colors.red}
413
601
  secondColorCustom={theme.colors.green}
414
- widthButton={'45%'}
602
+ widthButton={isHideRejectButtons ? '100%': '45%'}
603
+ isHideRejectButtons={isHideRejectButtons}
415
604
  />
416
605
  </>
417
606
  )}
@@ -425,7 +614,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
425
614
  secondButton={true}
426
615
  firstColorCustom={theme.colors.red}
427
616
  secondColorCustom={theme.colors.green}
428
- widthButton={'45%'}
617
+ widthButton={isHideRejectButtons ? '100%': '45%'}
618
+ isHideRejectButtons={isHideRejectButtons}
429
619
  />
430
620
  )}
431
621
  </>