ordering-ui-react-native 0.17.49 → 0.17.50-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 (219) hide show
  1. package/package.json +8 -7
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessesListing/index.tsx +1 -1
  4. package/src/components/OrderCreating/index.tsx +1 -21
  5. package/src/components/PaymentOptionsWebView/index.tsx +29 -8
  6. package/src/components/PhoneInputNumber/index.tsx +6 -2
  7. package/src/components/StripeMethodForm/index.tsx +136 -102
  8. package/src/components/VerifyPhone/styles.tsx +1 -2
  9. package/src/components/shared/OToast.tsx +4 -4
  10. package/src/types/index.tsx +5 -0
  11. package/src/utils/index.tsx +7 -1
  12. package/themes/business/index.tsx +2 -0
  13. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +265 -240
  14. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
  15. package/themes/business/src/components/BusinessController/index.tsx +0 -1
  16. package/themes/business/src/components/Chat/index.tsx +125 -113
  17. package/themes/business/src/components/DriverMap/index.tsx +17 -6
  18. package/themes/business/src/components/DriverSchedule/index.tsx +29 -2
  19. package/themes/business/src/components/GoogleMap/index.tsx +58 -57
  20. package/themes/business/src/components/LoginForm/Otp/index.tsx +120 -0
  21. package/themes/business/src/components/LoginForm/Otp/styles.tsx +7 -0
  22. package/themes/business/src/components/LoginForm/index.tsx +238 -80
  23. package/themes/business/src/components/LoginForm/styles.tsx +10 -0
  24. package/themes/business/src/components/MapView/index.tsx +10 -10
  25. package/themes/business/src/components/NewOrderNotification/index.tsx +35 -21
  26. package/themes/business/src/components/OrderDetails/Delivery.tsx +30 -4
  27. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +93 -50
  28. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +59 -62
  29. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +195 -0
  30. package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
  31. package/themes/business/src/components/OrderMessage/index.tsx +18 -17
  32. package/themes/business/src/components/OrderSummary/index.tsx +113 -121
  33. package/themes/business/src/components/OrdersOption/index.tsx +32 -75
  34. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
  35. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
  36. package/themes/business/src/components/PreviousOrders/index.tsx +445 -243
  37. package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
  38. package/themes/business/src/components/ProductItemAccordion/index.tsx +27 -3
  39. package/themes/business/src/components/ReviewCustomer/index.tsx +29 -14
  40. package/themes/business/src/components/StoresList/index.tsx +2 -2
  41. package/themes/business/src/components/UserProfileForm/index.tsx +11 -13
  42. package/themes/business/src/components/shared/OLink.tsx +33 -13
  43. package/themes/business/src/components/shared/OModal.tsx +16 -9
  44. package/themes/business/src/components/shared/OText.tsx +8 -2
  45. package/themes/business/src/types/index.tsx +32 -2
  46. package/themes/business/src/utils/index.tsx +44 -1
  47. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  48. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  49. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  50. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -1
  51. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  52. package/themes/kiosk/src/components/LoginForm/Otp/index.tsx +92 -0
  53. package/themes/kiosk/src/components/LoginForm/Otp/styles.tsx +7 -0
  54. package/themes/kiosk/src/components/LoginForm/index.tsx +480 -156
  55. package/themes/kiosk/src/components/LoginForm/styles.tsx +14 -1
  56. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  57. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  58. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  59. package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +3 -2
  60. package/themes/kiosk/src/components/PhoneInputNumber/styles.tsx +1 -3
  61. package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
  62. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  63. package/themes/kiosk/src/components/shared/OModal.tsx +14 -11
  64. package/themes/kiosk/src/layouts/Container.tsx +7 -1
  65. package/themes/kiosk/src/types/index.d.ts +13 -0
  66. package/themes/kiosk/src/utils/index.tsx +15 -0
  67. package/themes/original/index.tsx +6 -0
  68. package/themes/original/src/components/AddressDetails/index.tsx +29 -11
  69. package/themes/original/src/components/AddressForm/index.tsx +79 -44
  70. package/themes/original/src/components/AddressList/index.tsx +27 -22
  71. package/themes/original/src/components/AddressList/styles.tsx +4 -2
  72. package/themes/original/src/components/AnalyticsSegment/index.tsx +193 -10
  73. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  74. package/themes/original/src/components/AppleLogin/styles.tsx +3 -1
  75. package/themes/original/src/components/BusinessBasicInformation/index.tsx +160 -91
  76. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +9 -7
  77. package/themes/original/src/components/BusinessController/index.tsx +146 -68
  78. package/themes/original/src/components/BusinessController/styles.tsx +22 -2
  79. package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
  80. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
  81. package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
  82. package/themes/original/src/components/BusinessItemAccordion/index.tsx +23 -22
  83. package/themes/original/src/components/BusinessListingSearch/index.tsx +352 -326
  84. package/themes/original/src/components/BusinessPreorder/index.tsx +97 -16
  85. package/themes/original/src/components/BusinessProductsList/index.tsx +23 -14
  86. package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
  87. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +1 -1
  88. package/themes/original/src/components/BusinessProductsListing/index.tsx +669 -513
  89. package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -2
  90. package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
  91. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  92. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +98 -79
  93. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -11
  94. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  95. package/themes/original/src/components/Cart/index.tsx +100 -67
  96. package/themes/original/src/components/CartContent/index.tsx +115 -19
  97. package/themes/original/src/components/CartContent/styles.tsx +17 -7
  98. package/themes/original/src/components/Checkout/index.tsx +366 -173
  99. package/themes/original/src/components/Checkout/styles.tsx +4 -2
  100. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  101. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  102. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  103. package/themes/original/src/components/DriverTips/index.tsx +52 -34
  104. package/themes/original/src/components/FacebookLogin/styles.tsx +3 -1
  105. package/themes/original/src/components/Favorite/index.tsx +8 -9
  106. package/themes/original/src/components/Favorite/styles.tsx +1 -1
  107. package/themes/original/src/components/FavoriteList/index.tsx +51 -80
  108. package/themes/original/src/components/FloatingButton/index.tsx +1 -2
  109. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  110. package/themes/original/src/components/GPSButton/index.tsx +6 -4
  111. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  112. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +96 -0
  113. package/themes/original/src/components/GiftCard/GiftCardUI/styles.tsx +5 -0
  114. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +100 -0
  115. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +8 -0
  116. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +191 -0
  117. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +8 -0
  118. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +165 -0
  119. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +9 -0
  120. package/themes/original/src/components/GoogleLogin/styles.tsx +1 -1
  121. package/themes/original/src/components/GoogleMap/index.tsx +15 -4
  122. package/themes/original/src/components/Help/index.tsx +8 -8
  123. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +10 -31
  124. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +5 -3
  125. package/themes/original/src/components/HelpGuide/index.tsx +6 -6
  126. package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
  127. package/themes/original/src/components/HelpOrder/index.tsx +6 -15
  128. package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
  129. package/themes/original/src/components/Home/index.tsx +13 -4
  130. package/themes/original/src/components/LastOrder/index.tsx +1 -34
  131. package/themes/original/src/components/LoginForm/Otp/index.tsx +55 -13
  132. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  133. package/themes/original/src/components/LoginForm/index.tsx +64 -26
  134. package/themes/original/src/components/LottieAnimation/index.tsx +89 -55
  135. package/themes/original/src/components/MessageListing/index.tsx +16 -42
  136. package/themes/original/src/components/Messages/index.tsx +32 -10
  137. package/themes/original/src/components/MomentOption/index.tsx +195 -88
  138. package/themes/original/src/components/MultiCart/index.tsx +50 -0
  139. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +151 -49
  140. package/themes/original/src/components/MultiCheckout/index.tsx +308 -88
  141. package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
  142. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
  143. package/themes/original/src/components/MultiOrdersDetails/index.tsx +68 -21
  144. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
  145. package/themes/original/src/components/MyOrders/index.tsx +77 -52
  146. package/themes/original/src/components/NavBar/index.tsx +18 -18
  147. package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
  148. package/themes/original/src/components/Notifications/index.tsx +46 -50
  149. package/themes/original/src/components/Notifications/styles.tsx +6 -3
  150. package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
  151. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +15 -3
  152. package/themes/original/src/components/OrderDetails/index.tsx +190 -358
  153. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  154. package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
  155. package/themes/original/src/components/OrderProgress/index.tsx +93 -114
  156. package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
  157. package/themes/original/src/components/OrderSummary/index.tsx +85 -57
  158. package/themes/original/src/components/OrderTypeSelector/index.tsx +1 -1
  159. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +24 -19
  160. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +14 -14
  161. package/themes/original/src/components/OrdersOption/index.tsx +76 -66
  162. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  163. package/themes/original/src/components/PageBanner/index.tsx +171 -0
  164. package/themes/original/src/components/PageBanner/styles.tsx +11 -0
  165. package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
  166. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
  167. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  168. package/themes/original/src/components/PaymentOptions/index.tsx +64 -7
  169. package/themes/original/src/components/PhoneInputNumber/index.tsx +3 -3
  170. package/themes/original/src/components/PlaceSpot/index.tsx +12 -6
  171. package/themes/original/src/components/ProductForm/index.tsx +114 -36
  172. package/themes/original/src/components/ProductForm/styles.tsx +5 -7
  173. package/themes/original/src/components/ProductItemAccordion/index.tsx +17 -14
  174. package/themes/original/src/components/ProductOptionSubOption/index.tsx +24 -14
  175. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +3 -4
  176. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  177. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
  178. package/themes/original/src/components/ProfessionalProfile/index.tsx +36 -7
  179. package/themes/original/src/components/Promotions/index.tsx +234 -220
  180. package/themes/original/src/components/Promotions/styles.tsx +10 -3
  181. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  182. package/themes/original/src/components/ReviewOrder/index.tsx +26 -9
  183. package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
  184. package/themes/original/src/components/ReviewProducts/index.tsx +23 -11
  185. package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
  186. package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
  187. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  188. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  189. package/themes/original/src/components/ServiceForm/index.tsx +66 -17
  190. package/themes/original/src/components/Sessions/index.tsx +11 -8
  191. package/themes/original/src/components/Sessions/styles.tsx +5 -0
  192. package/themes/original/src/components/SignupForm/index.tsx +43 -20
  193. package/themes/original/src/components/SingleOrderCard/index.tsx +130 -52
  194. package/themes/original/src/components/SingleOrderCard/styles.tsx +11 -2
  195. package/themes/original/src/components/SingleProductCard/index.tsx +72 -34
  196. package/themes/original/src/components/SingleProductCard/styles.tsx +22 -4
  197. package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
  198. package/themes/original/src/components/StripeCardsList/index.tsx +13 -3
  199. package/themes/original/src/components/StripeElementsForm/index.tsx +67 -34
  200. package/themes/original/src/components/UpsellingProducts/index.tsx +238 -224
  201. package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
  202. package/themes/original/src/components/UserDetails/index.tsx +8 -4
  203. package/themes/original/src/components/UserFormDetails/index.tsx +76 -7
  204. package/themes/original/src/components/UserFormDetails/styles.tsx +1 -1
  205. package/themes/original/src/components/UserProfile/index.tsx +12 -29
  206. package/themes/original/src/components/UserProfileForm/index.tsx +27 -29
  207. package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
  208. package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
  209. package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
  210. package/themes/original/src/components/Wallets/index.tsx +67 -24
  211. package/themes/original/src/components/Wallets/styles.tsx +3 -4
  212. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  213. package/themes/original/src/components/shared/OButton.tsx +6 -2
  214. package/themes/original/src/components/shared/OInput.tsx +16 -2
  215. package/themes/original/src/components/shared/OModal.tsx +3 -3
  216. package/themes/original/src/layouts/Container.tsx +1 -1
  217. package/themes/original/src/types/index.tsx +40 -11
  218. package/themes/original/src/utils/index.tsx +375 -58
  219. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,16 +1,17 @@
1
- import React, { useState, useEffect } from 'react'
2
1
  import moment from 'moment'
3
- import { View, Modal, StyleSheet, TouchableOpacity, Dimensions } from 'react-native'
2
+ import { NewOrderNotification as NewOrderNotificationController, useApi, useEvent, useLanguage, useSession } from 'ordering-components/native'
3
+ import React, { useEffect, useState } from 'react'
4
+ import { Dimensions, Modal, StyleSheet, TouchableOpacity, View } from 'react-native'
4
5
  import Sound from 'react-native-sound'
5
6
  import Icon from 'react-native-vector-icons/Feather'
6
7
  import { useTheme } from 'styled-components/native'
7
- import { useEvent, useLanguage, useSession, useApi, NewOrderNotification as NewOrderNotificationController } from 'ordering-components/native'
8
8
 
9
- import { OText, OIcon } from '../shared'
10
- import { NotificationContainer } from './styles'
11
9
  import { useLocation } from '../../hooks/useLocation'
10
+ import { OIcon, OText } from '../shared'
11
+ import { NotificationContainer } from './styles'
12
12
 
13
- Sound.setCategory('Playback')
13
+ Sound.setCategory('Playback', true)
14
+ Sound.setMode('Default')
14
15
 
15
16
  const windowWidth = Dimensions.get('screen').width
16
17
 
@@ -44,9 +45,10 @@ const NewOrderNotificationUI = (props: any) => {
44
45
  },
45
46
  }
46
47
 
47
- const notificationSound = new Sound(theme.sounds.notification);
48
+ const notificationSound = new Sound(theme.sounds.notification, '', () => { });
48
49
 
49
50
  let _timeout: any = null
51
+ let times = 0
50
52
 
51
53
  const handleCloseEvents = () => {
52
54
  notificationSound.stop()
@@ -56,15 +58,22 @@ const NewOrderNotificationUI = (props: any) => {
56
58
 
57
59
  const handlePlayNotificationSound = (eventObj: any = null) => {
58
60
  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)
61
+ if (times > 0) {
62
+ if (times === 3) {
63
+ times = 0
64
+ return
65
+ }
66
+ return
67
67
  }
68
+ _timeout = setInterval(() => {
69
+ if (times < SOUND_LOOP) {
70
+ notificationSound.play()
71
+ times++
72
+ } else {
73
+ clearInterval(_timeout)
74
+ return
75
+ }
76
+ }, 2500)
68
77
  }
69
78
 
70
79
  const handleEventNotification = async (evtType: number, value: any) => {
@@ -74,32 +83,37 @@ const NewOrderNotificationUI = (props: any) => {
74
83
  await fetch(`${ordering.root}/users/${user.id}/locations`, {
75
84
  method: 'POST',
76
85
  body: JSON.stringify({
77
- location: JSON.stringify({location: `{lat: ${location.latitude}, lng: ${location.longitude}}`})
86
+ location: JSON.stringify({ location: `{lat: ${location.latitude}, lng: ${location.longitude}}` })
78
87
  }),
79
88
  headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }
80
89
  })
81
- } catch {}
90
+ } catch { }
82
91
  const duration = moment.duration(moment().diff(moment.utc(value?.last_driver_assigned_at)))
83
92
  const assignedSecondsDiff = duration.asSeconds()
84
- if (assignedSecondsDiff < 5 && !isBusinessApp) {
93
+ if (assignedSecondsDiff < 5 && !isBusinessApp && !value?.logistic_status) {
85
94
  handlePlayNotificationSound({ evt: 2, orderId: value?.id })
86
95
  }
87
96
  }
88
97
  if (evtType === 3 || value.author_id === user.id) return
89
- handlePlayNotificationSound({
98
+ setTimeout(() => handlePlayNotificationSound({
90
99
  evt: evtType,
91
- orderId: evtList[evtType].event === 'messages' ? value?.order_id : value?.id
92
- })
100
+ orderId: value?.driver ? value?.order_id : evtList[evtType].event === 'messages' ? value?.order?.id : value?.id
101
+ }), 1000)
93
102
  }
94
103
 
95
104
  useEffect(() => {
96
105
  events.on('message_added_notification', (o: any) => handleEventNotification(1, o))
97
106
  events.on('order_added_notification', (o: any) => handleEventNotification(2, o))
98
107
  events.on('order_updated_notification', (o: any) => handleEventNotification(3, o))
108
+ events.on('request_register_notification', (o: any) => handleEventNotification(2, o))
109
+ events.on('request_update_notification', (o: any) => handleEventNotification(3, o))
110
+
99
111
  return () => {
100
112
  events.off('message_added_notification', (o: any) => handleEventNotification(1, o))
101
113
  events.off('order_added_notification', (o: any) => handleEventNotification(2, o))
102
114
  events.off('order_updated_notification', (o: any) => handleEventNotification(3, o))
115
+ events.off('request_register_notification', (o: any) => handleEventNotification(2, o))
116
+ events.off('request_update_notification', (o: any) => handleEventNotification(3, o))
103
117
  }
104
118
  }, [])
105
119
 
@@ -12,6 +12,8 @@ import {
12
12
  useToast,
13
13
  useSession,
14
14
  ToastType,
15
+ useUtils,
16
+ useConfig
15
17
  } from 'ordering-components/native';
16
18
 
17
19
  //Components
@@ -52,10 +54,15 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
52
54
  handleClickLogisticOrder,
53
55
  forceUpdate,
54
56
  getPermissions,
55
- isGrantedPermissions
57
+ orderAssingId,
58
+ isGrantedPermissions,
56
59
  } = props;
57
60
  const [, { showToast }] = useToast();
61
+ const [{ parsePrice, parseNumber }] = useUtils();
62
+ const [{ configs }] = useConfig();
58
63
  const { order } = props.order
64
+
65
+ const isAllowedDriverRejectOrder = configs?.allow_driver_reject_order?.value === '1'
59
66
  const theme = useTheme();
60
67
  const [, t] = useLanguage();
61
68
  const [session] = useSession();
@@ -75,6 +82,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
75
82
 
76
83
  const validStatusComplete = [9, 19, 23]
77
84
 
85
+ const pendingOrderStatus = [1, 4, 7, 13]
86
+
78
87
  const logisticOrderStatus = [4, 6, 7]
79
88
 
80
89
  const showFloatButtonsPickUp: any = {
@@ -134,6 +143,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
134
143
  };
135
144
 
136
145
  const handleViewActionOrder = (action: string) => {
146
+ if (action === 'reject' && !isAllowedDriverRejectOrder) {
147
+ setAlertState({
148
+ open: true,
149
+ content: [
150
+ t('DRIVER_NOT_ALLOWED_TO_REJECT_ORDER', 'The driver is not allowed to reject an order.'),
151
+ ],
152
+ key: null,
153
+ })
154
+ return
155
+ }
137
156
  if (!isGrantedPermissions) {
138
157
  navigation.navigate('RequestPermissions')
139
158
  return
@@ -150,16 +169,23 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
150
169
  };
151
170
 
152
171
  const handleArrowBack: any = () => {
172
+ if (alertState?.open && !isAllowedDriverRejectOrder && !pendingOrderStatus.includes(order?.status)) {
173
+ setAlertState({
174
+ ...alertState,
175
+ open: false
176
+ })
177
+ return
178
+ }
153
179
  navigation?.canGoBack() && navigation.goBack();
154
180
  };
155
181
 
156
182
  const handleRejectLogisticOrder = () => {
157
- handleClickLogisticOrder?.(2, order?.logistic_order_id)
183
+ handleClickLogisticOrder?.(2, orderAssingId || order?.logistic_order_id)
158
184
  handleArrowBack()
159
185
  }
160
186
 
161
187
  const handleAcceptLogisticOrder = (order: any) => {
162
- handleClickLogisticOrder?.(1, order?.logistic_order_id)
188
+ handleClickLogisticOrder?.(1, orderAssingId || order?.logistic_order_id)
163
189
  if (order?.order_group) {
164
190
  handleArrowBack()
165
191
  }
@@ -343,7 +369,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
343
369
  </View>
344
370
  )}
345
371
 
346
- {(!!props.order?.error || props.order?.error) && (
372
+ {(!!props.order?.error || props.order?.error?.length > 0) && (
347
373
  <NotFoundSource
348
374
  btnTitle={t('GO_TO_MY_ORDERS', 'Go to my orders')}
349
375
  content={
@@ -1,6 +1,6 @@
1
- import React, { useState } from 'react'
1
+ import React, { useState, useCallback } from 'react'
2
2
 
3
- import { Platform, StyleSheet, View } from 'react-native';
3
+ import { Platform, StyleSheet, View, TouchableOpacity, ScrollView } from 'react-native';
4
4
 
5
5
  import { OButton, OText, OLink, OModal } from '../shared'
6
6
  import {
@@ -16,18 +16,23 @@ import {
16
16
 
17
17
  import { ProductItemAccordion } from '../ProductItemAccordion';
18
18
 
19
- import { verifyDecimals } from '../../utils';
19
+ import { verifyDecimals, calculateDistance, transformDistance } from '../../utils';
20
20
 
21
21
  import {
22
22
  useLanguage,
23
23
  useUtils,
24
24
  useConfig,
25
+ useSession
25
26
  } from 'ordering-components/native';
26
27
  import { useTheme } from 'styled-components/native';
27
28
  import { ReviewCustomer } from '../ReviewCustomer'
28
29
 
29
30
  import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons'
30
31
 
32
+ import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
33
+
34
+ const { useDeviceOrientation } = DeviceOrientationMethods
35
+
31
36
  interface OrderContent {
32
37
  order: any,
33
38
  logisticOrderStatus?: Array<number>,
@@ -38,12 +43,20 @@ interface OrderContent {
38
43
  export const OrderContentComponent = (props: OrderContent) => {
39
44
  const [, t] = useLanguage();
40
45
  const theme = useTheme()
41
-
46
+ const [{ user }] = useSession()
42
47
  const { order, logisticOrderStatus, isOrderGroup, lastOrder } = props;
43
48
  const [{ parsePrice, parseNumber }] = useUtils();
44
49
  const [{ configs }] = useConfig();
50
+ const [orientationState] = useDeviceOrientation();
51
+ const distanceUnit = configs?.distance_unit?.value
52
+
53
+ const WIDTH_SCREEN = orientationState?.dimensions?.width
54
+
45
55
  const [openReviewModal, setOpenReviewModal] = useState(false)
46
56
 
57
+ const [isReadMore, setIsReadMore] = useState(false)
58
+ const [lengthMore, setLengthMore] = useState(false)
59
+
47
60
  const pastOrderStatuses = [1, 2, 5, 6, 10, 11, 12, 16, 17]
48
61
 
49
62
  const walletName: any = {
@@ -91,10 +104,18 @@ export const OrderContentComponent = (props: OrderContent) => {
91
104
  return order?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
92
105
  }
93
106
 
107
+ const containsOnlyNumbers = (str: string) => {
108
+ return /^\d+$/.test(str);
109
+ }
110
+
111
+ const onTextLayout = useCallback((e: any) => {
112
+ setLengthMore((e.nativeEvent.lines.length == 2 && e.nativeEvent.lines[1].width > WIDTH_SCREEN * .76) || e.nativeEvent.lines.length > 2); //to check the text is more than 2 lines or not
113
+ }, []);
114
+
94
115
  return (
95
116
  <OrderContent isOrderGroup={isOrderGroup} lastOrder={lastOrder}>
96
117
  {isOrderGroup && (
97
- <OText size={18}>{t('ORDER', 'Order')} #{isOrderGroup ? order?.order_group_id : order?.id}</OText>
118
+ <OText size={18}>{t('ORDER', 'Order')} #{order?.id}</OText>
98
119
  )}
99
120
 
100
121
  {order?.metafields?.length > 0 && (
@@ -148,7 +169,7 @@ export const OrderContentComponent = (props: OrderContent) => {
148
169
  <View style={styles.linkWithIcons}>
149
170
  <OLink
150
171
  PressStyle={styles.linkWithIcons}
151
- url={`tel:${order?.business?.cellphone}`}
172
+ url={`tel:${containsOnlyNumbers(order?.business?.cellphone) ? order?.business?.cellphone : 'invalid'}`}
152
173
  shorcut={`${order?.business?.cellphone}`}
153
174
  TextStyle={styles.textLink}
154
175
  />
@@ -159,7 +180,7 @@ export const OrderContentComponent = (props: OrderContent) => {
159
180
  <View style={styles.linkWithIcons}>
160
181
  <OLink
161
182
  PressStyle={styles.linkWithIcons}
162
- url={`tel:${order?.business?.phone}`}
183
+ url={`tel:${containsOnlyNumbers(order?.business?.cellphone) ? order?.business?.phone : 'invalid'}`}
163
184
  shorcut={order?.business?.phone}
164
185
  TextStyle={styles.textLink}
165
186
  />
@@ -176,12 +197,17 @@ export const OrderContentComponent = (props: OrderContent) => {
176
197
  ios: `maps:0,0?q=${order?.business?.address}`,
177
198
  android: `geo:0,0?q=${order?.business?.address}`,
178
199
  })}
200
+ numberOfLines={2}
179
201
  shorcut={order?.business?.address}
180
202
  TextStyle={styles.textLink}
181
203
  />
182
204
  </View>
183
205
  )}
184
-
206
+ {!!order?.business?.location && order?.customer?.location && (
207
+ <OText>
208
+ {t('DISTANCE_TO_THE_BUSINESS', 'Distance to the business')}: {transformDistance(calculateDistance(order?.business?.location, { latitude: order?.customer?.location?.lat, longitude: order?.customer?.location?.lng }), distanceUnit)} {t(distanceUnit.toUpperCase(), distanceUnit)}
209
+ </OText>
210
+ )}
185
211
  {!!order?.business?.address_notes && (
186
212
  <View style={styles.linkWithIcons}>
187
213
  <OLink
@@ -274,7 +300,7 @@ export const OrderContentComponent = (props: OrderContent) => {
274
300
  <View style={styles.linkWithIcons}>
275
301
  <OLink
276
302
  PressStyle={styles.linkWithIcons}
277
- url={`tel:${!!order?.customer?.country_phone_code ? '+' + order?.customer?.country_phone_code : ''} ${order?.customer?.cellphone}`}
303
+ url={`tel:${!!order?.customer?.country_phone_code ? '+' + order?.customer?.country_phone_code : ''} ${containsOnlyNumbers(order?.customer?.cellphone) ? order?.customer?.cellphone : 'invalid'}`}
278
304
  shorcut={`${!!order?.customer?.country_phone_code ? '+' + order?.customer?.country_phone_code : ''} ${order?.customer?.cellphone}`}
279
305
  TextStyle={styles.textLink}
280
306
  />
@@ -285,7 +311,7 @@ export const OrderContentComponent = (props: OrderContent) => {
285
311
  <View style={styles.linkWithIcons}>
286
312
  <OLink
287
313
  PressStyle={styles.linkWithIcons}
288
- url={`tel:${order?.customer?.phone}`}
314
+ url={`tel:${containsOnlyNumbers(order?.customer?.phone) ? order?.customer?.phone : 'invalid'}`}
289
315
  shorcut={order?.customer?.phone}
290
316
  TextStyle={styles.textLink}
291
317
  />
@@ -293,17 +319,26 @@ export const OrderContentComponent = (props: OrderContent) => {
293
319
  )}
294
320
 
295
321
  {!!order?.customer?.address && (
296
- <View style={styles.linkWithIcons}>
297
- <OLink
298
- PressStyle={styles.linkWithIcons}
299
- url={Platform.select({
300
- ios: `maps:0,0?q=${order?.customer?.address}`,
301
- android: `geo:0,0?q=${order?.customer?.address}`,
302
- })}
303
- shorcut={order?.customer?.address}
304
- TextStyle={styles.textLink}
305
- />
306
- </View>
322
+ <>
323
+ <View style={styles.linkWithIcons}>
324
+ <OLink
325
+ PressStyle={{ ...styles.linkWithIcons, marginBottom: 0 }}
326
+ url={Platform.select({
327
+ ios: `maps:0,0?q=${order?.customer?.address}`,
328
+ android: `geo:0,0?q=${order?.customer?.address}`,
329
+ })}
330
+ onTextLayout={onTextLayout}
331
+ numberOfLines={isReadMore ? 20 : 2}
332
+ shorcut={order?.customer?.address}
333
+ TextStyle={styles.textLink}
334
+ />
335
+ </View>
336
+ {lengthMore && (
337
+ <TouchableOpacity onPress={() => setIsReadMore(!isReadMore)}>
338
+ <OText size={12} color={theme.colors.statusOrderBlue}>{isReadMore ? t('SHOW_LESS', 'Show less') : t('READ_MORE', 'Read more')}</OText>
339
+ </TouchableOpacity>
340
+ )}
341
+ </>
307
342
  )}
308
343
 
309
344
  {!!order?.customer?.internal_number && (
@@ -313,9 +348,15 @@ export const OrderContentComponent = (props: OrderContent) => {
313
348
  )}
314
349
 
315
350
  {!!order?.customer?.address_notes && (
316
- <OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
317
- {order?.customer?.address_notes}
318
- </OText>
351
+ <ScrollView
352
+ showsVerticalScrollIndicator={false}
353
+ showsHorizontalScrollIndicator={false}
354
+ horizontal
355
+ >
356
+ <OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
357
+ {order?.customer?.address_notes}
358
+ </OText>
359
+ </ScrollView>
319
360
  )}
320
361
 
321
362
  {!!order?.customer?.zipcode && (
@@ -333,7 +374,7 @@ export const OrderContentComponent = (props: OrderContent) => {
333
374
  <View style={{ marginTop: 10 }}>
334
375
  {order?.delivery_option !== undefined && order?.delivery_type === 1 && (
335
376
  <OText>
336
- {order?.delivery_option?.name}
377
+ {t(order?.delivery_option?.name?.toUpperCase()?.replace(/ /g, '_'), order?.delivery_option?.name)}
337
378
  </OText>
338
379
  )}
339
380
  {!!order?.comment && (
@@ -378,7 +419,7 @@ export const OrderContentComponent = (props: OrderContent) => {
378
419
  <Table>
379
420
  <OText mBottom={4}>{t('SUBTOTAL', 'Subtotal')}</OText>
380
421
  <OText mBottom={4}>
381
- {parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()), { currency: order?.currency})}
422
+ {parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()), { currency: order?.currency })}
382
423
  </OText>
383
424
  </Table>
384
425
  {(order?.summary?.discount > 0 ?? order?.discount > 0) && order?.offers?.length === 0 && (
@@ -391,7 +432,7 @@ export const OrderContentComponent = (props: OrderContent) => {
391
432
  ) : (
392
433
  <OText mBottom={4}>{t('DISCOUNT', theme?.defaultLanguages?.DISCOUNT || 'Discount')}</OText>
393
434
  )}
394
- <OText>- {parsePrice(order?.summary?.discount ?? order?.discount, { currency: order?.currency})}</OText>
435
+ <OText>- {parsePrice(order?.summary?.discount ?? order?.discount, { currency: order?.currency })}</OText>
395
436
  </Table>
396
437
  )}
397
438
  {
@@ -399,13 +440,13 @@ export const OrderContentComponent = (props: OrderContent) => {
399
440
  <Table key={offer.id}>
400
441
  <OSRow>
401
442
  <OText mBottom={4}>
402
- {offer.name}
443
+ {t(offer.name?.toUpperCase()?.replace(/ /g, '_'), offer.name)}
403
444
  {offer.rate_type === 1 && (
404
445
  <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
405
446
  )}
406
447
  </OText>
407
448
  </OSRow>
408
- <OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency})}</OText>
449
+ <OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency })}</OText>
409
450
  </Table>
410
451
  ))
411
452
  }
@@ -413,9 +454,9 @@ export const OrderContentComponent = (props: OrderContent) => {
413
454
  <Table>
414
455
  <OText mBottom={4}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
415
456
  {order?.tax_type === 1 ? (
416
- <OText mBottom={4}>{parsePrice((order?.summary?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0), { currency: order?.currency})}</OText>
457
+ <OText mBottom={4}>{parsePrice((order?.summary?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0), { currency: order?.currency })}</OText>
417
458
  ) : (
418
- <OText mBottom={4}>{parsePrice(order?.summary?.subtotal_with_discount ?? 0, { currency: order?.currency})}</OText>
459
+ <OText mBottom={4}>{parsePrice(order?.summary?.subtotal_with_discount ?? 0, { currency: order?.currency })}</OText>
419
460
  )}
420
461
  </Table>
421
462
  )}
@@ -425,7 +466,7 @@ export const OrderContentComponent = (props: OrderContent) => {
425
466
  {t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
426
467
  </OText>
427
468
  <OText mBottom={4}>
428
- {parsePrice(order?.summary?.tax ?? 0, { currency: order?.currency})}
469
+ {parsePrice(order?.summary?.tax ?? 0, { currency: order?.currency })}
429
470
  </OText>
430
471
  </Table>
431
472
  )}
@@ -436,7 +477,7 @@ export const OrderContentComponent = (props: OrderContent) => {
436
477
  {t('SERVICE_FEE', 'Service fee')}
437
478
  {`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
438
479
  </OText>
439
- <OText mBottom={4}>{parsePrice(order?.summary?.service_fee ?? 0, { currency: order?.currency})}</OText>
480
+ <OText mBottom={4}>{parsePrice(order?.summary?.service_fee ?? 0, { currency: order?.currency })}</OText>
440
481
  </Table>
441
482
  )
442
483
  }
@@ -445,11 +486,11 @@ export const OrderContentComponent = (props: OrderContent) => {
445
486
  <Table key={tax.id}>
446
487
  <OSRow>
447
488
  <OText mBottom={4}>
448
- {tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
489
+ {t(tax?.name?.toUpperCase()?.replace(/ /g, '_'), tax?.name) || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
449
490
  {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
450
491
  </OText>
451
492
  </OSRow>
452
- <OText mBottom={4}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0, { currency: order?.currency})}</OText>
493
+ <OText mBottom={4}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0, { currency: order?.currency })}</OText>
453
494
  </Table>
454
495
  ))
455
496
  }
@@ -458,11 +499,11 @@ export const OrderContentComponent = (props: OrderContent) => {
458
499
  <Table key={fee.id}>
459
500
  <OSRow>
460
501
  <OText mBottom={4}>
461
- {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
462
- ({fee?.fixed > 0 && `${parsePrice(fee?.fixed, { currency: order?.currency})} + `}{fee.percentage}%){' '}
502
+ {t(fee?.name?.toUpperCase()?.replace(/ /g, '_'), fee?.name) || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
503
+ ({fee?.fixed > 0 && `${parsePrice(fee?.fixed, { currency: order?.currency })} + `}{fee.percentage}%){' '}
463
504
  </OText>
464
505
  </OSRow>
465
- <OText mBottom={4}>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0, { currency: order?.currency})}</OText>
506
+ <OText mBottom={4}>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0, { currency: order?.currency })}</OText>
466
507
  </Table>
467
508
  ))
468
509
  }
@@ -471,25 +512,25 @@ export const OrderContentComponent = (props: OrderContent) => {
471
512
  <Table key={offer.id}>
472
513
  <OSRow>
473
514
  <OText mBottom={4}>
474
- {offer.name}
515
+ {t(offer.name?.toUpperCase()?.replace(/ /g, '_'), offer.name)}
475
516
  {offer.rate_type === 1 && (
476
517
  <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
477
518
  )}
478
519
  </OText>
479
520
  </OSRow>
480
- <OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency})}</OText>
521
+ <OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency })}</OText>
481
522
  </Table>
482
523
  ))
483
524
  }
484
525
  {
485
- order?.summary?.delivery_price > 0 && (
526
+ typeof order?.summary?.delivery_price === 'number' && (
486
527
  <Table>
487
528
  <OText mBottom={4}>
488
529
  {t('DELIVERY_FEE', 'Delivery Fee')}
489
530
  </OText>
490
531
 
491
532
  <OText mBottom={4}>
492
- {parsePrice(order?.summary?.delivery_price, { currency: order?.currency})}
533
+ {parsePrice(order?.summary?.delivery_price, { currency: order?.currency })}
493
534
  </OText>
494
535
  </Table>
495
536
  )
@@ -499,13 +540,13 @@ export const OrderContentComponent = (props: OrderContent) => {
499
540
  <Table key={offer.id}>
500
541
  <OSRow>
501
542
  <OText mBottom={4}>
502
- {offer.name}
543
+ {t(offer.name?.toUpperCase()?.replace(/ /g, '_'), offer.name)}
503
544
  {offer.rate_type === 1 && (
504
545
  <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
505
546
  )}
506
547
  </OText>
507
548
  </OSRow>
508
- <OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency})}</OText>
549
+ <OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency })}</OText>
509
550
  </Table>
510
551
  ))
511
552
  }
@@ -520,7 +561,7 @@ export const OrderContentComponent = (props: OrderContent) => {
520
561
  `(${verifyDecimals(order?.summary?.driver_tip, parseNumber)}%)`
521
562
  )}
522
563
  </OText>
523
- <OText mBottom={4}>{parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip, { currency: order?.currency})}</OText>
564
+ <OText mBottom={4}>{parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip, { currency: order?.currency })}</OText>
524
565
  </Table>
525
566
  )}
526
567
 
@@ -534,7 +575,7 @@ export const OrderContentComponent = (props: OrderContent) => {
534
575
  mBottom={4}
535
576
  style={styles.textBold}
536
577
  color={theme.colors.primary}>
537
- {parsePrice(order?.summary?.total ?? order?.total, { currency: order?.currency})}
578
+ {parsePrice(order?.summary?.total ?? order?.total, { currency: order?.currency })}
538
579
  </OText>
539
580
  </Table>
540
581
  </Total>
@@ -568,16 +609,18 @@ export const OrderContentComponent = (props: OrderContent) => {
568
609
  <OText>
569
610
  {event?.wallet_event
570
611
  ? walletName[event?.wallet_event?.wallet?.type]?.name
571
- : event?.paymethod?.name}
612
+ : t(event?.paymethod?.name?.toUpperCase()?.replace(/ /g, '_'), event?.paymethod?.name)}
572
613
  </OText>
573
- {event?.data?.charge_id && (
614
+ {/* {event?.data?.charge_id && (
574
615
  <OText>
575
616
  {`${t('CODE', 'Code')}: ${event?.data?.charge_id}`}
576
617
  </OText>
577
- )}
618
+ )} */}
578
619
  </View>
579
620
  <OText>
580
- -{parsePrice(event.amount, { currency: order?.currency})}
621
+ {(event?.paymethod?.gateway === 'cash' && order?.cash)
622
+ ? parsePrice(order?.cash, { currency: order?.currency })
623
+ : `-${parsePrice(event?.amount, { currency: order?.currency })}`}
581
624
  </OText>
582
625
  </View>
583
626
  ))}