ordering-ui-react-native 0.16.82 → 0.16.83-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 (218) hide show
  1. package/package.json +5 -5
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/ActiveOrders/styles.tsx +8 -14
  4. package/src/components/BusinessInformation/index.tsx +19 -4
  5. package/src/components/BusinessInformation/styles.tsx +2 -2
  6. package/src/components/BusinessProductsList/index.tsx +10 -10
  7. package/src/components/BusinessesListing/index.tsx +1 -1
  8. package/src/components/LanguageSelector/index.tsx +21 -16
  9. package/src/components/Messages/index.tsx +2 -2
  10. package/src/components/OrderCreating/index.tsx +1 -21
  11. package/src/components/OrdersOption/index.tsx +54 -56
  12. package/src/components/PaymentOptionsWebView/index.tsx +119 -120
  13. package/src/components/SingleProductReview/index.tsx +7 -4
  14. package/src/components/VerifyPhone/styles.tsx +1 -2
  15. package/src/components/shared/OToast.tsx +4 -4
  16. package/src/utils/index.tsx +2 -1
  17. package/themes/business/index.tsx +2 -0
  18. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +260 -238
  19. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
  20. package/themes/business/src/components/BusinessController/index.tsx +2 -2
  21. package/themes/business/src/components/Chat/index.tsx +31 -31
  22. package/themes/business/src/components/DriverMap/index.tsx +22 -9
  23. package/themes/business/src/components/GoogleMap/index.tsx +58 -57
  24. package/themes/business/src/components/LoginForm/Otp/index.tsx +120 -0
  25. package/themes/business/src/components/LoginForm/Otp/styles.tsx +7 -0
  26. package/themes/business/src/components/LoginForm/index.tsx +236 -80
  27. package/themes/business/src/components/LoginForm/styles.tsx +10 -0
  28. package/themes/business/src/components/MapView/index.tsx +19 -8
  29. package/themes/business/src/components/MessagesOption/index.tsx +11 -1
  30. package/themes/business/src/components/NewOrderNotification/index.tsx +31 -41
  31. package/themes/business/src/components/OrderDetails/Delivery.tsx +4 -3
  32. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +97 -50
  33. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +3 -3
  34. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +195 -0
  35. package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
  36. package/themes/business/src/components/OrdersOption/index.tsx +63 -73
  37. package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
  38. package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
  39. package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
  40. package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
  41. package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
  42. package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
  43. package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
  44. package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
  45. package/themes/business/src/components/PreviousMessages/index.tsx +17 -18
  46. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
  47. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
  48. package/themes/business/src/components/PreviousOrders/index.tsx +447 -247
  49. package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
  50. package/themes/business/src/components/ProductItemAccordion/index.tsx +30 -5
  51. package/themes/business/src/components/ReviewCustomer/index.tsx +39 -15
  52. package/themes/business/src/components/shared/ODropDown.tsx +42 -8
  53. package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
  54. package/themes/business/src/components/shared/OLink.tsx +33 -13
  55. package/themes/business/src/components/shared/OModal.tsx +16 -9
  56. package/themes/business/src/components/shared/OText.tsx +8 -2
  57. package/themes/business/src/types/index.tsx +36 -3
  58. package/themes/business/src/utils/index.tsx +53 -0
  59. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  60. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  61. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  62. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -1
  63. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  64. package/themes/kiosk/src/components/LoginForm/Otp/index.tsx +92 -0
  65. package/themes/kiosk/src/components/LoginForm/Otp/styles.tsx +7 -0
  66. package/themes/kiosk/src/components/LoginForm/index.tsx +473 -151
  67. package/themes/kiosk/src/components/LoginForm/styles.tsx +14 -1
  68. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  69. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  70. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  71. package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +1 -0
  72. package/themes/kiosk/src/components/PhoneInputNumber/styles.tsx +1 -3
  73. package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
  74. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  75. package/themes/kiosk/src/components/shared/OModal.tsx +14 -11
  76. package/themes/kiosk/src/layouts/Container.tsx +7 -1
  77. package/themes/kiosk/src/types/index.d.ts +13 -0
  78. package/themes/kiosk/src/utils/index.tsx +15 -0
  79. package/themes/original/index.tsx +8 -0
  80. package/themes/original/src/components/AddressDetails/index.tsx +10 -8
  81. package/themes/original/src/components/AddressForm/index.tsx +155 -139
  82. package/themes/original/src/components/AddressList/index.tsx +18 -18
  83. package/themes/original/src/components/AddressList/styles.tsx +4 -2
  84. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  85. package/themes/original/src/components/BusinessBasicInformation/index.tsx +118 -76
  86. package/themes/original/src/components/BusinessController/index.tsx +101 -70
  87. package/themes/original/src/components/BusinessController/styles.tsx +14 -9
  88. package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
  89. package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -6
  90. package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
  91. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
  92. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
  93. package/themes/original/src/components/BusinessListingSearch/index.tsx +102 -155
  94. package/themes/original/src/components/BusinessListingSearch/styles.tsx +10 -12
  95. package/themes/original/src/components/BusinessProductsList/index.tsx +11 -8
  96. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  97. package/themes/original/src/components/BusinessProductsListing/index.tsx +564 -495
  98. package/themes/original/src/components/BusinessProductsListing/styles.tsx +13 -12
  99. package/themes/original/src/components/BusinessTypeFilter/index.tsx +3 -2
  100. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
  101. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +116 -81
  102. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -9
  103. package/themes/original/src/components/BusinessesListing/index.tsx +6 -6
  104. package/themes/original/src/components/Cart/index.tsx +75 -41
  105. package/themes/original/src/components/CartContent/index.tsx +80 -18
  106. package/themes/original/src/components/CartContent/styles.tsx +11 -1
  107. package/themes/original/src/components/Checkout/index.tsx +91 -96
  108. package/themes/original/src/components/Checkout/styles.tsx +4 -2
  109. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  110. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  111. package/themes/original/src/components/DriverTips/index.tsx +52 -37
  112. package/themes/original/src/components/DriverTips/styles.tsx +2 -1
  113. package/themes/original/src/components/Favorite/index.tsx +7 -4
  114. package/themes/original/src/components/Favorite/styles.tsx +1 -1
  115. package/themes/original/src/components/FavoriteList/index.tsx +70 -80
  116. package/themes/original/src/components/FloatingButton/index.tsx +1 -2
  117. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  118. package/themes/original/src/components/GPSButton/index.tsx +20 -19
  119. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  120. package/themes/original/src/components/GoogleMap/index.tsx +10 -1
  121. package/themes/original/src/components/Help/index.tsx +8 -8
  122. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +14 -20
  123. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +6 -0
  124. package/themes/original/src/components/HelpGuide/index.tsx +13 -12
  125. package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
  126. package/themes/original/src/components/HelpOrder/index.tsx +12 -20
  127. package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
  128. package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
  129. package/themes/original/src/components/LastOrder/index.tsx +1 -34
  130. package/themes/original/src/components/LoginForm/Otp/index.tsx +89 -73
  131. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  132. package/themes/original/src/components/LoginForm/index.tsx +28 -8
  133. package/themes/original/src/components/LottieAnimation/index.tsx +78 -0
  134. package/themes/original/src/components/MessageListing/index.tsx +7 -40
  135. package/themes/original/src/components/Messages/index.tsx +42 -26
  136. package/themes/original/src/components/MomentOption/index.tsx +195 -88
  137. package/themes/original/src/components/MultiCart/index.tsx +50 -0
  138. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +92 -93
  139. package/themes/original/src/components/MultiCheckout/index.tsx +153 -77
  140. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
  141. package/themes/original/src/components/MultiOrdersDetails/index.tsx +85 -34
  142. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
  143. package/themes/original/src/components/MyOrders/index.tsx +66 -17
  144. package/themes/original/src/components/NavBar/index.tsx +7 -6
  145. package/themes/original/src/components/NetworkError/index.tsx +5 -3
  146. package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
  147. package/themes/original/src/components/Notifications/index.tsx +144 -0
  148. package/themes/original/src/components/Notifications/styles.tsx +20 -0
  149. package/themes/original/src/components/OrderDetails/index.tsx +108 -218
  150. package/themes/original/src/components/OrderDetails/styles.tsx +10 -1
  151. package/themes/original/src/components/OrderItAgain/index.tsx +46 -43
  152. package/themes/original/src/components/OrderProgress/index.tsx +81 -105
  153. package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
  154. package/themes/original/src/components/OrderSummary/index.tsx +2 -2
  155. package/themes/original/src/components/OrderTypeSelector/index.tsx +13 -6
  156. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +93 -97
  157. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +3 -0
  158. package/themes/original/src/components/OrdersOption/index.tsx +86 -92
  159. package/themes/original/src/components/PageBanner/index.tsx +146 -0
  160. package/themes/original/src/components/PageBanner/styles.tsx +11 -0
  161. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
  162. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  163. package/themes/original/src/components/PaymentOptions/index.tsx +1 -1
  164. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  165. package/themes/original/src/components/PlaceSpot/index.tsx +16 -6
  166. package/themes/original/src/components/PreviousOrders/index.tsx +3 -2
  167. package/themes/original/src/components/ProductForm/index.tsx +240 -256
  168. package/themes/original/src/components/ProductForm/styles.tsx +5 -8
  169. package/themes/original/src/components/ProductItemAccordion/index.tsx +199 -128
  170. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -10
  171. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +1 -2
  172. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  173. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -49
  174. package/themes/original/src/components/ProfessionalProfile/index.tsx +54 -14
  175. package/themes/original/src/components/Promotions/index.tsx +234 -220
  176. package/themes/original/src/components/Promotions/styles.tsx +7 -2
  177. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  178. package/themes/original/src/components/ReviewOrder/index.tsx +43 -11
  179. package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
  180. package/themes/original/src/components/ReviewProducts/index.tsx +8 -5
  181. package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
  182. package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
  183. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  184. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  185. package/themes/original/src/components/ServiceForm/index.tsx +377 -270
  186. package/themes/original/src/components/Sessions/index.tsx +11 -8
  187. package/themes/original/src/components/Sessions/styles.tsx +5 -0
  188. package/themes/original/src/components/SignupForm/index.tsx +78 -66
  189. package/themes/original/src/components/SingleOrderCard/index.tsx +125 -56
  190. package/themes/original/src/components/SingleOrderCard/styles.tsx +10 -8
  191. package/themes/original/src/components/SingleProductCard/index.tsx +112 -77
  192. package/themes/original/src/components/SingleProductCard/styles.tsx +14 -13
  193. package/themes/original/src/components/SingleProductReview/index.tsx +38 -5
  194. package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
  195. package/themes/original/src/components/StripeCardsList/index.tsx +1 -1
  196. package/themes/original/src/components/StripeElementsForm/index.tsx +4 -1
  197. package/themes/original/src/components/UpsellingProducts/index.tsx +244 -215
  198. package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
  199. package/themes/original/src/components/UserDetails/index.tsx +5 -3
  200. package/themes/original/src/components/UserFormDetails/index.tsx +50 -54
  201. package/themes/original/src/components/UserProfile/index.tsx +58 -35
  202. package/themes/original/src/components/UserProfile/styles.ts +17 -0
  203. package/themes/original/src/components/UserProfileForm/index.tsx +21 -28
  204. package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
  205. package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
  206. package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
  207. package/themes/original/src/components/Wallets/index.tsx +177 -164
  208. package/themes/original/src/components/Wallets/styles.tsx +12 -8
  209. package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
  210. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  211. package/themes/original/src/components/shared/OBottomPopup.tsx +1 -1
  212. package/themes/original/src/components/shared/OButton.tsx +9 -4
  213. package/themes/original/src/components/shared/OIcon.tsx +8 -1
  214. package/themes/original/src/components/shared/OInput.tsx +10 -1
  215. package/themes/original/src/layouts/Container.tsx +13 -9
  216. package/themes/original/src/types/index.tsx +42 -7
  217. package/themes/original/src/utils/index.tsx +322 -58
  218. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -14,6 +14,8 @@ Sound.setCategory('Playback')
14
14
 
15
15
  const windowWidth = Dimensions.get('screen').width
16
16
 
17
+ const SOUND_LOOP = 3
18
+
17
19
  const NewOrderNotificationUI = (props: any) => {
18
20
  const { isBusinessApp } = props
19
21
  const [events] = useEvent()
@@ -22,8 +24,7 @@ const NewOrderNotificationUI = (props: any) => {
22
24
  const [{ user, token }] = useSession()
23
25
  const [ordering] = useApi()
24
26
  const { getCurrentLocation } = useLocation();
25
- const [soundTimeout, setSoundTimeout] = useState<any>(null)
26
- let [currentEvent, setCurrentEvent] = useState<any>(null)
27
+ const [currentEvent, setCurrentEvent] = useState<any>(null)
27
28
 
28
29
  const evtList: any = {
29
30
  1: {
@@ -43,29 +44,27 @@ const NewOrderNotificationUI = (props: any) => {
43
44
  },
44
45
  }
45
46
 
46
- const notificationSound = new Sound(theme.sounds.notification, (e) => { console.log(e) });
47
+ const notificationSound = new Sound(theme.sounds.notification);
47
48
 
48
- const handlePlayNotificationSound = () => {
49
- if (currentEvent) return
50
- let times = 0
51
- const _timeout = setInterval(function () {
52
- notificationSound.play(success => {
53
- if (success) {
54
- times = times + 1
55
- }
56
- })
57
- setSoundTimeout(_timeout)
58
- if (times === 3) {
59
- clearInterval(_timeout)
60
- clearInterval(soundTimeout)
61
- }
62
- }, 2500)
49
+ let _timeout: any = null
50
+
51
+ const handleCloseEvents = () => {
52
+ notificationSound.stop()
53
+ setCurrentEvent(null)
54
+ clearInterval(_timeout)
63
55
  }
64
56
 
65
- const handleCloseModal = () => {
66
- clearInterval(soundTimeout)
67
- currentEvent = null
68
- setCurrentEvent({ evt: null })
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)
67
+ }
69
68
  }
70
69
 
71
70
  const handleEventNotification = async (evtType: number, value: any) => {
@@ -79,26 +78,15 @@ const NewOrderNotificationUI = (props: any) => {
79
78
  }),
80
79
  headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }
81
80
  })
82
- } catch (error) {
83
- console.log(error)
84
- }
81
+ } catch {}
85
82
  const duration = moment.duration(moment().diff(moment.utc(value?.last_driver_assigned_at)))
86
83
  const assignedSecondsDiff = duration.asSeconds()
87
84
  if (assignedSecondsDiff < 5 && !isBusinessApp) {
88
- handlePlayNotificationSound()
89
- clearInterval(soundTimeout)
90
- currentEvent = { evt: 2, orderId: value?.id }
91
- setCurrentEvent({ evt: 2, orderId: value?.id })
85
+ handlePlayNotificationSound({ evt: 2, orderId: value?.id })
92
86
  }
93
87
  }
94
88
  if (evtType === 3 || value.author_id === user.id) return
95
- handlePlayNotificationSound()
96
- clearInterval(soundTimeout)
97
- currentEvent = {
98
- evt: evtType,
99
- orderId: evtList[evtType].event === 'messages' ? value?.order_id : value?.id
100
- }
101
- setCurrentEvent({
89
+ handlePlayNotificationSound({
102
90
  evt: evtType,
103
91
  orderId: evtList[evtType].event === 'messages' ? value?.order_id : value?.id
104
92
  })
@@ -108,18 +96,20 @@ const NewOrderNotificationUI = (props: any) => {
108
96
  events.on('message_added_notification', (o: any) => handleEventNotification(1, o))
109
97
  events.on('order_added_notification', (o: any) => handleEventNotification(2, o))
110
98
  events.on('order_updated_notification', (o: any) => handleEventNotification(3, o))
99
+ events.on('request_register_notification', (o: any) => handleEventNotification(2, o))
100
+ events.on('request_update_notification', (o: any) => handleEventNotification(3, o))
101
+
111
102
  return () => {
112
103
  events.off('message_added_notification', (o: any) => handleEventNotification(1, o))
113
104
  events.off('order_added_notification', (o: any) => handleEventNotification(2, o))
114
105
  events.off('order_updated_notification', (o: any) => handleEventNotification(3, o))
106
+ events.off('request_register_notification', (o: any) => handleEventNotification(2, o))
107
+ events.off('request_update_notification', (o: any) => handleEventNotification(3, o))
115
108
  }
116
109
  }, [])
117
110
 
118
111
  useEffect(() => {
119
- notificationSound.setVolume(1);
120
- return () => {
121
- notificationSound.release();
122
- }
112
+ return () => handleCloseEvents()
123
113
  }, [])
124
114
 
125
115
  return (
@@ -133,7 +123,7 @@ const NewOrderNotificationUI = (props: any) => {
133
123
  <View style={styles.modalView}>
134
124
  <TouchableOpacity
135
125
  style={styles.wrapperIcon}
136
- onPress={() => handleCloseModal()}
126
+ onPress={() => handleCloseEvents()}
137
127
  >
138
128
  <Icon name="x" size={30} />
139
129
  </TouchableOpacity>
@@ -52,7 +52,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
52
52
  handleClickLogisticOrder,
53
53
  forceUpdate,
54
54
  getPermissions,
55
- isGrantedPermissions
55
+ orderAssingId,
56
+ isGrantedPermissions,
56
57
  } = props;
57
58
  const [, { showToast }] = useToast();
58
59
  const { order } = props.order
@@ -154,12 +155,12 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
154
155
  };
155
156
 
156
157
  const handleRejectLogisticOrder = () => {
157
- handleClickLogisticOrder?.(2, order?.logistic_order_id)
158
+ handleClickLogisticOrder?.(2, orderAssingId || order?.logistic_order_id)
158
159
  handleArrowBack()
159
160
  }
160
161
 
161
162
  const handleAcceptLogisticOrder = (order: any) => {
162
- handleClickLogisticOrder?.(1, order?.logistic_order_id)
163
+ handleClickLogisticOrder?.(1, orderAssingId || order?.logistic_order_id)
163
164
  if (order?.order_group) {
164
165
  handleArrowBack()
165
166
  }
@@ -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 && (
207
+ <OText>
208
+ {t('DISTANCE_TO_THE_BUSINESS', 'Distance to the business')}: {transformDistance(calculateDistance(order?.business?.location, user?.location), 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,13 +374,18 @@ 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 && (
340
- <OText style={{ fontStyle: 'italic', opacity: 0.6, marginBottom: 5 }}>
341
- {order?.comment}
342
- </OText>
381
+ <>
382
+ <OText weight='500' style={{ marginBottom: 5 }}>
383
+ {t('ORDER_COMMENT', 'Order Comment')}
384
+ </OText>
385
+ <OText style={{ fontStyle: 'italic', opacity: 0.6, marginBottom: 20 }}>
386
+ {order?.comment}
387
+ </OText>
388
+ </>
343
389
  )}
344
390
  </View>
345
391
  )}
@@ -364,6 +410,7 @@ export const OrderContentComponent = (props: OrderContent) => {
364
410
  <ProductItemAccordion
365
411
  key={product?.id || i}
366
412
  product={product}
413
+ currency={order?.currency}
367
414
  />
368
415
  ))}
369
416
  </OrderProducts>
@@ -372,7 +419,7 @@ export const OrderContentComponent = (props: OrderContent) => {
372
419
  <Table>
373
420
  <OText mBottom={4}>{t('SUBTOTAL', 'Subtotal')}</OText>
374
421
  <OText mBottom={4}>
375
- {parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()), { currency: order?.currency})}
422
+ {parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()), { currency: order?.currency })}
376
423
  </OText>
377
424
  </Table>
378
425
  {(order?.summary?.discount > 0 ?? order?.discount > 0) && order?.offers?.length === 0 && (
@@ -385,7 +432,7 @@ export const OrderContentComponent = (props: OrderContent) => {
385
432
  ) : (
386
433
  <OText mBottom={4}>{t('DISCOUNT', theme?.defaultLanguages?.DISCOUNT || 'Discount')}</OText>
387
434
  )}
388
- <OText>- {parsePrice(order?.summary?.discount ?? order?.discount, { currency: order?.currency})}</OText>
435
+ <OText>- {parsePrice(order?.summary?.discount ?? order?.discount, { currency: order?.currency })}</OText>
389
436
  </Table>
390
437
  )}
391
438
  {
@@ -393,13 +440,13 @@ export const OrderContentComponent = (props: OrderContent) => {
393
440
  <Table key={offer.id}>
394
441
  <OSRow>
395
442
  <OText mBottom={4}>
396
- {offer.name}
443
+ {t(offer.name?.toUpperCase()?.replace(/ /g, '_'), offer.name)}
397
444
  {offer.rate_type === 1 && (
398
445
  <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
399
446
  )}
400
447
  </OText>
401
448
  </OSRow>
402
- <OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency})}</OText>
449
+ <OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency })}</OText>
403
450
  </Table>
404
451
  ))
405
452
  }
@@ -407,9 +454,9 @@ export const OrderContentComponent = (props: OrderContent) => {
407
454
  <Table>
408
455
  <OText mBottom={4}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
409
456
  {order?.tax_type === 1 ? (
410
- <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>
411
458
  ) : (
412
- <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>
413
460
  )}
414
461
  </Table>
415
462
  )}
@@ -419,7 +466,7 @@ export const OrderContentComponent = (props: OrderContent) => {
419
466
  {t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
420
467
  </OText>
421
468
  <OText mBottom={4}>
422
- {parsePrice(order?.summary?.tax ?? 0, { currency: order?.currency})}
469
+ {parsePrice(order?.summary?.tax ?? 0, { currency: order?.currency })}
423
470
  </OText>
424
471
  </Table>
425
472
  )}
@@ -430,7 +477,7 @@ export const OrderContentComponent = (props: OrderContent) => {
430
477
  {t('SERVICE_FEE', 'Service fee')}
431
478
  {`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
432
479
  </OText>
433
- <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>
434
481
  </Table>
435
482
  )
436
483
  }
@@ -439,11 +486,11 @@ export const OrderContentComponent = (props: OrderContent) => {
439
486
  <Table key={tax.id}>
440
487
  <OSRow>
441
488
  <OText mBottom={4}>
442
- {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')}
443
490
  {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
444
491
  </OText>
445
492
  </OSRow>
446
- <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>
447
494
  </Table>
448
495
  ))
449
496
  }
@@ -452,11 +499,11 @@ export const OrderContentComponent = (props: OrderContent) => {
452
499
  <Table key={fee.id}>
453
500
  <OSRow>
454
501
  <OText mBottom={4}>
455
- {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
456
- ({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}%){' '}
457
504
  </OText>
458
505
  </OSRow>
459
- <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>
460
507
  </Table>
461
508
  ))
462
509
  }
@@ -465,13 +512,13 @@ export const OrderContentComponent = (props: OrderContent) => {
465
512
  <Table key={offer.id}>
466
513
  <OSRow>
467
514
  <OText mBottom={4}>
468
- {offer.name}
515
+ {t(offer.name?.toUpperCase()?.replace(/ /g, '_'), offer.name)}
469
516
  {offer.rate_type === 1 && (
470
517
  <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
471
518
  )}
472
519
  </OText>
473
520
  </OSRow>
474
- <OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency})}</OText>
521
+ <OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency })}</OText>
475
522
  </Table>
476
523
  ))
477
524
  }
@@ -483,7 +530,7 @@ export const OrderContentComponent = (props: OrderContent) => {
483
530
  </OText>
484
531
 
485
532
  <OText mBottom={4}>
486
- {parsePrice(order?.summary?.delivery_price, { currency: order?.currency})}
533
+ {parsePrice(order?.summary?.delivery_price, { currency: order?.currency })}
487
534
  </OText>
488
535
  </Table>
489
536
  )
@@ -493,13 +540,13 @@ export const OrderContentComponent = (props: OrderContent) => {
493
540
  <Table key={offer.id}>
494
541
  <OSRow>
495
542
  <OText mBottom={4}>
496
- {offer.name}
543
+ {t(offer.name?.toUpperCase()?.replace(/ /g, '_'), offer.name)}
497
544
  {offer.rate_type === 1 && (
498
545
  <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
499
546
  )}
500
547
  </OText>
501
548
  </OSRow>
502
- <OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency})}</OText>
549
+ <OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency })}</OText>
503
550
  </Table>
504
551
  ))
505
552
  }
@@ -514,7 +561,7 @@ export const OrderContentComponent = (props: OrderContent) => {
514
561
  `(${verifyDecimals(order?.summary?.driver_tip, parseNumber)}%)`
515
562
  )}
516
563
  </OText>
517
- <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>
518
565
  </Table>
519
566
  )}
520
567
 
@@ -528,7 +575,7 @@ export const OrderContentComponent = (props: OrderContent) => {
528
575
  mBottom={4}
529
576
  style={styles.textBold}
530
577
  color={theme.colors.primary}>
531
- {parsePrice(order?.summary?.total ?? order?.total, { currency: order?.currency})}
578
+ {parsePrice(order?.summary?.total ?? order?.total, { currency: order?.currency })}
532
579
  </OText>
533
580
  </Table>
534
581
  </Total>
@@ -562,7 +609,7 @@ export const OrderContentComponent = (props: OrderContent) => {
562
609
  <OText>
563
610
  {event?.wallet_event
564
611
  ? walletName[event?.wallet_event?.wallet?.type]?.name
565
- : event?.paymethod?.name}
612
+ : t(event?.paymethod?.name?.toUpperCase()?.replace(/ /g, '_'), event?.paymethod?.name)}
566
613
  </OText>
567
614
  {event?.data?.charge_id && (
568
615
  <OText>
@@ -571,7 +618,7 @@ export const OrderContentComponent = (props: OrderContent) => {
571
618
  )}
572
619
  </View>
573
620
  <OText>
574
- -{parsePrice(event.amount, { currency: order?.currency})}
621
+ -{parsePrice(event.amount, { currency: order?.currency })}
575
622
  </OText>
576
623
  </View>
577
624
  ))}
@@ -271,7 +271,7 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
271
271
  {order?.delivery_option && (
272
272
  <OText size={13}>
273
273
  <OText size={13} weight='bold'>{`${t('DELIVERY_PREFERENCE', 'Delivery Preference')}: `}</OText>
274
- {order?.delivery_option?.name}
274
+ {t(order?.delivery_option?.name?.toUpperCase()?.replace(/ /g, '_'), order?.delivery_option?.name)}
275
275
  </OText>
276
276
  )}
277
277
  {order?.payment_events?.length > 0 && (
@@ -286,8 +286,8 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
286
286
  ? `${walletName[event?.wallet_event?.wallet?.type]?.name} - `
287
287
  : walletName[event?.wallet_event?.wallet?.type]?.name
288
288
  : idx < order?.payment_events?.length - 1
289
- ? `${event?.paymethod?.name} - `
290
- : event?.paymethod?.name
289
+ ? `${t(event?.paymethod?.name?.toUpperCase()?.replace(/ /g, '_'), event?.paymethod?.name)} - `
290
+ : t(event?.paymethod?.name?.toUpperCase()?.replace(/ /g, '_'), event?.paymethod?.name)
291
291
  })}
292
292
  </OText>
293
293
  </View>