ordering-ui-react-native 0.17.67 → 0.17.68-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 (202) hide show
  1. package/package.json +8 -7
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessInformation/index.tsx +10 -9
  4. package/src/components/BusinessesListing/index.tsx +1 -1
  5. package/src/components/OrderCreating/index.tsx +1 -21
  6. package/src/components/PaymentOptionsWebView/index.tsx +29 -8
  7. package/src/components/PhoneInputNumber/index.tsx +6 -2
  8. package/src/components/StripeMethodForm/index.tsx +136 -102
  9. package/src/components/VerifyPhone/styles.tsx +1 -2
  10. package/src/components/shared/OToast.tsx +2 -1
  11. package/src/types/index.tsx +5 -0
  12. package/src/utils/index.tsx +5 -0
  13. package/themes/business/index.tsx +2 -0
  14. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +270 -245
  15. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
  16. package/themes/business/src/components/BusinessController/index.tsx +0 -1
  17. package/themes/business/src/components/Chat/index.tsx +123 -111
  18. package/themes/business/src/components/DriverMap/index.tsx +17 -6
  19. package/themes/business/src/components/DriverSchedule/index.tsx +45 -8
  20. package/themes/business/src/components/GoogleMap/index.tsx +58 -57
  21. package/themes/business/src/components/LoginForm/Otp/index.tsx +31 -3
  22. package/themes/business/src/components/LoginForm/index.tsx +15 -22
  23. package/themes/business/src/components/MapView/index.tsx +10 -10
  24. package/themes/business/src/components/NewOrderNotification/index.tsx +35 -21
  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 +191 -6
  28. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +111 -43
  29. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +61 -60
  30. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +195 -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/OrdersOption/index.tsx +32 -75
  35. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +249 -0
  36. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
  37. package/themes/business/src/components/PreviousOrders/index.tsx +444 -242
  38. package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
  39. package/themes/business/src/components/ProductItemAccordion/index.tsx +27 -3
  40. package/themes/business/src/components/ReviewCustomer/index.tsx +30 -15
  41. package/themes/business/src/components/StoresList/index.tsx +3 -4
  42. package/themes/business/src/components/UserProfileForm/index.tsx +11 -13
  43. package/themes/business/src/components/shared/OLink.tsx +33 -13
  44. package/themes/business/src/components/shared/OModal.tsx +16 -9
  45. package/themes/business/src/components/shared/OText.tsx +8 -2
  46. package/themes/business/src/types/index.tsx +28 -12
  47. package/themes/business/src/utils/index.tsx +29 -2
  48. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  49. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  50. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  51. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  52. package/themes/kiosk/src/components/Intro/index.tsx +16 -1
  53. package/themes/kiosk/src/components/LoginForm/index.tsx +7 -9
  54. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  55. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  56. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  57. package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +2 -2
  58. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  59. package/themes/original/index.tsx +2 -0
  60. package/themes/original/src/components/AddressDetails/index.tsx +19 -3
  61. package/themes/original/src/components/AddressForm/index.tsx +61 -39
  62. package/themes/original/src/components/AddressList/index.tsx +27 -22
  63. package/themes/original/src/components/AddressList/styles.tsx +4 -2
  64. package/themes/original/src/components/AnalyticsSegment/index.tsx +193 -10
  65. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  66. package/themes/original/src/components/AppleLogin/styles.tsx +3 -1
  67. package/themes/original/src/components/BusinessBasicInformation/index.tsx +153 -96
  68. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +10 -12
  69. package/themes/original/src/components/BusinessController/index.tsx +80 -66
  70. package/themes/original/src/components/BusinessController/styles.tsx +12 -5
  71. package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
  72. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
  73. package/themes/original/src/components/BusinessInformation/index.tsx +139 -85
  74. package/themes/original/src/components/BusinessItemAccordion/index.tsx +15 -20
  75. package/themes/original/src/components/BusinessListingSearch/index.tsx +349 -339
  76. package/themes/original/src/components/BusinessListingSearch/styles.tsx +0 -18
  77. package/themes/original/src/components/BusinessPreorder/index.tsx +103 -19
  78. package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -2
  79. package/themes/original/src/components/BusinessProductsList/index.tsx +15 -7
  80. package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
  81. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +1 -1
  82. package/themes/original/src/components/BusinessProductsListing/index.tsx +684 -556
  83. package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -2
  84. package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
  85. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  86. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +69 -38
  87. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +0 -1
  88. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  89. package/themes/original/src/components/Cart/index.tsx +77 -79
  90. package/themes/original/src/components/CartContent/index.tsx +117 -20
  91. package/themes/original/src/components/CartContent/styles.tsx +17 -7
  92. package/themes/original/src/components/Checkout/index.tsx +356 -124
  93. package/themes/original/src/components/CitiesControl/index.tsx +1 -1
  94. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  95. package/themes/original/src/components/DriverTips/index.tsx +52 -34
  96. package/themes/original/src/components/FacebookLogin/styles.tsx +3 -1
  97. package/themes/original/src/components/Favorite/index.tsx +8 -9
  98. package/themes/original/src/components/Favorite/styles.tsx +1 -1
  99. package/themes/original/src/components/FavoriteList/index.tsx +1 -35
  100. package/themes/original/src/components/FloatingButton/index.tsx +11 -14
  101. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  102. package/themes/original/src/components/GPSButton/index.tsx +6 -4
  103. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +96 -0
  104. package/themes/original/src/components/GiftCard/GiftCardUI/styles.tsx +5 -0
  105. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +100 -0
  106. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +8 -0
  107. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +191 -0
  108. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +8 -0
  109. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +165 -0
  110. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +9 -0
  111. package/themes/original/src/components/GoogleLogin/styles.tsx +1 -1
  112. package/themes/original/src/components/GoogleMap/index.tsx +60 -5
  113. package/themes/original/src/components/Help/index.tsx +8 -8
  114. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +10 -31
  115. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +5 -3
  116. package/themes/original/src/components/HelpGuide/index.tsx +6 -6
  117. package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
  118. package/themes/original/src/components/HelpOrder/index.tsx +6 -15
  119. package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
  120. package/themes/original/src/components/Home/index.tsx +13 -4
  121. package/themes/original/src/components/LastOrder/index.tsx +1 -34
  122. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -31
  123. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  124. package/themes/original/src/components/LoginForm/index.tsx +64 -34
  125. package/themes/original/src/components/LottieAnimation/index.tsx +89 -55
  126. package/themes/original/src/components/MessageListing/index.tsx +16 -42
  127. package/themes/original/src/components/Messages/index.tsx +14 -7
  128. package/themes/original/src/components/MomentOption/index.tsx +195 -90
  129. package/themes/original/src/components/MomentSelector/index.tsx +1 -1
  130. package/themes/original/src/components/MultiCart/index.tsx +41 -54
  131. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +162 -50
  132. package/themes/original/src/components/MultiCheckout/index.tsx +329 -100
  133. package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
  134. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
  135. package/themes/original/src/components/MultiOrdersDetails/index.tsx +54 -21
  136. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
  137. package/themes/original/src/components/MyOrders/index.tsx +40 -29
  138. package/themes/original/src/components/NavBar/index.tsx +20 -17
  139. package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
  140. package/themes/original/src/components/Notifications/index.tsx +46 -50
  141. package/themes/original/src/components/Notifications/styles.tsx +6 -3
  142. package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
  143. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +21 -5
  144. package/themes/original/src/components/OrderDetails/index.tsx +191 -363
  145. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  146. package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
  147. package/themes/original/src/components/OrderProgress/index.tsx +30 -56
  148. package/themes/original/src/components/OrderSummary/index.tsx +88 -59
  149. package/themes/original/src/components/OrderTypeSelector/index.tsx +2 -1
  150. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +14 -14
  151. package/themes/original/src/components/OrdersOption/index.tsx +68 -87
  152. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  153. package/themes/original/src/components/PageBanner/index.tsx +98 -38
  154. package/themes/original/src/components/PageBanner/styles.tsx +0 -10
  155. package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
  156. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
  157. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  158. package/themes/original/src/components/PaymentOptions/index.tsx +78 -35
  159. package/themes/original/src/components/PhoneInputNumber/index.tsx +3 -3
  160. package/themes/original/src/components/ProductForm/index.tsx +105 -30
  161. package/themes/original/src/components/ProductForm/styles.tsx +5 -5
  162. package/themes/original/src/components/ProductItemAccordion/index.tsx +14 -11
  163. package/themes/original/src/components/ProductOptionSubOption/index.tsx +20 -18
  164. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +5 -9
  165. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  166. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
  167. package/themes/original/src/components/ProfessionalProfile/index.tsx +36 -7
  168. package/themes/original/src/components/Promotions/index.tsx +5 -4
  169. package/themes/original/src/components/Promotions/styles.tsx +3 -1
  170. package/themes/original/src/components/ReviewProducts/index.tsx +16 -7
  171. package/themes/original/src/components/ScheduleAccordion/index.tsx +3 -3
  172. package/themes/original/src/components/ServiceForm/index.tsx +66 -17
  173. package/themes/original/src/components/Sessions/index.tsx +11 -8
  174. package/themes/original/src/components/Sessions/styles.tsx +5 -0
  175. package/themes/original/src/components/SignupForm/index.tsx +43 -27
  176. package/themes/original/src/components/SingleOrderCard/index.tsx +101 -62
  177. package/themes/original/src/components/SingleOrderCard/styles.tsx +1 -1
  178. package/themes/original/src/components/SingleProductCard/index.tsx +72 -31
  179. package/themes/original/src/components/SingleProductCard/styles.tsx +20 -4
  180. package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
  181. package/themes/original/src/components/StripeCardsList/index.tsx +49 -5
  182. package/themes/original/src/components/StripeElementsForm/index.tsx +48 -34
  183. package/themes/original/src/components/StripeElementsForm/naked.tsx +12 -1
  184. package/themes/original/src/components/UpsellingProducts/index.tsx +238 -224
  185. package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
  186. package/themes/original/src/components/UserDetails/index.tsx +3 -1
  187. package/themes/original/src/components/UserFormDetails/index.tsx +76 -7
  188. package/themes/original/src/components/UserFormDetails/styles.tsx +1 -1
  189. package/themes/original/src/components/UserProfile/index.tsx +88 -79
  190. package/themes/original/src/components/UserProfileForm/index.tsx +27 -29
  191. package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
  192. package/themes/original/src/components/UserVerification/index.tsx +52 -49
  193. package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
  194. package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
  195. package/themes/original/src/components/Wallets/index.tsx +66 -30
  196. package/themes/original/src/components/Wallets/styles.tsx +3 -4
  197. package/themes/original/src/components/shared/OButton.tsx +6 -2
  198. package/themes/original/src/components/shared/OInput.tsx +6 -1
  199. package/themes/original/src/components/shared/OModal.tsx +3 -3
  200. package/themes/original/src/types/index.tsx +41 -11
  201. package/themes/original/src/utils/index.tsx +273 -1
  202. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -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,26 @@ 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({
58
+ customerAddress: false,
59
+ businessAddressNotes: false
60
+ })
61
+ const [lengthMore, setLengthMore] = useState({
62
+ customerAddress: false,
63
+ businessAddressNotes: false
64
+ })
65
+
47
66
  const pastOrderStatuses = [1, 2, 5, 6, 10, 11, 12, 16, 17]
48
67
 
49
68
  const walletName: any = {
@@ -91,10 +110,25 @@ export const OrderContentComponent = (props: OrderContent) => {
91
110
  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
111
  }
93
112
 
113
+ const containsOnlyNumbers = (str: string) => {
114
+ return /^\d+$/.test(str);
115
+ }
116
+
117
+ const onTextLayout = useCallback((e: any, item: string) => {
118
+ if (item === 'customerAddress') {
119
+ const customerAddressMore = (e.nativeEvent.lines.length == 2 && e.nativeEvent.lines[1].width > WIDTH_SCREEN * .76) || e.nativeEvent.lines.length > 2
120
+ setLengthMore(prev => ({ ...prev, customerAddress: customerAddressMore }))
121
+ }
122
+ if (item === 'businessAddressNotes') {
123
+ const businessAddressNotesMore = (e.nativeEvent.lines.length == 3 && e.nativeEvent.lines[2].width > WIDTH_SCREEN * .76) || e.nativeEvent.lines.length > 3
124
+ setLengthMore(prev => ({ ...prev, businessAddressNotes: businessAddressNotesMore }))
125
+ }
126
+ }, []);
127
+
94
128
  return (
95
129
  <OrderContent isOrderGroup={isOrderGroup} lastOrder={lastOrder}>
96
130
  {isOrderGroup && (
97
- <OText size={18}>{t('ORDER', 'Order')} #{isOrderGroup ? order?.order_group_id : order?.id}</OText>
131
+ <OText size={18}>{t('ORDER', 'Order')} #{order?.id}</OText>
98
132
  )}
99
133
 
100
134
  {order?.metafields?.length > 0 && (
@@ -148,7 +182,7 @@ export const OrderContentComponent = (props: OrderContent) => {
148
182
  <View style={styles.linkWithIcons}>
149
183
  <OLink
150
184
  PressStyle={styles.linkWithIcons}
151
- url={`tel:${order?.business?.cellphone}`}
185
+ url={`tel:${containsOnlyNumbers(order?.business?.cellphone) ? order?.business?.cellphone : 'invalid'}`}
152
186
  shorcut={`${order?.business?.cellphone}`}
153
187
  TextStyle={styles.textLink}
154
188
  />
@@ -159,7 +193,7 @@ export const OrderContentComponent = (props: OrderContent) => {
159
193
  <View style={styles.linkWithIcons}>
160
194
  <OLink
161
195
  PressStyle={styles.linkWithIcons}
162
- url={`tel:${order?.business?.phone}`}
196
+ url={`tel:${containsOnlyNumbers(order?.business?.cellphone) ? order?.business?.phone : 'invalid'}`}
163
197
  shorcut={order?.business?.phone}
164
198
  TextStyle={styles.textLink}
165
199
  />
@@ -176,24 +210,40 @@ export const OrderContentComponent = (props: OrderContent) => {
176
210
  ios: `maps:0,0?q=${order?.business?.address}`,
177
211
  android: `geo:0,0?q=${order?.business?.address}`,
178
212
  })}
213
+ numberOfLines={2}
179
214
  shorcut={order?.business?.address}
180
215
  TextStyle={styles.textLink}
181
216
  />
182
217
  </View>
183
218
  )}
184
-
219
+ {!!order?.business?.location && order?.customer?.location && (
220
+ <OText>
221
+ {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)}
222
+ </OText>
223
+ )}
185
224
  {!!order?.business?.address_notes && (
186
- <View style={styles.linkWithIcons}>
187
- <OLink
188
- PressStyle={styles.linkWithIcons}
189
- url={Platform.select({
190
- ios: `maps:0,0?q=${order?.business?.address_notes}`,
191
- android: `geo:0,0?q=${order?.business?.address_notes}`,
192
- })}
193
- shorcut={order?.business?.address_notes}
194
- TextStyle={styles.textLink}
195
- />
196
- </View>
225
+ <>
226
+ <View style={styles.linkWithIcons}>
227
+ <OLink
228
+ PressStyle={styles.linkWithIcons}
229
+ url={Platform.select({
230
+ ios: `maps:0,0?q=${order?.business?.address_notes}`,
231
+ android: `geo:0,0?q=${order?.business?.address_notes}`,
232
+ })}
233
+ shorcut={order?.business?.address_notes}
234
+ TextStyle={styles.textLink}
235
+ onTextLayout={e => onTextLayout(e, 'businessAddressNotes')}
236
+ numberOfLines={isReadMore.businessAddressNotes ? 20 : 3}
237
+ />
238
+ </View>
239
+ {lengthMore.businessAddressNotes && (
240
+ <TouchableOpacity
241
+ onPress={() => setIsReadMore({ ...isReadMore, businessAddressNotes: !isReadMore.businessAddressNotes })}
242
+ >
243
+ <OText size={12} color={theme.colors.statusOrderBlue}>{isReadMore.businessAddressNotes ? t('SHOW_LESS', 'Show less') : t('READ_MORE', 'Read more')}</OText>
244
+ </TouchableOpacity>
245
+ )}
246
+ </>
197
247
  )}
198
248
  </OrderBusiness>
199
249
 
@@ -274,7 +324,7 @@ export const OrderContentComponent = (props: OrderContent) => {
274
324
  <View style={styles.linkWithIcons}>
275
325
  <OLink
276
326
  PressStyle={styles.linkWithIcons}
277
- url={`tel:${!!order?.customer?.country_phone_code ? '+' + order?.customer?.country_phone_code : ''} ${order?.customer?.cellphone}`}
327
+ url={`tel:${!!order?.customer?.country_phone_code ? '+' + order?.customer?.country_phone_code : ''} ${containsOnlyNumbers(order?.customer?.cellphone) ? order?.customer?.cellphone : 'invalid'}`}
278
328
  shorcut={`${!!order?.customer?.country_phone_code ? '+' + order?.customer?.country_phone_code : ''} ${order?.customer?.cellphone}`}
279
329
  TextStyle={styles.textLink}
280
330
  />
@@ -285,7 +335,7 @@ export const OrderContentComponent = (props: OrderContent) => {
285
335
  <View style={styles.linkWithIcons}>
286
336
  <OLink
287
337
  PressStyle={styles.linkWithIcons}
288
- url={`tel:${order?.customer?.phone}`}
338
+ url={`tel:${containsOnlyNumbers(order?.customer?.phone) ? order?.customer?.phone : 'invalid'}`}
289
339
  shorcut={order?.customer?.phone}
290
340
  TextStyle={styles.textLink}
291
341
  />
@@ -293,17 +343,28 @@ export const OrderContentComponent = (props: OrderContent) => {
293
343
  )}
294
344
 
295
345
  {!!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>
346
+ <>
347
+ <View style={styles.linkWithIcons}>
348
+ <OLink
349
+ PressStyle={{ ...styles.linkWithIcons, marginBottom: 0 }}
350
+ url={Platform.select({
351
+ ios: `maps:0,0?q=${order?.customer?.address}`,
352
+ android: `geo:0,0?q=${order?.customer?.address}`,
353
+ })}
354
+ onTextLayout={e => onTextLayout(e, 'customerAddress')}
355
+ numberOfLines={isReadMore.customerAddress ? 20 : 2}
356
+ shorcut={order?.customer?.address}
357
+ TextStyle={styles.textLink}
358
+ />
359
+ </View>
360
+ {lengthMore.customerAddress && (
361
+ <TouchableOpacity
362
+ onPress={() => setIsReadMore({ ...isReadMore, customerAddress: !isReadMore.customerAddress })}
363
+ >
364
+ <OText size={12} color={theme.colors.statusOrderBlue}>{isReadMore.customerAddress ? t('SHOW_LESS', 'Show less') : t('READ_MORE', 'Read more')}</OText>
365
+ </TouchableOpacity>
366
+ )}
367
+ </>
307
368
  )}
308
369
 
309
370
  {!!order?.customer?.internal_number && (
@@ -313,9 +374,15 @@ export const OrderContentComponent = (props: OrderContent) => {
313
374
  )}
314
375
 
315
376
  {!!order?.customer?.address_notes && (
316
- <OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
317
- {order?.customer?.address_notes}
318
- </OText>
377
+ <ScrollView
378
+ showsVerticalScrollIndicator={false}
379
+ showsHorizontalScrollIndicator={false}
380
+ horizontal
381
+ >
382
+ <OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
383
+ {order?.customer?.address_notes}
384
+ </OText>
385
+ </ScrollView>
319
386
  )}
320
387
 
321
388
  {!!order?.customer?.zipcode && (
@@ -482,7 +549,7 @@ export const OrderContentComponent = (props: OrderContent) => {
482
549
  ))
483
550
  }
484
551
  {
485
- order?.summary?.delivery_price > 0 && (
552
+ typeof order?.summary?.delivery_price === 'number' && (
486
553
  <Table>
487
554
  <OText mBottom={4}>
488
555
  {t('DELIVERY_FEE', 'Delivery Fee')}
@@ -509,15 +576,14 @@ export const OrderContentComponent = (props: OrderContent) => {
509
576
  </Table>
510
577
  ))
511
578
  }
512
- {order?.summary?.driver_tip > 0 && (
579
+ {(order?.summary?.driver_tip > 0 || order?.driver_tip > 0) && (
513
580
  <Table>
514
581
  <OText mBottom={4}>
515
582
  {t('DRIVER_TIP', 'Driver tip')}
516
- {order?.summary?.driver_tip > 0 &&
517
- parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
583
+ {order?.driver_tip > 0 && parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
518
584
  !parseInt(configs?.driver_tip_use_custom?.value, 10) &&
519
585
  (
520
- `(${verifyDecimals(order?.summary?.driver_tip, parseNumber)}%)`
586
+ `(${verifyDecimals(order?.driver_tip, parseNumber)}%)`
521
587
  )}
522
588
  </OText>
523
589
  <OText mBottom={4}>{parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip, { currency: order?.currency })}</OText>
@@ -570,14 +636,16 @@ export const OrderContentComponent = (props: OrderContent) => {
570
636
  ? walletName[event?.wallet_event?.wallet?.type]?.name
571
637
  : t(event?.paymethod?.name?.toUpperCase()?.replace(/ /g, '_'), event?.paymethod?.name)}
572
638
  </OText>
573
- {event?.data?.charge_id && (
639
+ {/* {event?.data?.charge_id && (
574
640
  <OText>
575
641
  {`${t('CODE', 'Code')}: ${event?.data?.charge_id}`}
576
642
  </OText>
577
- )}
643
+ )} */}
578
644
  </View>
579
645
  <OText>
580
- -{parsePrice(event.amount, { currency: order?.currency })}
646
+ {(event?.paymethod?.gateway === 'cash' && order?.cash)
647
+ ? parsePrice(order?.cash, { currency: order?.currency })
648
+ : `-${parsePrice(event?.amount, { currency: order?.currency })}`}
581
649
  </OText>
582
650
  </View>
583
651
  ))}
@@ -9,12 +9,15 @@ import {
9
9
 
10
10
  //Components
11
11
  import {
12
+ OIcon,
12
13
  OIconButton,
13
14
  OText,
14
15
  } from '../shared'
15
16
 
16
17
  import { useTheme } from 'styled-components/native';
17
- import { StyleSheet, View } from 'react-native';
18
+ import { StyleSheet, TouchableOpacity, View } from 'react-native';
19
+ import SimpleLineIcons from 'react-native-vector-icons/SimpleLineIcons'
20
+ import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'
18
21
 
19
22
  import {
20
23
  useLanguage,
@@ -54,6 +57,19 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
54
57
  height: 40,
55
58
  padding: 10,
56
59
  alignItems: 'flex-end',
60
+ color: theme.colors.textGray,
61
+ },
62
+ btnBackArrow: {
63
+ borderWidth: 0,
64
+ width: 32,
65
+ height: 32,
66
+ tintColor: theme.colors.textGray,
67
+ backgroundColor: theme.colors.clear,
68
+ borderColor: theme.colors.clear,
69
+ shadowColor: theme.colors.clear,
70
+ paddingLeft: 0,
71
+ paddingRight: 0,
72
+ marginTop: 10
57
73
  },
58
74
  })
59
75
 
@@ -108,42 +124,32 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
108
124
  <>
109
125
  {!props.isCustomView && (
110
126
  <Header>
111
- <OIconButton
112
- icon={theme.images.general.arrow_left}
113
- iconStyle={{ width: 20, height: 20 }}
114
- borderColor={theme.colors.clear}
115
- style={{ ...styles.icons, justifyContent: 'flex-end' }}
116
- onClick={() => handleArrowBack()}
117
- />
118
-
127
+ <TouchableOpacity onPress={() => handleArrowBack()} style={styles.btnBackArrow}>
128
+ <OIcon src={theme.images.general.arrow_left} color={theme.colors.textGray} />
129
+ </TouchableOpacity>
119
130
  {(!order?.isLogistic || (!logisticOrderStatus?.includes(order?.status) && !order?.order_group)) && (
120
131
  <Actions>
121
132
  {getOrderStatus(order?.status, t)?.value !==
122
133
  t('PENDING', 'Pending') && (
123
134
  <>
124
- <OIconButton
125
- icon={theme.images.general.copy}
126
- iconStyle={{
127
- width: 20,
128
- height: 25,
129
- top: 2,
130
- tintColor: theme.colors.backArrow,
131
- }}
132
- borderColor={theme.colors.clear}
133
- style={styles.icons}
134
- onClick={() => handleCopyClipboard?.()}
135
- />
136
- <OIconButton
137
- icon={theme.images.general.print}
138
- iconStyle={{
139
- width: 25,
140
- height: 22,
141
- tintColor: theme.colors.backArrow,
142
- }}
143
- borderColor={theme.colors.clear}
144
- style={styles.icons}
145
- onClick={() => handleViewSummaryOrder?.()}
146
- />
135
+ <TouchableOpacity onPress={() => handleCopyClipboard?.()}>
136
+ <MaterialCommunityIcons
137
+ name='content-copy'
138
+ color={theme.colors.textGray}
139
+ size={20}
140
+ style={styles.icons}
141
+ />
142
+ </TouchableOpacity>
143
+ {!!handleViewSummaryOrder && (
144
+ <TouchableOpacity onPress={() => handleViewSummaryOrder?.()}>
145
+ <SimpleLineIcons
146
+ name='printer'
147
+ color={theme.colors.textGray}
148
+ size={20}
149
+ style={styles.icons}
150
+ />
151
+ </TouchableOpacity>
152
+ )}
147
153
  </>
148
154
  )}
149
155
  <OIconButton
@@ -151,7 +157,7 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
151
157
  iconStyle={{
152
158
  width: 20,
153
159
  height: 20,
154
- tintColor: theme.colors.backArrow,
160
+ tintColor: theme.colors.textGray,
155
161
  }}
156
162
  borderColor={theme.colors.clear}
157
163
  style={styles.icons}
@@ -163,7 +169,7 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
163
169
  iconStyle={{
164
170
  width: 20,
165
171
  height: 20,
166
- tintColor: theme.colors.backArrow,
172
+ tintColor: theme.colors.textGray,
167
173
  }}
168
174
  borderColor={theme.colors.clear}
169
175
  style={styles.icons}
@@ -193,29 +199,24 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
193
199
  {getOrderStatus(order?.status, t)?.value !==
194
200
  t('PENDING', 'Pending') && (
195
201
  <>
196
- <OIconButton
197
- icon={theme.images.general.copy}
198
- iconStyle={{
199
- width: 20,
200
- height: 25,
201
- top: 2,
202
- tintColor: theme.colors.backArrow,
203
- }}
204
- borderColor={theme.colors.clear}
205
- style={styles.icons}
206
- onClick={() => handleCopyClipboard?.()}
207
- />
208
- <OIconButton
209
- icon={theme.images.general.print}
210
- iconStyle={{
211
- width: 25,
212
- height: 22,
213
- tintColor: theme.colors.backArrow,
214
- }}
215
- borderColor={theme.colors.clear}
216
- style={styles.icons}
217
- onClick={() => handleViewSummaryOrder?.()}
218
- />
202
+ <TouchableOpacity onPress={() => handleCopyClipboard?.()}>
203
+ <MaterialCommunityIcons
204
+ name='content-copy'
205
+ color={theme.colors.textGray}
206
+ size={20}
207
+ style={styles.icons}
208
+ />
209
+ </TouchableOpacity>
210
+ {!!handleViewSummaryOrder && (
211
+ <TouchableOpacity onPress={() => handleViewSummaryOrder?.()}>
212
+ <SimpleLineIcons
213
+ name='printer'
214
+ color={theme.colors.textGray}
215
+ size={20}
216
+ style={styles.icons}
217
+ />
218
+ </TouchableOpacity>
219
+ )}
219
220
  </>
220
221
  )}
221
222
  <OIconButton
@@ -223,7 +224,7 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
223
224
  iconStyle={{
224
225
  width: 20,
225
226
  height: 20,
226
- tintColor: theme.colors.backArrow,
227
+ tintColor: theme.colors.textGray,
227
228
  }}
228
229
  borderColor={theme.colors.clear}
229
230
  style={styles.icons}
@@ -235,7 +236,7 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
235
236
  iconStyle={{
236
237
  width: 20,
237
238
  height: 20,
238
- tintColor: theme.colors.backArrow,
239
+ tintColor: theme.colors.textGray,
239
240
  }}
240
241
  borderColor={theme.colors.clear}
241
242
  style={styles.icons}
@@ -262,7 +263,7 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
262
263
  )}
263
264
  </>
264
265
  </OText>
265
- {!order?.isLogistic && order?.delivery_type && (!order?.order_group_id || !logisticOrderStatus?.includes(order?.status)) && (
266
+ {!order?.isLogistic && !!order?.delivery_type && (!order?.order_group_id || !logisticOrderStatus?.includes(order?.status)) && (
266
267
  <>
267
268
  <OText size={13}>
268
269
  <OText size={13} weight='bold'>{`${t('ORDER_TYPE', 'Order Type')}: `}</OText>
@@ -0,0 +1,195 @@
1
+ //React & React Native
2
+ import React, { useState, useEffect } from 'react';
3
+ import { View } from 'react-native';
4
+
5
+ // Thirds
6
+ import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
7
+
8
+ //OrderingComponent
9
+ import {
10
+ useLanguage,
11
+ OrderDetails as OrderDetailsConTableoller,
12
+ useSession,
13
+ } from 'ordering-components/native';
14
+
15
+ //Components
16
+ import Alert from '../../providers/AlertProvider';
17
+ import { FloatingButton } from '../FloatingButton';
18
+ import { OrderDetailsLogisticParams } from '../../types';
19
+ import { useTheme } from 'styled-components/native';
20
+ import { NotFoundSource } from '../NotFoundSource';
21
+ import { getOrderStatus } from '../../utils';
22
+ import { OrderHeaderComponent } from '../OrderDetails/OrderHeaderComponent';
23
+ import { OrderContentComponent } from '../OrderDetails/OrderContentComponent';
24
+ //Styles
25
+ import { OrderDetailsContainer } from './styles';
26
+
27
+ export const OrderDetailsLogisticUI = (props: OrderDetailsLogisticParams) => {
28
+ const {
29
+ navigation,
30
+ handleClickLogisticOrder,
31
+ orderAssingId,
32
+ } = props;
33
+ const { order } = props.order
34
+ const theme = useTheme();
35
+ const [, t] = useLanguage();
36
+ const [session] = useSession();
37
+ const [alertState, setAlertState] = useState<{
38
+ open: boolean;
39
+ content: Array<string>;
40
+ key?: string | null;
41
+ }>({ open: false, content: [], key: null });
42
+
43
+ const logisticOrderStatus = [4, 6, 7]
44
+
45
+ const showFloatButtonsAcceptOrReject: any = {
46
+ 0: true,
47
+ 4: true,
48
+ 7: true,
49
+ 14: true
50
+ };
51
+
52
+ const handleArrowBack: any = () => {
53
+ navigation?.canGoBack() && navigation.goBack();
54
+ };
55
+
56
+ const handleRejectLogisticOrder = (order: any) => {
57
+ handleClickLogisticOrder?.(2, orderAssingId || order?.logistic_order_id, order)
58
+ handleArrowBack()
59
+ }
60
+
61
+ const handleAcceptLogisticOrder = (order: any) => {
62
+ handleClickLogisticOrder?.(1, orderAssingId || order?.logistic_order_id, order)
63
+ handleArrowBack()
64
+ }
65
+
66
+ useEffect(() => {
67
+ if (order?.driver === null && session?.user?.level === 4) {
68
+ setAlertState({
69
+ open: true,
70
+ content: [
71
+ t(
72
+ 'YOU_HAVE_BEEN_REMOVED_FROM_THE_ORDER',
73
+ 'You have been removed from the order',
74
+ ),
75
+ ],
76
+ key: null,
77
+ });
78
+ }
79
+ }, [order?.driver]);
80
+
81
+ const OrderDetailsInformation = (props: { order: any, isOrderGroup?: boolean, lastOrder?: boolean }) => {
82
+ const {
83
+ order,
84
+ isOrderGroup,
85
+ lastOrder,
86
+ } = props
87
+ return (
88
+ <>
89
+ <OrderContentComponent
90
+ order={order}
91
+ logisticOrderStatus={logisticOrderStatus}
92
+ isOrderGroup={isOrderGroup}
93
+ lastOrder={lastOrder}
94
+ />
95
+ <View
96
+ style={{
97
+ height:
98
+ order?.status === 8 && order?.delivery_type === 1 ? 50 : 35,
99
+ }}
100
+ />
101
+
102
+ </>
103
+ )
104
+ }
105
+
106
+ return (
107
+ <>
108
+ {(!order || Object.keys(order).length === 0) &&
109
+ (props.order?.error?.length < 1 || !props.order?.error) && (
110
+ <View style={{ flex: 1 }}>
111
+ {[...Array(6)].map((item, i) => (
112
+ <Placeholder key={i} Animation={Fade}>
113
+ <View style={{ flexDirection: 'row', paddingVertical: 20 }}>
114
+ <Placeholder>
115
+ <PlaceholderLine width={100} />
116
+ <PlaceholderLine width={70} />
117
+ <PlaceholderLine width={30} />
118
+ <PlaceholderLine width={20} />
119
+ </Placeholder>
120
+ </View>
121
+ </Placeholder>
122
+ ))}
123
+ </View>
124
+ )}
125
+
126
+ {(!!props.order?.error || props.order?.error) && (
127
+ <NotFoundSource
128
+ btnTitle={t('GO_TO_MY_ORDERS', 'Go to my orders')}
129
+ content={
130
+ props.order.error[0] ||
131
+ props.order.error ||
132
+ t('NETWORK_ERROR', 'Network Error')
133
+ }
134
+ onClickButton={() => navigation.navigate('Orders')}
135
+ />
136
+ )}
137
+ {!((!order || Object.keys(order).length === 0) &&
138
+ (props.order?.error?.length < 1 || !props.order?.error)) && (
139
+ <View style={{ flex: 1 }}>
140
+ <OrderHeaderComponent
141
+ order={order}
142
+ getOrderStatus={getOrderStatus}
143
+ handleArrowBack={handleArrowBack}
144
+ logisticOrderStatus={logisticOrderStatus}
145
+ />
146
+ {order && Object.keys(order).length > 0 && (props.order?.error?.length < 1 || !props.order?.error) && (
147
+ <>
148
+ <OrderDetailsContainer
149
+ keyboardShouldPersistTaps="handled"
150
+ showsVerticalScrollIndicator={false}
151
+ >
152
+ {order?.order_group && !!order?.order_group_id && order?.isLogistic ? order?.order_group?.orders.map((order: any, i: number, hash: any) => (
153
+ <OrderDetailsInformation key={order?.id} order={order} isOrderGroup lastOrder={hash?.length === i + 1} />
154
+ )) : (
155
+ <OrderDetailsInformation order={order} />
156
+ )}
157
+ </OrderDetailsContainer>
158
+
159
+ {showFloatButtonsAcceptOrReject[order?.status] && (
160
+ <FloatingButton
161
+ btnText={t('REJECT', 'Reject')}
162
+ isSecondaryBtn={false}
163
+ secondButtonClick={() => handleAcceptLogisticOrder(order)}
164
+ firstButtonClick={() => handleRejectLogisticOrder(order)}
165
+ secondBtnText={t('ACCEPT', 'Accept')}
166
+ secondButton={true}
167
+ firstColorCustom={theme.colors.red}
168
+ secondColorCustom={theme.colors.green}
169
+ widthButton={'45%'}
170
+ />
171
+ )}
172
+ </>
173
+ )}
174
+ </View>
175
+ )}
176
+ {alertState?.open && (
177
+ <Alert
178
+ open={alertState.open}
179
+ onAccept={handleArrowBack}
180
+ onClose={handleArrowBack}
181
+ content={alertState.content}
182
+ title={t('WARNING', 'Warning')}
183
+ />
184
+ )}
185
+ </>
186
+ );
187
+ };
188
+
189
+ export const OrderDetailsLogistic = (props: OrderDetailsLogisticParams) => {
190
+ const orderDetailsProps = {
191
+ ...props,
192
+ UIComponent: OrderDetailsLogisticUI,
193
+ };
194
+ return <OrderDetailsConTableoller {...orderDetailsProps} />;
195
+ };
@@ -0,0 +1,5 @@
1
+ import styled from 'styled-components/native';
2
+
3
+ export const OrderDetailsContainer = styled.ScrollView`
4
+ flex: 1;
5
+ `;