ordering-ui-react-native 0.16.91 → 0.16.92-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 (206) 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 +1 -1
  7. package/src/components/BusinessesListing/index.tsx +1 -1
  8. package/src/components/OrderCreating/index.tsx +1 -21
  9. package/src/components/OrdersOption/index.tsx +54 -56
  10. package/src/components/PaymentOptionsWebView/index.tsx +119 -120
  11. package/src/components/SingleProductReview/index.tsx +7 -4
  12. package/src/components/VerifyPhone/styles.tsx +1 -2
  13. package/src/components/shared/OToast.tsx +4 -4
  14. package/src/utils/index.tsx +2 -1
  15. package/themes/business/index.tsx +2 -0
  16. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +265 -240
  17. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
  18. package/themes/business/src/components/BusinessController/index.tsx +2 -2
  19. package/themes/business/src/components/Chat/index.tsx +30 -30
  20. package/themes/business/src/components/DriverMap/index.tsx +22 -9
  21. package/themes/business/src/components/GoogleMap/index.tsx +58 -57
  22. package/themes/business/src/components/LoginForm/Otp/index.tsx +120 -0
  23. package/themes/business/src/components/LoginForm/Otp/styles.tsx +7 -0
  24. package/themes/business/src/components/LoginForm/index.tsx +239 -80
  25. package/themes/business/src/components/LoginForm/styles.tsx +10 -0
  26. package/themes/business/src/components/MapView/index.tsx +18 -7
  27. package/themes/business/src/components/NewOrderNotification/index.tsx +31 -41
  28. package/themes/business/src/components/OrderDetails/Delivery.tsx +4 -3
  29. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +96 -50
  30. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +59 -62
  31. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +195 -0
  32. package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
  33. package/themes/business/src/components/OrderMessage/index.tsx +18 -17
  34. package/themes/business/src/components/OrdersOption/index.tsx +33 -75
  35. package/themes/business/src/components/OrdersOptionBusiness/index.tsx +1 -1
  36. package/themes/business/src/components/PreviousMessages/index.tsx +16 -18
  37. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
  38. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
  39. package/themes/business/src/components/PreviousOrders/index.tsx +447 -247
  40. package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
  41. package/themes/business/src/components/ProductItemAccordion/index.tsx +27 -3
  42. package/themes/business/src/components/ReviewCustomer/index.tsx +54 -27
  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 +33 -2
  47. package/themes/business/src/utils/index.tsx +53 -0
  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/BusinessesListing/index.tsx +2 -1
  52. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  53. package/themes/kiosk/src/components/LoginForm/Otp/index.tsx +92 -0
  54. package/themes/kiosk/src/components/LoginForm/Otp/styles.tsx +7 -0
  55. package/themes/kiosk/src/components/LoginForm/index.tsx +473 -151
  56. package/themes/kiosk/src/components/LoginForm/styles.tsx +14 -1
  57. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  58. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  59. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  60. package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +1 -0
  61. package/themes/kiosk/src/components/PhoneInputNumber/styles.tsx +1 -3
  62. package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
  63. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  64. package/themes/kiosk/src/components/shared/OModal.tsx +14 -11
  65. package/themes/kiosk/src/layouts/Container.tsx +7 -1
  66. package/themes/kiosk/src/types/index.d.ts +13 -0
  67. package/themes/kiosk/src/utils/index.tsx +15 -0
  68. package/themes/original/index.tsx +8 -0
  69. package/themes/original/src/components/AddressDetails/index.tsx +10 -8
  70. package/themes/original/src/components/AddressForm/index.tsx +155 -139
  71. package/themes/original/src/components/AddressList/index.tsx +27 -22
  72. package/themes/original/src/components/AddressList/styles.tsx +4 -2
  73. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  74. package/themes/original/src/components/BusinessBasicInformation/index.tsx +118 -76
  75. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +1 -4
  76. package/themes/original/src/components/BusinessController/index.tsx +100 -47
  77. package/themes/original/src/components/BusinessController/styles.tsx +14 -9
  78. package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
  79. package/themes/original/src/components/BusinessItemAccordion/index.tsx +9 -3
  80. package/themes/original/src/components/BusinessListingSearch/index.tsx +86 -33
  81. package/themes/original/src/components/BusinessListingSearch/styles.tsx +6 -0
  82. package/themes/original/src/components/BusinessPreorder/index.tsx +96 -15
  83. package/themes/original/src/components/BusinessProductsList/index.tsx +10 -8
  84. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  85. package/themes/original/src/components/BusinessProductsListing/index.tsx +566 -490
  86. package/themes/original/src/components/BusinessProductsListing/styles.tsx +6 -12
  87. package/themes/original/src/components/BusinessTypeFilter/index.tsx +3 -2
  88. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  89. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +115 -82
  90. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -9
  91. package/themes/original/src/components/BusinessesListing/index.tsx +6 -6
  92. package/themes/original/src/components/Cart/index.tsx +90 -43
  93. package/themes/original/src/components/CartContent/index.tsx +77 -15
  94. package/themes/original/src/components/CartContent/styles.tsx +11 -1
  95. package/themes/original/src/components/Checkout/index.tsx +288 -175
  96. package/themes/original/src/components/Checkout/styles.tsx +4 -2
  97. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  98. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  99. package/themes/original/src/components/DriverTips/index.tsx +52 -37
  100. package/themes/original/src/components/DriverTips/styles.tsx +2 -1
  101. package/themes/original/src/components/Favorite/index.tsx +7 -4
  102. package/themes/original/src/components/Favorite/styles.tsx +1 -1
  103. package/themes/original/src/components/FavoriteList/index.tsx +70 -80
  104. package/themes/original/src/components/FloatingButton/index.tsx +1 -2
  105. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  106. package/themes/original/src/components/GPSButton/index.tsx +20 -19
  107. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  108. package/themes/original/src/components/GoogleMap/index.tsx +10 -1
  109. package/themes/original/src/components/Help/index.tsx +8 -8
  110. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +11 -22
  111. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +6 -0
  112. package/themes/original/src/components/HelpGuide/index.tsx +12 -16
  113. package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
  114. package/themes/original/src/components/HelpOrder/index.tsx +12 -25
  115. package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
  116. package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
  117. package/themes/original/src/components/LastOrder/index.tsx +1 -34
  118. package/themes/original/src/components/LoginForm/Otp/index.tsx +89 -73
  119. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  120. package/themes/original/src/components/LoginForm/index.tsx +43 -19
  121. package/themes/original/src/components/LottieAnimation/index.tsx +78 -0
  122. package/themes/original/src/components/MessageListing/index.tsx +16 -42
  123. package/themes/original/src/components/Messages/index.tsx +31 -10
  124. package/themes/original/src/components/MomentOption/index.tsx +195 -88
  125. package/themes/original/src/components/MultiCart/index.tsx +50 -0
  126. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +92 -93
  127. package/themes/original/src/components/MultiCheckout/index.tsx +210 -79
  128. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
  129. package/themes/original/src/components/MultiOrdersDetails/index.tsx +67 -20
  130. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
  131. package/themes/original/src/components/MyOrders/index.tsx +66 -17
  132. package/themes/original/src/components/NavBar/index.tsx +6 -11
  133. package/themes/original/src/components/NetworkError/index.tsx +5 -3
  134. package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
  135. package/themes/original/src/components/Notifications/index.tsx +144 -0
  136. package/themes/original/src/components/Notifications/styles.tsx +20 -0
  137. package/themes/original/src/components/OrderDetails/OrderEta.tsx +59 -0
  138. package/themes/original/src/components/OrderDetails/index.tsx +110 -221
  139. package/themes/original/src/components/OrderDetails/styles.tsx +10 -1
  140. package/themes/original/src/components/OrderItAgain/index.tsx +44 -42
  141. package/themes/original/src/components/OrderProgress/index.tsx +74 -112
  142. package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
  143. package/themes/original/src/components/OrderSummary/index.tsx +52 -17
  144. package/themes/original/src/components/OrderTypeSelector/index.tsx +9 -3
  145. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +29 -20
  146. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +3 -0
  147. package/themes/original/src/components/OrdersOption/index.tsx +76 -83
  148. package/themes/original/src/components/PageBanner/index.tsx +146 -0
  149. package/themes/original/src/components/PageBanner/styles.tsx +11 -0
  150. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
  151. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  152. package/themes/original/src/components/PaymentOptions/index.tsx +2 -2
  153. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  154. package/themes/original/src/components/PlaceSpot/index.tsx +12 -6
  155. package/themes/original/src/components/PreviousOrders/index.tsx +3 -2
  156. package/themes/original/src/components/ProductForm/index.tsx +240 -256
  157. package/themes/original/src/components/ProductForm/styles.tsx +5 -8
  158. package/themes/original/src/components/ProductItemAccordion/index.tsx +199 -128
  159. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -10
  160. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +1 -2
  161. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  162. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -49
  163. package/themes/original/src/components/ProfessionalProfile/index.tsx +54 -14
  164. package/themes/original/src/components/Promotions/index.tsx +234 -220
  165. package/themes/original/src/components/Promotions/styles.tsx +7 -2
  166. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  167. package/themes/original/src/components/ReviewOrder/index.tsx +43 -11
  168. package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
  169. package/themes/original/src/components/ReviewProducts/index.tsx +8 -5
  170. package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
  171. package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
  172. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  173. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  174. package/themes/original/src/components/ServiceForm/index.tsx +377 -270
  175. package/themes/original/src/components/Sessions/index.tsx +11 -8
  176. package/themes/original/src/components/Sessions/styles.tsx +5 -0
  177. package/themes/original/src/components/SignupForm/index.tsx +79 -66
  178. package/themes/original/src/components/SingleOrderCard/index.tsx +126 -57
  179. package/themes/original/src/components/SingleOrderCard/styles.tsx +10 -8
  180. package/themes/original/src/components/SingleProductCard/index.tsx +104 -45
  181. package/themes/original/src/components/SingleProductCard/styles.tsx +14 -13
  182. package/themes/original/src/components/SingleProductReview/index.tsx +38 -5
  183. package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
  184. package/themes/original/src/components/StripeCardsList/index.tsx +1 -1
  185. package/themes/original/src/components/StripeElementsForm/index.tsx +4 -1
  186. package/themes/original/src/components/UpsellingProducts/index.tsx +237 -218
  187. package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
  188. package/themes/original/src/components/UserDetails/index.tsx +8 -4
  189. package/themes/original/src/components/UserFormDetails/index.tsx +53 -54
  190. package/themes/original/src/components/UserProfile/index.tsx +58 -35
  191. package/themes/original/src/components/UserProfile/styles.ts +17 -0
  192. package/themes/original/src/components/UserProfileForm/index.tsx +21 -28
  193. package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
  194. package/themes/original/src/components/Wallets/index.tsx +20 -21
  195. package/themes/original/src/components/Wallets/styles.tsx +2 -0
  196. package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
  197. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  198. package/themes/original/src/components/shared/OBottomPopup.tsx +1 -1
  199. package/themes/original/src/components/shared/OButton.tsx +6 -2
  200. package/themes/original/src/components/shared/OIcon.tsx +8 -1
  201. package/themes/original/src/components/shared/OInput.tsx +10 -1
  202. package/themes/original/src/components/shared/OModal.tsx +3 -3
  203. package/themes/original/src/layouts/Container.tsx +13 -9
  204. package/themes/original/src/types/index.tsx +37 -5
  205. package/themes/original/src/utils/index.tsx +321 -58
  206. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -8,7 +8,7 @@ import {
8
8
  useValidationFields,
9
9
  } from 'ordering-components/native';
10
10
  import { useTheme } from 'styled-components/native';
11
- import { CContainer, CheckoutAction, Divider, DriverTipsContainer } from './styles';
11
+ import { CContainer, CheckoutAction, DriverTipsContainer } from './styles';
12
12
 
13
13
  import { OSBill, OSTable, OSCoupon, OSTotal, OSRow } from '../OrderSummary/styles';
14
14
 
@@ -41,7 +41,16 @@ const CartUI = (props: any) => {
41
41
  commentState,
42
42
  onNavigationRedirect,
43
43
  handleRemoveOfferClick,
44
- isMultiCheckout
44
+ isMultiCheckout,
45
+ hideDeliveryFee,
46
+ hideDriverTip,
47
+ hideCouponInput,
48
+ preorderSlotInterval,
49
+ preorderLeadTime,
50
+ preorderTimeRange,
51
+ preorderMaximumDays,
52
+ preorderMinimumDays,
53
+ cateringTypes
45
54
  } = props
46
55
 
47
56
  const theme = useTheme();
@@ -61,13 +70,12 @@ const CartUI = (props: any) => {
61
70
 
62
71
  const isCartPending = cart?.status === 2
63
72
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
64
- const isCheckoutMultiBusinessEnabled: Boolean = configs?.checkout_multi_business_enabled?.value === '1'
65
- const openCarts = (Object.values(orderState?.carts)?.filter((cart: any) => cart?.products && cart?.products?.length && cart?.status !== 2 && cart?.valid_schedule && cart?.valid_products && cart?.valid_address && cart?.valid_maximum && cart?.valid_minimum && !cart?.wallets) || null) || []
66
-
67
73
  const business: any = (orderState?.carts && Object.values(orderState.carts).find((_cart: any) => _cart?.uuid === props.cartuuid)) ?? {}
68
74
  const businessId = business?.business_id ?? null
69
75
  const placeSpotTypes = [4]
70
-
76
+ const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
77
+ const hideCartComments = theme?.business_view?.components?.cart?.components?.comments?.hidden
78
+ const hideCartDiscount = theme?.business_view?.components?.cart?.components?.discount?.hidden
71
79
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
72
80
  ? JSON.parse(configs?.driver_tip_options?.value) || []
73
81
  : configs?.driver_tip_options?.value || []
@@ -101,21 +109,45 @@ const CartUI = (props: any) => {
101
109
  }
102
110
  }
103
111
 
104
- const handleUpsellingPage = () => {
112
+ const handleUpsellingPage = (individualCart : any) => {
113
+ const isProductCartParam = !!individualCart?.products?.length
105
114
  setOpenUpselling(false)
106
115
  setCanOpenUpselling(false)
107
- if (isCheckoutMultiBusinessEnabled && openCarts.length > 1) {
108
- props.onNavigationRedirect('CheckoutNavigator', {
109
- screen: 'MultiCheckout'
110
- })
111
- } else {
112
- props.onNavigationRedirect('CheckoutNavigator', {
116
+
117
+ const cartsAvailable: any = Object.values(orderState?.carts)
118
+ ?.filter((_cart: any) => _cart?.valid && _cart?.status !== 2 && _cart?.products?.length)
119
+ ?.filter((_c: any) => !isProductCartParam ? _c.uuid !== individualCart?.uuid : _c)
120
+ if (cartsAvailable.length === 1 || !isMultiCheckout) {
121
+ const cart = isMultiCheckout ? cartsAvailable[0] : individualCart
122
+ onNavigationRedirect('CheckoutNavigator', {
113
123
  screen: 'CheckoutPage',
114
124
  cartUuid: cart?.uuid,
115
125
  businessLogo: cart?.business?.logo,
116
126
  businessName: cart?.business?.name,
117
127
  cartTotal: cart?.total
128
+ }, true)
129
+ } else {
130
+ const groupKeys: any = {}
131
+ cartsAvailable.forEach((_cart: any) => {
132
+ groupKeys[_cart?.group?.uuid]
133
+ ? groupKeys[_cart?.group?.uuid] += 1
134
+ : groupKeys[_cart?.group?.uuid ?? 'null'] = 1
118
135
  })
136
+
137
+ if (
138
+ (Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
139
+ Object.keys(groupKeys).length > 1
140
+ ) {
141
+ onNavigationRedirect('CheckoutNavigator', {
142
+ screen: 'MultiCheckout',
143
+ checkCarts: true
144
+ }, true)
145
+ } else {
146
+ onNavigationRedirect('CheckoutNavigator', {
147
+ screen: 'MultiCheckout',
148
+ cartUuid: cartsAvailable[0]?.group?.uuid
149
+ }, true)
150
+ }
119
151
  }
120
152
  }
121
153
 
@@ -154,6 +186,12 @@ const CartUI = (props: any) => {
154
186
  }
155
187
  }
156
188
 
189
+ const subtotalWithTaxes = cart?.taxes?.reduce((acc: any, item: any) => {
190
+ if (item?.type === 1)
191
+ return acc = acc + item?.summary?.tax
192
+ return acc = acc
193
+ }, cart?.subtotal)
194
+
157
195
  return (
158
196
  <CContainer>
159
197
  {openUpselling && (
@@ -178,7 +216,7 @@ const CartUI = (props: any) => {
178
216
  onNavigationRedirect={props.onNavigationRedirect}
179
217
  handleChangeStore={() => setOpenChangeStore(true)}
180
218
  handleClickCheckout={() => setOpenUpselling(true)}
181
- checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
219
+ checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
182
220
  isMultiCheckout={isMultiCheckout}
183
221
  >
184
222
  {cart?.products?.length > 0 && cart?.products.map((product: any, i: number) => (
@@ -291,9 +329,11 @@ const CartUI = (props: any) => {
291
329
  <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
292
330
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
293
331
  </TouchableOpacity>
294
- <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
295
- <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
296
- </TouchableOpacity>
332
+ {!offer?.type && (
333
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
334
+ <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
335
+ </TouchableOpacity>
336
+ )}
297
337
  </OSRow>
298
338
  <OText size={12} lineHeight={18}>
299
339
  - {parsePrice(offer?.summary?.discount)}
@@ -301,10 +341,10 @@ const CartUI = (props: any) => {
301
341
  </OSTable>
302
342
  ))
303
343
  }
304
- {orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
344
+ {orderState?.options?.type === 1 && cart?.delivery_price > 0 && !hideDeliveryFee && (
305
345
  <OSTable>
306
346
  <OText size={12} lineHeight={18}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
307
- <OText size={12} lineHeight={18}>{parsePrice(cart?.delivery_price)}</OText>
347
+ <OText size={12} lineHeight={18}>{parsePrice(cart?.delivery_price_with_discount ?? cart?.delivery_price)}</OText>
308
348
  </OSTable>
309
349
  )}
310
350
  {
@@ -328,7 +368,13 @@ const CartUI = (props: any) => {
328
368
  </OSTable>
329
369
  ))
330
370
  }
331
- {cart?.driver_tip > 0 && (
371
+ {orderState?.options?.type === 1 && cart?.delivery_price > 0 && cart?.delivery_price_with_discount >= 0 && !hideDeliveryFee && isChewLayout && (
372
+ <OSTable>
373
+ <OText size={12} lineHeight={18}>{t('DELIVERY_FEE_AFTER_DISCOUNT', 'Delivery Fee After Discount')}</OText>
374
+ <OText size={12} lineHeight={18}>{parsePrice(cart?.delivery_price_with_discount)}</OText>
375
+ </OSTable>
376
+ )}
377
+ {cart?.driver_tip > 0 && !hideDriverTip && (
332
378
  <OSTable>
333
379
  <OText size={12} lineHeight={18}>
334
380
  {t('DRIVER_TIP', 'Driver tip')}
@@ -350,7 +396,7 @@ const CartUI = (props: any) => {
350
396
  <OText size={12}>-{parsePrice(event.amount, { isTruncable: true })}</OText>
351
397
  </OSTable>
352
398
  ))}
353
- {isCouponEnabled && !isCartPending && (
399
+ {isCouponEnabled && !isCartPending && !hideCouponInput && (
354
400
  <OSTable>
355
401
  <OSCoupon>
356
402
  <CouponControl
@@ -361,7 +407,7 @@ const CartUI = (props: any) => {
361
407
  </OSTable>
362
408
  )}
363
409
 
364
- {isMultiCheckout &&
410
+ {!isMultiCheckout &&
365
411
  cart &&
366
412
  cart?.valid &&
367
413
  orderState?.options?.type === 1 &&
@@ -369,30 +415,31 @@ const CartUI = (props: any) => {
369
415
  validationFields?.fields?.checkout?.driver_tip?.enabled &&
370
416
  driverTipsOptions && driverTipsOptions?.length > 0 &&
371
417
  (
372
- <DriverTipsContainer>
373
- <OText size={14} lineHeight={20} color={theme.colors.textNormal}>
374
- {t('DRIVER_TIPS', 'Driver Tips')}
375
- </OText>
376
- <DriverTips
377
- uuid={cart?.uuid}
378
- businessId={cart?.business_id}
379
- driverTipsOptions={driverTipsOptions}
380
- isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)}
381
- isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
382
- driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)
383
- ? cart?.driver_tip
384
- : cart?.driver_tip_rate}
385
- useOrderContext
386
- />
387
- </DriverTipsContainer>
418
+ <DriverTipsContainer>
419
+ <OText size={14} lineHeight={20} color={theme.colors.textNormal}>
420
+ {t('DRIVER_TIPS', 'Driver Tips')}
421
+ </OText>
422
+ <DriverTips
423
+ uuid={cart?.uuid}
424
+ businessId={cart?.business_id}
425
+ driverTipsOptions={!driverTipsOptions.includes(0) ? [0, ...driverTipsOptions] : driverTipsOptions}
426
+ isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1}
427
+ isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
428
+ driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1
429
+ ? cart?.driver_tip
430
+ : cart?.driver_tip_rate}
431
+ useOrderContext
432
+ cart={cart}
433
+ />
434
+ </DriverTipsContainer>
388
435
  )}
389
436
 
390
437
  <OSTotal>
391
438
  <OSTable style={{ marginTop: 15 }}>
392
- <OText size={14} lineHeight={21} weight={'600'}>
439
+ <OText size={14} lineHeight={21} weight={'bold'} color={theme.colors.textNormal}>
393
440
  {t('TOTAL', 'Total')}
394
441
  </OText>
395
- <OText size={14} lineHeight={21} weight={'600'}>
442
+ <OText size={14} lineHeight={21} weight={'bold'} color={theme.colors.textNormal}>
396
443
  {parsePrice(cart?.balance >= 0 ? cart?.balance : 0)}
397
444
  </OText>
398
445
  </OSTable>
@@ -455,15 +502,15 @@ const CartUI = (props: any) => {
455
502
  {cart?.valid_products ? (
456
503
  <CheckoutAction>
457
504
  <OButton
458
- text={(cart?.subtotal >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
505
+ text={(subtotalWithTaxes >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
459
506
  !openUpselling !== canOpenUpselling ? t('CHECKOUT', 'Checkout') : t('LOADING', 'Loading')
460
507
  ) : !cart?.valid_address ? (
461
508
  `${t('OUT_OF_COVERAGE', 'Out of Coverage')}`
462
509
  ) : (
463
510
  `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`
464
511
  )}
465
- bgColor={(cart?.subtotal < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
466
- isDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
512
+ bgColor={(subtotalWithTaxes < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
513
+ isDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
467
514
  borderColor={theme.colors.primary}
468
515
  imgRightSrc={null}
469
516
  textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
@@ -1,30 +1,69 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { useLanguage, useOrder } from 'ordering-components/native';
1
+ import React, { useState } from 'react';
2
+ import { View } from 'react-native';
3
+ import { useLanguage, useConfig } from 'ordering-components/native';
3
4
  import { useTheme } from 'styled-components/native';
4
- import { CCContainer, CCNotCarts, CCList } from './styles';
5
+ import { CCContainer, CCNotCarts, CCList, CheckoutAction } from './styles';
5
6
 
6
7
  import { Cart } from '../Cart';
7
- import { OIcon, OText } from '../shared';
8
+ import { OButton, OText } from '../shared';
8
9
  import Spinner from 'react-native-loading-spinner-overlay';
9
- import { View } from 'react-native';
10
10
 
11
11
  export const CartContent = (props: any) => {
12
12
  const {
13
13
  carts,
14
- isOrderStateCarts
14
+ isOrderStateCarts,
15
+ onNavigationRedirect
15
16
  } = props
16
17
 
17
18
  const theme = useTheme();
18
19
  const [, t] = useLanguage()
20
+ const [{ configs }] = useConfig()
19
21
  const [isCartsLoading, setIsCartsLoading] = useState(false)
20
22
 
23
+ const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
24
+ const isMultiCheckout = configs?.checkout_multi_business_enabled?.value === '1'
25
+ const cartsAvailable: any = Object.values(carts)?.filter((cart: any) => cart?.valid && cart?.status !== 2)
26
+
27
+ const handleCheckoutRedirect = () => {
28
+ if (cartsAvailable.length === 1) {
29
+ onNavigationRedirect('CheckoutNavigator', {
30
+ screen: 'CheckoutPage',
31
+ cartUuid: cartsAvailable[0]?.uuid,
32
+ businessLogo: cartsAvailable[0]?.business?.logo,
33
+ businessName: cartsAvailable[0]?.business?.name,
34
+ cartTotal: cartsAvailable[0]?.total
35
+ })
36
+ } else {
37
+ const groupKeys: any = {}
38
+ cartsAvailable.forEach((_cart: any) => {
39
+ groupKeys[_cart?.group?.uuid]
40
+ ? groupKeys[_cart?.group?.uuid] += 1
41
+ : groupKeys[_cart?.group?.uuid ?? 'null'] = 1
42
+ })
43
+
44
+ if (
45
+ (Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
46
+ Object.keys(groupKeys).length > 1
47
+ ) {
48
+ onNavigationRedirect('CheckoutNavigator', {
49
+ screen: 'MultiCheckout',
50
+ checkCarts: true
51
+ })
52
+ } else {
53
+ onNavigationRedirect('CheckoutNavigator', {
54
+ screen: 'MultiCheckout',
55
+ cartUuid: cartsAvailable[0]?.group?.uuid
56
+ })
57
+ }
58
+ }
59
+ }
60
+
21
61
  return (
22
- <CCContainer>
62
+ <CCContainer
63
+ style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}
64
+ >
23
65
  {isOrderStateCarts && carts?.length > 0 && (
24
66
  <>
25
- {/* <OText size={24} lineHeight={36} weight={'600'} style={{ marginBottom: 20 }}>
26
- {carts.length > 1 ? t('MY_CARTS', 'My Carts') : t('CART', 'Cart')}
27
- </OText> */}
28
67
  {carts.map((cart: any, i: number) => (
29
68
  <CCList key={i} style={{ overflow: 'visible' }}>
30
69
  {cart.products.length > 0 && (
@@ -37,6 +76,7 @@ export const CartContent = (props: any) => {
37
76
  onNavigationRedirect={props.onNavigationRedirect}
38
77
  isCartsLoading={isCartsLoading}
39
78
  setIsCartsLoading={setIsCartsLoading}
79
+ isMultiCheckout={isMultiCheckout}
40
80
  hideUpselling
41
81
  />
42
82
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40, marginTop: 20 }} />
@@ -44,18 +84,40 @@ export const CartContent = (props: any) => {
44
84
  )}
45
85
  </CCList>
46
86
  ))}
87
+ {isMultiCheckout && (
88
+ <CheckoutAction style={{ marginTop: 0 }}>
89
+ <OButton
90
+ text={t('CHECKOUT', 'Checkout')}
91
+ bgColor={!cartsAvailable.length ? theme.colors.secundary : theme.colors.primary}
92
+ isDisabled={!cartsAvailable.length}
93
+ borderColor={theme.colors.primary}
94
+ imgRightSrc={null}
95
+ textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
96
+ onClick={() => handleCheckoutRedirect()}
97
+ style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
98
+ />
99
+ </CheckoutAction>
100
+ )}
47
101
  </>
48
102
  )}
49
103
  {(!carts || carts?.length === 0) && (
50
104
  <CCNotCarts>
51
- {/* <OIcon
52
- url={props.icon}
53
- width={200}
54
- height={122}
55
- /> */}
56
105
  <OText size={24} style={{ textAlign: 'center' }}>
57
106
  {t('CARTS_NOT_FOUND', 'You don\'t have carts available')}
58
107
  </OText>
108
+ <OButton
109
+ text={t('START_SHOPPING', 'Start shopping')}
110
+ bgColor={theme.colors.primary}
111
+ borderColor={theme.colors.primary}
112
+ textStyle={{
113
+ color: theme.colors.white,
114
+ fontSize: 14,
115
+ paddingRight: 0
116
+ }}
117
+ style={{ height: 35, marginVertical: 20, borderRadius: 8 }}
118
+ imgRightSrc={null}
119
+ onClick={() => onNavigationRedirect('BusinessList')}
120
+ />
59
121
  </CCNotCarts>
60
122
  )}
61
123
  <Spinner visible={isCartsLoading} />
@@ -1,7 +1,7 @@
1
1
  import styled from 'styled-components/native';
2
2
 
3
3
  export const CCContainer = styled.View`
4
- padding: 20px 40px;
4
+ padding-vertical: 20px;
5
5
  `
6
6
 
7
7
  export const CCNotCarts = styled.View`
@@ -17,3 +17,13 @@ export const CCNotCarts = styled.View`
17
17
  export const CCList = styled.ScrollView`
18
18
  padding: 10px 0px;
19
19
  `
20
+
21
+ export const CheckoutAction = styled.View`
22
+ width: 100%;
23
+ display: flex;
24
+ justify-content: center;
25
+ flex-direction: column;
26
+ align-items: center;
27
+ margin-top: 10px;
28
+ margin-bottom: 10px;
29
+ `