ordering-ui-react-native 0.17.74 → 0.17.75-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 (231) hide show
  1. package/package.json +8 -7
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessInformation/index.tsx +10 -9
  4. package/src/components/BusinessesListing/index.tsx +1 -1
  5. package/src/components/OrderCreating/index.tsx +1 -21
  6. package/src/components/PaymentOptionsWebView/index.tsx +29 -8
  7. package/src/components/PhoneInputNumber/index.tsx +6 -2
  8. package/src/components/StripeMethodForm/index.tsx +136 -102
  9. package/src/components/VerifyPhone/styles.tsx +1 -2
  10. package/src/components/shared/OToast.tsx +3 -2
  11. package/src/types/index.tsx +5 -0
  12. package/src/utils/index.tsx +5 -0
  13. package/themes/business/index.tsx +2 -0
  14. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +28 -25
  15. package/themes/business/src/components/BusinessController/index.tsx +0 -1
  16. package/themes/business/src/components/Chat/index.tsx +149 -118
  17. package/themes/business/src/components/DriverMap/index.tsx +17 -6
  18. package/themes/business/src/components/DriverSchedule/index.tsx +45 -8
  19. package/themes/business/src/components/GoogleMap/index.tsx +58 -57
  20. package/themes/business/src/components/LoginForm/Otp/index.tsx +31 -3
  21. package/themes/business/src/components/LoginForm/index.tsx +15 -22
  22. package/themes/business/src/components/MapView/index.tsx +10 -10
  23. package/themes/business/src/components/MessagesOption/index.tsx +20 -93
  24. package/themes/business/src/components/NewOrderNotification/index.tsx +37 -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 +102 -40
  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 +17 -15
  35. package/themes/business/src/components/PreviousMessages/FooterMessageComponent.tsx +103 -0
  36. package/themes/business/src/components/PreviousMessages/index.tsx +97 -55
  37. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +17 -12
  38. package/themes/business/src/components/PreviousOrders/OrderList.tsx +88 -0
  39. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +1 -1
  40. package/themes/business/src/components/PreviousOrders/index.tsx +139 -174
  41. package/themes/business/src/components/ProductItemAccordion/index.tsx +27 -3
  42. package/themes/business/src/components/ReviewCustomer/index.tsx +18 -13
  43. package/themes/business/src/components/StoresList/index.tsx +3 -4
  44. package/themes/business/src/components/UserProfileForm/index.tsx +14 -15
  45. package/themes/business/src/components/shared/OLink.tsx +9 -2
  46. package/themes/business/src/components/shared/OModal.tsx +16 -9
  47. package/themes/business/src/components/shared/OText.tsx +6 -1
  48. package/themes/business/src/types/index.tsx +25 -10
  49. package/themes/business/src/utils/index.tsx +29 -2
  50. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  51. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  52. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  53. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  54. package/themes/kiosk/src/components/Intro/index.tsx +16 -1
  55. package/themes/kiosk/src/components/LoginForm/index.tsx +7 -9
  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 +2 -2
  60. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  61. package/themes/original/index.tsx +1 -1
  62. package/themes/original/src/components/AddressDetails/index.tsx +19 -3
  63. package/themes/original/src/components/AddressForm/index.tsx +61 -39
  64. package/themes/original/src/components/AddressList/index.tsx +25 -24
  65. package/themes/original/src/components/AddressList/styles.tsx +4 -2
  66. package/themes/original/src/components/AnalyticsSegment/index.tsx +193 -10
  67. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  68. package/themes/original/src/components/AppleLogin/styles.tsx +3 -1
  69. package/themes/original/src/components/BusinessBasicInformation/index.tsx +153 -96
  70. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +10 -12
  71. package/themes/original/src/components/BusinessController/index.tsx +80 -66
  72. package/themes/original/src/components/BusinessController/styles.tsx +12 -5
  73. package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
  74. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
  75. package/themes/original/src/components/BusinessInformation/index.tsx +140 -85
  76. package/themes/original/src/components/BusinessItemAccordion/index.tsx +15 -20
  77. package/themes/original/src/components/BusinessListingSearch/index.tsx +349 -339
  78. package/themes/original/src/components/BusinessListingSearch/styles.tsx +0 -18
  79. package/themes/original/src/components/BusinessPreorder/index.tsx +103 -19
  80. package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -2
  81. package/themes/original/src/components/BusinessProductsList/index.tsx +15 -7
  82. package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
  83. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +1 -1
  84. package/themes/original/src/components/BusinessProductsListing/index.tsx +684 -557
  85. package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -2
  86. package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
  87. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +69 -38
  88. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +0 -1
  89. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  90. package/themes/original/src/components/Cart/index.tsx +76 -79
  91. package/themes/original/src/components/CartContent/index.tsx +117 -20
  92. package/themes/original/src/components/CartContent/styles.tsx +17 -7
  93. package/themes/original/src/components/Checkout/index.tsx +281 -54
  94. package/themes/original/src/components/CitiesControl/index.tsx +1 -1
  95. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  96. package/themes/original/src/components/DriverTips/index.tsx +52 -34
  97. package/themes/original/src/components/FacebookLogin/styles.tsx +3 -1
  98. package/themes/original/src/components/Favorite/index.tsx +2 -6
  99. package/themes/original/src/components/FavoriteList/index.tsx +1 -35
  100. package/themes/original/src/components/FloatingButton/index.tsx +10 -13
  101. package/themes/original/src/components/GPSButton/index.tsx +6 -4
  102. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +7 -3
  103. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +2 -0
  104. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +19 -6
  105. package/themes/original/src/components/GoogleLogin/styles.tsx +1 -1
  106. package/themes/original/src/components/GoogleMap/index.tsx +60 -5
  107. package/themes/original/src/components/Help/index.tsx +2 -2
  108. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +10 -31
  109. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +5 -3
  110. package/themes/original/src/components/HelpGuide/index.tsx +6 -6
  111. package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
  112. package/themes/original/src/components/HelpOrder/index.tsx +6 -15
  113. package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
  114. package/themes/original/src/components/Home/index.tsx +13 -4
  115. package/themes/original/src/components/LastOrder/index.tsx +1 -34
  116. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -25
  117. package/themes/original/src/components/LoginForm/index.tsx +64 -34
  118. package/themes/original/src/components/LottieAnimation/index.tsx +88 -63
  119. package/themes/original/src/components/MessageListing/index.tsx +16 -42
  120. package/themes/original/src/components/Messages/index.tsx +14 -7
  121. package/themes/original/src/components/MomentOption/index.tsx +193 -90
  122. package/themes/original/src/components/MomentSelector/index.tsx +1 -1
  123. package/themes/original/src/components/MultiCart/index.tsx +41 -54
  124. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +162 -50
  125. package/themes/original/src/components/MultiCheckout/index.tsx +329 -100
  126. package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
  127. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
  128. package/themes/original/src/components/MultiOrdersDetails/index.tsx +54 -21
  129. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
  130. package/themes/original/src/components/MyOrders/index.tsx +40 -29
  131. package/themes/original/src/components/NavBar/index.tsx +20 -17
  132. package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
  133. package/themes/original/src/components/Notifications/index.tsx +42 -52
  134. package/themes/original/src/components/Notifications/styles.tsx +6 -3
  135. package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
  136. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +21 -5
  137. package/themes/original/src/components/OrderDetails/index.tsx +28 -233
  138. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  139. package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
  140. package/themes/original/src/components/OrderProgress/index.tsx +30 -56
  141. package/themes/original/src/components/OrderSummary/index.tsx +83 -57
  142. package/themes/original/src/components/OrderTypeSelector/index.tsx +2 -1
  143. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +14 -14
  144. package/themes/original/src/components/OrdersOption/index.tsx +67 -85
  145. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  146. package/themes/original/src/components/PageBanner/index.tsx +98 -38
  147. package/themes/original/src/components/PageBanner/styles.tsx +0 -10
  148. package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
  149. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
  150. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  151. package/themes/original/src/components/PaymentOptions/index.tsx +77 -34
  152. package/themes/original/src/components/PhoneInputNumber/index.tsx +18 -4
  153. package/themes/original/src/components/ProductForm/index.tsx +104 -29
  154. package/themes/original/src/components/ProductForm/styles.tsx +5 -5
  155. package/themes/original/src/components/ProductItemAccordion/index.tsx +8 -6
  156. package/themes/original/src/components/ProductOptionSubOption/index.tsx +20 -18
  157. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +5 -9
  158. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  159. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
  160. package/themes/original/src/components/ProfessionalProfile/index.tsx +36 -7
  161. package/themes/original/src/components/Promotions/index.tsx +2 -2
  162. package/themes/original/src/components/Promotions/styles.tsx +3 -1
  163. package/themes/original/src/components/ReviewProducts/index.tsx +16 -7
  164. package/themes/original/src/components/ScheduleAccordion/index.tsx +3 -3
  165. package/themes/original/src/components/ServiceForm/index.tsx +63 -20
  166. package/themes/original/src/components/Sessions/index.tsx +11 -8
  167. package/themes/original/src/components/Sessions/styles.tsx +5 -0
  168. package/themes/original/src/components/SignupForm/index.tsx +43 -27
  169. package/themes/original/src/components/SingleOrderCard/index.tsx +102 -63
  170. package/themes/original/src/components/SingleOrderCard/styles.tsx +1 -1
  171. package/themes/original/src/components/SingleProductCard/index.tsx +72 -31
  172. package/themes/original/src/components/SingleProductCard/styles.tsx +20 -4
  173. package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
  174. package/themes/original/src/components/StripeCardsList/index.tsx +49 -5
  175. package/themes/original/src/components/StripeElementsForm/index.tsx +48 -34
  176. package/themes/original/src/components/StripeElementsForm/naked.tsx +12 -1
  177. package/themes/original/src/components/UpsellingProducts/index.tsx +238 -224
  178. package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
  179. package/themes/original/src/components/UserDetails/index.tsx +3 -1
  180. package/themes/original/src/components/UserFormDetails/index.tsx +78 -9
  181. package/themes/original/src/components/UserFormDetails/styles.tsx +1 -1
  182. package/themes/original/src/components/UserProfile/index.tsx +88 -79
  183. package/themes/original/src/components/UserProfileForm/index.tsx +17 -21
  184. package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
  185. package/themes/original/src/components/UserVerification/index.tsx +55 -50
  186. package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
  187. package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
  188. package/themes/original/src/components/Wallets/index.tsx +56 -33
  189. package/themes/original/src/components/Wallets/styles.tsx +3 -4
  190. package/themes/original/src/components/shared/OButton.tsx +6 -2
  191. package/themes/original/src/components/shared/OInput.tsx +6 -1
  192. package/themes/original/src/components/shared/OModal.tsx +3 -3
  193. package/themes/original/src/types/index.tsx +39 -10
  194. package/themes/original/src/utils/index.tsx +273 -1
  195. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  196. package/src/navigators/BottomNavigator.tsx +0 -117
  197. package/src/navigators/CheckoutNavigator.tsx +0 -66
  198. package/src/navigators/HomeNavigator.tsx +0 -202
  199. package/src/navigators/NavigationRef.tsx +0 -7
  200. package/src/navigators/RootNavigator.tsx +0 -269
  201. package/src/pages/Account.tsx +0 -34
  202. package/src/pages/AddressForm.tsx +0 -62
  203. package/src/pages/AddressList.tsx +0 -24
  204. package/src/pages/BusinessProductsList.tsx +0 -81
  205. package/src/pages/BusinessesListing.tsx +0 -43
  206. package/src/pages/CartList.tsx +0 -49
  207. package/src/pages/Checkout.tsx +0 -101
  208. package/src/pages/ForgotPassword.tsx +0 -24
  209. package/src/pages/Help.tsx +0 -23
  210. package/src/pages/HelpAccountAndPayment.tsx +0 -23
  211. package/src/pages/HelpGuide.tsx +0 -23
  212. package/src/pages/HelpOrder.tsx +0 -23
  213. package/src/pages/Home.tsx +0 -36
  214. package/src/pages/IntroductoryTutorial.tsx +0 -170
  215. package/src/pages/Login.tsx +0 -47
  216. package/src/pages/MomentOption.tsx +0 -30
  217. package/src/pages/MultiCheckout.tsx +0 -31
  218. package/src/pages/MultiOrdersDetails.tsx +0 -27
  219. package/src/pages/MyOrders.tsx +0 -40
  220. package/src/pages/NetworkError.tsx +0 -24
  221. package/src/pages/NotFound.tsx +0 -22
  222. package/src/pages/OrderDetails.tsx +0 -25
  223. package/src/pages/ProductDetails.tsx +0 -55
  224. package/src/pages/Profile.tsx +0 -36
  225. package/src/pages/ReviewDriver.tsx +0 -30
  226. package/src/pages/ReviewOrder.tsx +0 -32
  227. package/src/pages/ReviewProducts.tsx +0 -30
  228. package/src/pages/Sessions.tsx +0 -22
  229. package/src/pages/Signup.tsx +0 -53
  230. package/src/pages/SpinnerLoader.tsx +0 -10
  231. package/src/pages/Splash.tsx +0 -21
@@ -410,7 +410,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
410
410
  </View>
411
411
  )}
412
412
 
413
- {(!!error || error) && (
413
+ {(!!error || error?.length > 0) && (
414
414
  <NotFoundSource
415
415
  btnTitle={t('GO_TO_MY_ORDERS', 'Go to my orders')}
416
416
  content={
@@ -4,6 +4,7 @@ import { StyleSheet, View } from 'react-native';
4
4
 
5
5
  // Thirds
6
6
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
7
+ import Clipboard from '@react-native-clipboard/clipboard';
7
8
 
8
9
  //OrderingComponent
9
10
  import {
@@ -12,6 +13,8 @@ import {
12
13
  useToast,
13
14
  useSession,
14
15
  ToastType,
16
+ useUtils,
17
+ useConfig
15
18
  } from 'ordering-components/native';
16
19
 
17
20
  //Components
@@ -26,7 +29,7 @@ import { OrderDetailsParams } from '../../types';
26
29
  import { USER_TYPE } from '../../config/constants';
27
30
  import { useTheme } from 'styled-components/native';
28
31
  import { NotFoundSource } from '../NotFoundSource';
29
- import { getOrderStatus } from '../../utils';
32
+ import { verifyDecimals, getProductPrice, getOrderStatus } from '../../utils';
30
33
  import { OrderHeaderComponent } from './OrderHeaderComponent';
31
34
  import { OrderContentComponent } from './OrderContentComponent';
32
35
  //Styles
@@ -52,10 +55,15 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
52
55
  handleClickLogisticOrder,
53
56
  forceUpdate,
54
57
  getPermissions,
55
- isGrantedPermissions
58
+ orderAssingId,
59
+ isGrantedPermissions,
56
60
  } = props;
57
61
  const [, { showToast }] = useToast();
62
+ const [{ parsePrice, parseNumber }] = useUtils();
63
+ const [{ configs }] = useConfig();
58
64
  const { order } = props.order
65
+
66
+ const isAllowedDriverRejectOrder = configs?.allow_driver_reject_order?.value === '1'
59
67
  const theme = useTheme();
60
68
  const [, t] = useLanguage();
61
69
  const [session] = useSession();
@@ -75,6 +83,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
75
83
 
76
84
  const validStatusComplete = [9, 19, 23]
77
85
 
86
+ const pendingOrderStatus = [1, 4, 7, 13]
87
+
78
88
  const logisticOrderStatus = [4, 6, 7]
79
89
 
80
90
  const showFloatButtonsPickUp: any = {
@@ -133,7 +143,174 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
133
143
  }
134
144
  };
135
145
 
146
+ const getFormattedSubOptionName = ({ quantity, name, position, price }: any) => {
147
+ if (name !== 'No') {
148
+ const pos = position && position !== 'whole' ? `(${t(position.toUpperCase(), position)})` : '';
149
+ return pos
150
+ ? `${quantity} x ${name} ${pos} +${parsePrice(price)}\n`
151
+ : `${quantity} x ${name} +${parsePrice(price)}\n`;
152
+ } else {
153
+ return 'No\n';
154
+ }
155
+ };
156
+
157
+ const handleCopyClipboard = () => {
158
+ const businessName = !!order?.business?.name
159
+ ? `${order?.business?.name} \n`
160
+ : '';
161
+
162
+ const businessEmail = !!order?.business?.email
163
+ ? `${order?.business?.email} \n`
164
+ : '';
165
+
166
+ const businessCellphone = !!order?.business?.cellphone
167
+ ? `${order?.business?.cellphone} \n`
168
+ : '';
169
+
170
+ const businessPhone = !!order?.business?.phone
171
+ ? `${order?.business?.phone} \n`
172
+ : '';
173
+
174
+ const businessAddress = !!order?.business?.address
175
+ ? `${order?.business?.address} \n`
176
+ : '';
177
+
178
+ const businessSpecialAddress = !!order?.business?.address_notes
179
+ ? `${order?.business?.address_notes} \n \n`
180
+ : '';
181
+
182
+ const customerName = !!order?.customer?.name
183
+ ? `${order?.customer?.name} ${order?.customer?.middle_name || ''} ${order?.customer?.lastname || ''
184
+ } ${order?.customer?.second_lastname || ''} \n`
185
+ : '';
186
+
187
+ const customerEmail = !!order?.customer.email
188
+ ? `${order?.customer.email} \n`
189
+ : '';
190
+
191
+ const customerCellPhone = !!order?.customer?.cellphone
192
+ ? `${order?.customer?.cellphone} \n`
193
+ : '';
194
+
195
+ const customerPhone = !!order?.customer?.phone
196
+ ? `${order?.customer?.phone} \n`
197
+ : '';
198
+
199
+ const customerAddress = !!order?.customer?.address
200
+ ? `${order?.customer?.address} \n`
201
+ : '';
202
+
203
+ const customerSpecialAddress = !!order?.customer?.address_notes
204
+ ? `${order?.customer?.address_notes} \n`
205
+ : '';
206
+
207
+ const payment = order?.paymethod?.name
208
+ ? `${order?.paymethod?.name} - ${order.delivery_type === 1
209
+ ? t('DELIVERY', 'Delivery')
210
+ : order.delivery_type === 2
211
+ ? t('PICKUP', 'Pickup')
212
+ : order.delivery_type === 3
213
+ ? t('EAT_IN', 'Eat in')
214
+ : order.delivery_type === 4
215
+ ? t('CURBSIDE', 'Curbside')
216
+ : t('DRIVER_THRU', 'Driver thru')
217
+ }\n`
218
+ : '';
219
+
220
+ const getSuboptions = (suboptions: any) => {
221
+ const array: any = []
222
+ suboptions?.length > 0 &&
223
+ suboptions?.map((suboption: any) => {
224
+ const string = `${getFormattedSubOptionName(suboption)}`
225
+ array.push(string)
226
+ })
227
+
228
+ return array.join('')
229
+ }
230
+
231
+ const getOptions = (options: any, productComment: string = '') => {
232
+ const array: any = [];
233
+
234
+ options?.length &&
235
+ options?.map((option: any) => {
236
+ const string =
237
+ ` ${option.name}\n ${getSuboptions(option.suboptions)}`;
238
+
239
+ array.push(string)
240
+ })
241
+
242
+ if (productComment) {
243
+ array.push(` ${t('COMMENT', 'Comment')}\n ${productComment}\n`)
244
+ }
245
+
246
+ return array.join('')
247
+ }
248
+
249
+ const productsInArray =
250
+ order?.products.length &&
251
+ order?.products.map((product: any, i: number) => {
252
+ const string =
253
+ `${product?.quantity} X ${product?.name} ${parsePrice(product.total ?? getProductPrice(product))}\n${getOptions(product.options, product.comment)}`;
254
+
255
+ return i === 0 ? ` ${string}` : string
256
+ });
257
+
258
+ const productsInString = productsInArray.join(' ');
259
+ const orderDetails = `${t(
260
+ 'ORDER_DETAILS',
261
+ 'Order Details',
262
+ )}:\n${productsInString}\n`;
263
+
264
+ const subtotal = `${t('SUBTOTAL', 'Subtotal')}: ${parsePrice(
265
+ order?.subtotal,
266
+ )}\n`;
267
+
268
+ const drivertip = `${t('DRIVER_TIP', 'Driver tip')} ${parsePrice(
269
+ order?.summary?.driver_tip || order?.totalDriverTip,
270
+ )}\n`;
271
+
272
+ const deliveryFee = `${t('DELIVERY_FEE', 'Delivery fee')} ${verifyDecimals(
273
+ order?.service_fee,
274
+ parseNumber,
275
+ )}% ${parsePrice(order?.summary?.service_fee || order?.serviceFee || 0)}\n`;
276
+
277
+ const total = `${t('TOTAL', 'Total')} ${parsePrice(
278
+ order?.summary?.total || order?.total,
279
+ )}\n`;
280
+
281
+ const orderStatus = `${t('INVOICE_ORDER_NO', 'Order No.')} ${order.id} ${t(
282
+ 'IS',
283
+ 'is',
284
+ )} ${getOrderStatus(order?.status, t)?.value}\n`;
285
+
286
+ Clipboard.setString(
287
+ `${orderStatus} ${payment} ${t(
288
+ 'BUSINESS_DETAILS',
289
+ 'Business Details',
290
+ )}\n ${businessName} ${businessEmail} ${businessCellphone} ${businessPhone} ${businessAddress} ${businessSpecialAddress}${t(
291
+ 'CUSTOMER_DETAILS',
292
+ 'Customer Details',
293
+ )}\n ${customerName} ${customerEmail} ${customerCellPhone} ${customerPhone} ${customerAddress} ${customerSpecialAddress}\n${orderDetails} ${subtotal} ${drivertip} ${deliveryFee} ${total}`,
294
+ );
295
+
296
+ showToast(
297
+ ToastType.Info,
298
+ t('COPY_TO_CLIPBOARD', 'Copy to clipboard.'),
299
+ 1000,
300
+ );
301
+ };
302
+
136
303
  const handleViewActionOrder = (action: string) => {
304
+ if (action === 'reject' && !isAllowedDriverRejectOrder) {
305
+ setAlertState({
306
+ open: true,
307
+ content: [
308
+ t('DRIVER_NOT_ALLOWED_TO_REJECT_ORDER', 'The driver is not allowed to reject an order.'),
309
+ ],
310
+ key: null,
311
+ })
312
+ return
313
+ }
137
314
  if (!isGrantedPermissions) {
138
315
  navigation.navigate('RequestPermissions')
139
316
  return
@@ -150,16 +327,23 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
150
327
  };
151
328
 
152
329
  const handleArrowBack: any = () => {
330
+ if (alertState?.open && !isAllowedDriverRejectOrder && !pendingOrderStatus.includes(order?.status)) {
331
+ setAlertState({
332
+ ...alertState,
333
+ open: false
334
+ })
335
+ return
336
+ }
153
337
  navigation?.canGoBack() && navigation.goBack();
154
338
  };
155
339
 
156
340
  const handleRejectLogisticOrder = () => {
157
- handleClickLogisticOrder?.(2, order?.logistic_order_id)
341
+ handleClickLogisticOrder?.(2, orderAssingId || order?.logistic_order_id)
158
342
  handleArrowBack()
159
343
  }
160
344
 
161
345
  const handleAcceptLogisticOrder = (order: any) => {
162
- handleClickLogisticOrder?.(1, order?.logistic_order_id)
346
+ handleClickLogisticOrder?.(1, orderAssingId || order?.logistic_order_id)
163
347
  if (order?.order_group) {
164
348
  handleArrowBack()
165
349
  }
@@ -203,7 +387,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
203
387
  }, [props.order?.loading]);
204
388
 
205
389
  useEffect(() => {
206
- if (order?.driver === null && session?.user?.level === 4) {
390
+ if (!order?.driver_id && session?.user?.level === 4) {
207
391
  setAlertState({
208
392
  open: true,
209
393
  content: [
@@ -343,7 +527,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
343
527
  </View>
344
528
  )}
345
529
 
346
- {(!!props.order?.error || props.order?.error) && (
530
+ {(!!props.order?.error || props.order?.error?.length > 0) && (
347
531
  <NotFoundSource
348
532
  btnTitle={t('GO_TO_MY_ORDERS', 'Go to my orders')}
349
533
  content={
@@ -361,6 +545,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
361
545
  order={order}
362
546
  handleOpenMapView={handleOpenMapView}
363
547
  handleOpenMessagesForBusiness={handleOpenMessagesForBusiness}
548
+ handleCopyClipboard={handleCopyClipboard}
364
549
  getOrderStatus={getOrderStatus}
365
550
  handleArrowBack={handleArrowBack}
366
551
  logisticOrderStatus={logisticOrderStatus}
@@ -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 = {
@@ -95,10 +114,21 @@ export const OrderContentComponent = (props: OrderContent) => {
95
114
  return /^\d+$/.test(str);
96
115
  }
97
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
+
98
128
  return (
99
129
  <OrderContent isOrderGroup={isOrderGroup} lastOrder={lastOrder}>
100
130
  {isOrderGroup && (
101
- <OText size={18}>{t('ORDER', 'Order')} #{isOrderGroup ? order?.order_group_id : order?.id}</OText>
131
+ <OText size={18}>{t('ORDER', 'Order')} #{order?.id}</OText>
102
132
  )}
103
133
 
104
134
  {order?.metafields?.length > 0 && (
@@ -186,19 +216,34 @@ export const OrderContentComponent = (props: OrderContent) => {
186
216
  />
187
217
  </View>
188
218
  )}
189
-
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
+ )}
190
224
  {!!order?.business?.address_notes && (
191
- <View style={styles.linkWithIcons}>
192
- <OLink
193
- PressStyle={styles.linkWithIcons}
194
- url={Platform.select({
195
- ios: `maps:0,0?q=${order?.business?.address_notes}`,
196
- android: `geo:0,0?q=${order?.business?.address_notes}`,
197
- })}
198
- shorcut={order?.business?.address_notes}
199
- TextStyle={styles.textLink}
200
- />
201
- </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
+ </>
202
247
  )}
203
248
  </OrderBusiness>
204
249
 
@@ -298,18 +343,28 @@ export const OrderContentComponent = (props: OrderContent) => {
298
343
  )}
299
344
 
300
345
  {!!order?.customer?.address && (
301
- <View style={styles.linkWithIcons}>
302
- <OLink
303
- PressStyle={styles.linkWithIcons}
304
- url={Platform.select({
305
- ios: `maps:0,0?q=${order?.customer?.address}`,
306
- android: `geo:0,0?q=${order?.customer?.address}`,
307
- })}
308
- numberOfLines={2}
309
- shorcut={order?.customer?.address}
310
- TextStyle={styles.textLink}
311
- />
312
- </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
+ </>
313
368
  )}
314
369
 
315
370
  {!!order?.customer?.internal_number && (
@@ -319,9 +374,15 @@ export const OrderContentComponent = (props: OrderContent) => {
319
374
  )}
320
375
 
321
376
  {!!order?.customer?.address_notes && (
322
- <OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
323
- {order?.customer?.address_notes}
324
- </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>
325
386
  )}
326
387
 
327
388
  {!!order?.customer?.zipcode && (
@@ -488,7 +549,7 @@ export const OrderContentComponent = (props: OrderContent) => {
488
549
  ))
489
550
  }
490
551
  {
491
- order?.summary?.delivery_price > 0 && (
552
+ typeof order?.summary?.delivery_price === 'number' && (
492
553
  <Table>
493
554
  <OText mBottom={4}>
494
555
  {t('DELIVERY_FEE', 'Delivery Fee')}
@@ -515,15 +576,14 @@ export const OrderContentComponent = (props: OrderContent) => {
515
576
  </Table>
516
577
  ))
517
578
  }
518
- {order?.summary?.driver_tip > 0 && (
579
+ {(order?.summary?.driver_tip > 0 || order?.driver_tip > 0) && (
519
580
  <Table>
520
581
  <OText mBottom={4}>
521
582
  {t('DRIVER_TIP', 'Driver tip')}
522
- {order?.summary?.driver_tip > 0 &&
523
- parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
583
+ {order?.driver_tip > 0 && parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
524
584
  !parseInt(configs?.driver_tip_use_custom?.value, 10) &&
525
585
  (
526
- `(${verifyDecimals(order?.summary?.driver_tip, parseNumber)}%)`
586
+ `(${verifyDecimals(order?.driver_tip, parseNumber)}%)`
527
587
  )}
528
588
  </OText>
529
589
  <OText mBottom={4}>{parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip, { currency: order?.currency })}</OText>
@@ -576,14 +636,16 @@ export const OrderContentComponent = (props: OrderContent) => {
576
636
  ? walletName[event?.wallet_event?.wallet?.type]?.name
577
637
  : t(event?.paymethod?.name?.toUpperCase()?.replace(/ /g, '_'), event?.paymethod?.name)}
578
638
  </OText>
579
- {event?.data?.charge_id && (
639
+ {/* {event?.data?.charge_id && (
580
640
  <OText>
581
641
  {`${t('CODE', 'Code')}: ${event?.data?.charge_id}`}
582
642
  </OText>
583
- )}
643
+ )} */}
584
644
  </View>
585
645
  <OText>
586
- -{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 })}`}
587
649
  </OText>
588
650
  </View>
589
651
  ))}