ordering-ui-react-native 0.17.36 → 0.17.37-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 (215) hide show
  1. package/package.json +8 -7
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessesListing/index.tsx +1 -1
  4. package/src/components/OrderCreating/index.tsx +1 -21
  5. package/src/components/PaymentOptionsWebView/index.tsx +29 -8
  6. package/src/components/StripeMethodForm/index.tsx +108 -79
  7. package/src/components/VerifyPhone/styles.tsx +1 -2
  8. package/src/components/shared/OToast.tsx +4 -4
  9. package/src/types/index.tsx +5 -0
  10. package/src/utils/index.tsx +7 -1
  11. package/themes/business/index.tsx +2 -0
  12. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +265 -240
  13. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
  14. package/themes/business/src/components/BusinessController/index.tsx +0 -1
  15. package/themes/business/src/components/Chat/index.tsx +118 -107
  16. package/themes/business/src/components/DriverMap/index.tsx +17 -6
  17. package/themes/business/src/components/GoogleMap/index.tsx +58 -57
  18. package/themes/business/src/components/LoginForm/Otp/index.tsx +120 -0
  19. package/themes/business/src/components/LoginForm/Otp/styles.tsx +7 -0
  20. package/themes/business/src/components/LoginForm/index.tsx +238 -80
  21. package/themes/business/src/components/LoginForm/styles.tsx +10 -0
  22. package/themes/business/src/components/MapView/index.tsx +10 -10
  23. package/themes/business/src/components/NewOrderNotification/index.tsx +43 -50
  24. package/themes/business/src/components/OrderDetails/Delivery.tsx +4 -3
  25. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +90 -47
  26. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +59 -62
  27. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +195 -0
  28. package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
  29. package/themes/business/src/components/OrderMessage/index.tsx +18 -17
  30. package/themes/business/src/components/OrderSummary/index.tsx +113 -121
  31. package/themes/business/src/components/OrdersOption/index.tsx +32 -75
  32. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
  33. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
  34. package/themes/business/src/components/PreviousOrders/index.tsx +445 -243
  35. package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
  36. package/themes/business/src/components/ProductItemAccordion/index.tsx +27 -3
  37. package/themes/business/src/components/ReviewCustomer/index.tsx +41 -24
  38. package/themes/business/src/components/StoresList/index.tsx +2 -2
  39. package/themes/business/src/components/shared/OLink.tsx +33 -13
  40. package/themes/business/src/components/shared/OModal.tsx +16 -9
  41. package/themes/business/src/components/shared/OText.tsx +8 -2
  42. package/themes/business/src/types/index.tsx +32 -2
  43. package/themes/business/src/utils/index.tsx +44 -1
  44. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  45. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  46. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  47. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -1
  48. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  49. package/themes/kiosk/src/components/LoginForm/Otp/index.tsx +92 -0
  50. package/themes/kiosk/src/components/LoginForm/Otp/styles.tsx +7 -0
  51. package/themes/kiosk/src/components/LoginForm/index.tsx +473 -151
  52. package/themes/kiosk/src/components/LoginForm/styles.tsx +14 -1
  53. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  54. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  55. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  56. package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +3 -2
  57. package/themes/kiosk/src/components/PhoneInputNumber/styles.tsx +1 -3
  58. package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
  59. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  60. package/themes/kiosk/src/components/shared/OModal.tsx +14 -11
  61. package/themes/kiosk/src/layouts/Container.tsx +7 -1
  62. package/themes/kiosk/src/types/index.d.ts +13 -0
  63. package/themes/kiosk/src/utils/index.tsx +15 -0
  64. package/themes/original/index.tsx +6 -0
  65. package/themes/original/src/components/AddressDetails/index.tsx +29 -11
  66. package/themes/original/src/components/AddressForm/index.tsx +85 -49
  67. package/themes/original/src/components/AddressList/index.tsx +26 -21
  68. package/themes/original/src/components/AddressList/styles.tsx +4 -2
  69. package/themes/original/src/components/AnalyticsSegment/index.tsx +193 -10
  70. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  71. package/themes/original/src/components/BusinessBasicInformation/index.tsx +159 -90
  72. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +9 -7
  73. package/themes/original/src/components/BusinessController/index.tsx +154 -68
  74. package/themes/original/src/components/BusinessController/styles.tsx +22 -9
  75. package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
  76. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
  77. package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
  78. package/themes/original/src/components/BusinessItemAccordion/index.tsx +23 -22
  79. package/themes/original/src/components/BusinessListingSearch/index.tsx +351 -326
  80. package/themes/original/src/components/BusinessPreorder/index.tsx +97 -16
  81. package/themes/original/src/components/BusinessProductsList/index.tsx +20 -11
  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 -524
  85. package/themes/original/src/components/BusinessProductsListing/styles.tsx +4 -6
  86. package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
  87. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  88. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +106 -79
  89. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -9
  90. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  91. package/themes/original/src/components/Cart/index.tsx +102 -69
  92. package/themes/original/src/components/CartContent/index.tsx +115 -19
  93. package/themes/original/src/components/CartContent/styles.tsx +17 -7
  94. package/themes/original/src/components/Checkout/index.tsx +375 -179
  95. package/themes/original/src/components/Checkout/styles.tsx +4 -2
  96. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  97. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  98. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  99. package/themes/original/src/components/DriverTips/index.tsx +52 -34
  100. package/themes/original/src/components/Favorite/index.tsx +7 -4
  101. package/themes/original/src/components/Favorite/styles.tsx +1 -1
  102. package/themes/original/src/components/FavoriteList/index.tsx +51 -80
  103. package/themes/original/src/components/FloatingButton/index.tsx +1 -2
  104. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  105. package/themes/original/src/components/GPSButton/index.tsx +6 -4
  106. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  107. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +96 -0
  108. package/themes/original/src/components/GiftCard/GiftCardUI/styles.tsx +5 -0
  109. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +100 -0
  110. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +8 -0
  111. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +191 -0
  112. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +8 -0
  113. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +165 -0
  114. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +9 -0
  115. package/themes/original/src/components/GoogleMap/index.tsx +15 -4
  116. package/themes/original/src/components/Help/index.tsx +8 -8
  117. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +11 -22
  118. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +6 -0
  119. package/themes/original/src/components/HelpGuide/index.tsx +12 -16
  120. package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
  121. package/themes/original/src/components/HelpOrder/index.tsx +12 -25
  122. package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
  123. package/themes/original/src/components/Home/index.tsx +13 -4
  124. package/themes/original/src/components/LastOrder/index.tsx +1 -34
  125. package/themes/original/src/components/LoginForm/Otp/index.tsx +139 -75
  126. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  127. package/themes/original/src/components/LoginForm/index.tsx +71 -28
  128. package/themes/original/src/components/LottieAnimation/index.tsx +103 -0
  129. package/themes/original/src/components/MessageListing/index.tsx +16 -42
  130. package/themes/original/src/components/Messages/index.tsx +32 -10
  131. package/themes/original/src/components/MomentOption/index.tsx +195 -88
  132. package/themes/original/src/components/MultiCart/index.tsx +50 -0
  133. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +219 -117
  134. package/themes/original/src/components/MultiCheckout/index.tsx +298 -88
  135. package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
  136. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
  137. package/themes/original/src/components/MultiOrdersDetails/index.tsx +68 -21
  138. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
  139. package/themes/original/src/components/MyOrders/index.tsx +53 -51
  140. package/themes/original/src/components/NavBar/index.tsx +18 -18
  141. package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
  142. package/themes/original/src/components/Notifications/index.tsx +46 -50
  143. package/themes/original/src/components/Notifications/styles.tsx +6 -3
  144. package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
  145. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +15 -3
  146. package/themes/original/src/components/OrderDetails/index.tsx +199 -359
  147. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  148. package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
  149. package/themes/original/src/components/OrderProgress/index.tsx +93 -114
  150. package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
  151. package/themes/original/src/components/OrderSummary/index.tsx +87 -59
  152. package/themes/original/src/components/OrderTypeSelector/index.tsx +1 -1
  153. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +24 -19
  154. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +14 -14
  155. package/themes/original/src/components/OrdersOption/index.tsx +70 -65
  156. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  157. package/themes/original/src/components/PageBanner/index.tsx +171 -0
  158. package/themes/original/src/components/PageBanner/styles.tsx +11 -0
  159. package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
  160. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
  161. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  162. package/themes/original/src/components/PaymentOptions/index.tsx +64 -7
  163. package/themes/original/src/components/PhoneInputNumber/index.tsx +3 -3
  164. package/themes/original/src/components/PlaceSpot/index.tsx +12 -6
  165. package/themes/original/src/components/ProductForm/index.tsx +223 -232
  166. package/themes/original/src/components/ProductForm/styles.tsx +5 -8
  167. package/themes/original/src/components/ProductItemAccordion/index.tsx +59 -29
  168. package/themes/original/src/components/ProductOptionSubOption/index.tsx +19 -11
  169. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +1 -2
  170. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  171. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
  172. package/themes/original/src/components/ProfessionalProfile/index.tsx +36 -7
  173. package/themes/original/src/components/Promotions/index.tsx +234 -220
  174. package/themes/original/src/components/Promotions/styles.tsx +10 -3
  175. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  176. package/themes/original/src/components/ReviewOrder/index.tsx +26 -9
  177. package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
  178. package/themes/original/src/components/ReviewProducts/index.tsx +23 -11
  179. package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
  180. package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
  181. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  182. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  183. package/themes/original/src/components/ServiceForm/index.tsx +74 -19
  184. package/themes/original/src/components/Sessions/index.tsx +11 -8
  185. package/themes/original/src/components/Sessions/styles.tsx +5 -0
  186. package/themes/original/src/components/SignupForm/index.tsx +42 -19
  187. package/themes/original/src/components/SingleOrderCard/index.tsx +156 -65
  188. package/themes/original/src/components/SingleOrderCard/styles.tsx +11 -9
  189. package/themes/original/src/components/SingleProductCard/index.tsx +100 -56
  190. package/themes/original/src/components/SingleProductCard/styles.tsx +22 -13
  191. package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
  192. package/themes/original/src/components/StripeCardsList/index.tsx +13 -3
  193. package/themes/original/src/components/StripeElementsForm/index.tsx +28 -15
  194. package/themes/original/src/components/UpsellingProducts/index.tsx +238 -224
  195. package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
  196. package/themes/original/src/components/UserDetails/index.tsx +8 -4
  197. package/themes/original/src/components/UserFormDetails/index.tsx +47 -7
  198. package/themes/original/src/components/UserProfile/index.tsx +5 -7
  199. package/themes/original/src/components/UserProfileForm/index.tsx +25 -28
  200. package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
  201. package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
  202. package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
  203. package/themes/original/src/components/Wallets/index.tsx +79 -36
  204. package/themes/original/src/components/Wallets/styles.tsx +5 -4
  205. package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
  206. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  207. package/themes/original/src/components/shared/OBottomPopup.tsx +1 -1
  208. package/themes/original/src/components/shared/OButton.tsx +6 -2
  209. package/themes/original/src/components/shared/OIcon.tsx +8 -1
  210. package/themes/original/src/components/shared/OInput.tsx +16 -2
  211. package/themes/original/src/components/shared/OModal.tsx +3 -3
  212. package/themes/original/src/layouts/Container.tsx +13 -9
  213. package/themes/original/src/types/index.tsx +38 -9
  214. package/themes/original/src/utils/index.tsx +364 -58
  215. 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
 
@@ -23,7 +23,7 @@ import { ActivityIndicator, TouchableOpacity, View } from 'react-native';
23
23
  import AntIcon from 'react-native-vector-icons/AntDesign'
24
24
  import { TaxInformation } from '../TaxInformation';
25
25
  import { CartStoresListing } from '../CartStoresListing';
26
- import { OAlert } from '../../../../../src/components/shared'
26
+ import { OAlert } from '../shared'
27
27
  import { PlaceSpot } from '../PlaceSpot'
28
28
  import { DriverTips } from '../DriverTips'
29
29
 
@@ -41,7 +41,17 @@ 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,
54
+ isFromUpselling
45
55
  } = props
46
56
 
47
57
  const theme = useTheme();
@@ -56,18 +66,15 @@ const CartUI = (props: any) => {
56
66
  const [openChangeStore, setOpenChangeStore] = useState(false)
57
67
  const [canOpenUpselling, setCanOpenUpselling] = useState(false)
58
68
  const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null, type: '' })
59
- const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
60
69
  const [openPlaceModal, setOpenPlaceModal] = useState(false)
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 hideCartComments = theme?.business_view?.components?.cart?.components?.comments?.hidden
77
+ const hideCartDiscount = theme?.business_view?.components?.cart?.components?.discount?.hidden
71
78
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
72
79
  ? JSON.parse(configs?.driver_tip_options?.value) || []
73
80
  : configs?.driver_tip_options?.value || []
@@ -101,21 +108,45 @@ const CartUI = (props: any) => {
101
108
  }
102
109
  }
103
110
 
104
- const handleUpsellingPage = () => {
111
+ const handleUpsellingPage = (individualCart : any) => {
112
+ const isProductCartParam = !!individualCart?.products?.length
105
113
  setOpenUpselling(false)
106
114
  setCanOpenUpselling(false)
107
- if (isCheckoutMultiBusinessEnabled && openCarts.length > 1) {
108
- props.onNavigationRedirect('CheckoutNavigator', {
109
- screen: 'MultiCheckout'
110
- })
111
- } else {
112
- props.onNavigationRedirect('CheckoutNavigator', {
115
+
116
+ const cartsAvailable: any = Object.values(orderState?.carts)
117
+ ?.filter((_cart: any) => _cart?.valid && _cart?.status !== 2 && _cart?.products?.length)
118
+ ?.filter((_c: any) => !isProductCartParam ? _c.uuid !== individualCart?.uuid : _c)
119
+ if (cartsAvailable.length === 1 || !isMultiCheckout) {
120
+ const cart = isMultiCheckout ? cartsAvailable[0] : individualCart
121
+ onNavigationRedirect('CheckoutNavigator', {
113
122
  screen: 'CheckoutPage',
114
123
  cartUuid: cart?.uuid,
115
124
  businessLogo: cart?.business?.logo,
116
125
  businessName: cart?.business?.name,
117
126
  cartTotal: cart?.total
127
+ }, true)
128
+ } else {
129
+ const groupKeys: any = {}
130
+ cartsAvailable.forEach((_cart: any) => {
131
+ groupKeys[_cart?.group?.uuid]
132
+ ? groupKeys[_cart?.group?.uuid] += 1
133
+ : groupKeys[_cart?.group?.uuid ?? 'null'] = 1
118
134
  })
135
+
136
+ if (
137
+ (Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
138
+ Object.keys(groupKeys).length > 1
139
+ ) {
140
+ onNavigationRedirect('CheckoutNavigator', {
141
+ screen: 'MultiCheckout',
142
+ checkCarts: true
143
+ }, true)
144
+ } else {
145
+ onNavigationRedirect('CheckoutNavigator', {
146
+ screen: 'MultiCheckout',
147
+ cartUuid: cartsAvailable[0]?.group?.uuid
148
+ }, true)
149
+ }
119
150
  }
120
151
  }
121
152
 
@@ -133,16 +164,16 @@ const CartUI = (props: any) => {
133
164
  return cart?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
134
165
  }
135
166
 
136
- const onRemoveOffer = (id: number) => {
137
- setConfirm({
138
- open: true,
139
- content: [t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')],
140
- title: t('OFFER', 'Offer'),
141
- handleOnAccept: () => {
142
- setConfirm({ ...confirm, open: false })
143
- handleRemoveOfferClick(id)
144
- }
145
- })
167
+ const OfferAlert = ({ offerId }: any) => {
168
+ return (
169
+ <OAlert
170
+ title={t('OFFER', 'Offer')}
171
+ message={t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')}
172
+ onAccept={() => handleRemoveOfferClick(offerId)}
173
+ >
174
+ <AntIcon style={{ marginLeft: 3 }} name='closecircle' size={16} color={theme.colors.primary} />
175
+ </OAlert>
176
+ )
146
177
  }
147
178
 
148
179
  const walletName: any = {
@@ -154,6 +185,12 @@ const CartUI = (props: any) => {
154
185
  }
155
186
  }
156
187
 
188
+ const subtotalWithTaxes = cart?.taxes?.reduce((acc: any, item: any) => {
189
+ if (item?.type === 1)
190
+ return acc = acc + item?.summary?.tax
191
+ return acc = acc
192
+ }, cart?.subtotal)
193
+
157
194
  return (
158
195
  <CContainer>
159
196
  {openUpselling && (
@@ -178,14 +215,16 @@ const CartUI = (props: any) => {
178
215
  onNavigationRedirect={props.onNavigationRedirect}
179
216
  handleChangeStore={() => setOpenChangeStore(true)}
180
217
  handleClickCheckout={() => setOpenUpselling(true)}
181
- checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
218
+ checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
182
219
  isMultiCheckout={isMultiCheckout}
220
+ isFromUpselling={isFromUpselling}
183
221
  >
184
222
  {cart?.products?.length > 0 && cart?.products.map((product: any, i: number) => (
185
223
  <ProductItemAccordion
186
224
  key={`${product.code}_${i}`}
187
225
  isCartPending={isCartPending}
188
226
  isCartProduct
227
+ isDisabledEdit={!cart?.business_id}
189
228
  product={product}
190
229
  changeQuantity={changeQuantity}
191
230
  getProductMax={getProductMax}
@@ -227,9 +266,9 @@ const CartUI = (props: any) => {
227
266
  <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
228
267
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
229
268
  </TouchableOpacity>
230
- <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
231
- <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
232
- </TouchableOpacity>
269
+ {!!offer?.id && (
270
+ <OfferAlert offerId={offer?.id} />
271
+ )}
233
272
  </OSRow>
234
273
  <OText size={12} lineHeight={18}>
235
274
  - {parsePrice(offer?.summary?.discount)}
@@ -291,9 +330,9 @@ const CartUI = (props: any) => {
291
330
  <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
292
331
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
293
332
  </TouchableOpacity>
294
- <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
295
- <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
296
- </TouchableOpacity>
333
+ {!!offer?.id && (
334
+ <OfferAlert offerId={offer?.id} />
335
+ )}
297
336
  </OSRow>
298
337
  <OText size={12} lineHeight={18}>
299
338
  - {parsePrice(offer?.summary?.discount)}
@@ -301,10 +340,10 @@ const CartUI = (props: any) => {
301
340
  </OSTable>
302
341
  ))
303
342
  }
304
- {orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
343
+ {orderState?.options?.type === 1 && cart?.delivery_price_with_discount > 0 && !hideDeliveryFee && (
305
344
  <OSTable>
306
345
  <OText size={12} lineHeight={18}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
307
- <OText size={12} lineHeight={18}>{parsePrice(cart?.delivery_price)}</OText>
346
+ <OText size={12} lineHeight={18}>{parsePrice(cart?.delivery_price_with_discount)}</OText>
308
347
  </OSTable>
309
348
  )}
310
349
  {
@@ -318,9 +357,9 @@ const CartUI = (props: any) => {
318
357
  <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
319
358
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
320
359
  </TouchableOpacity>
321
- <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
322
- <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
323
- </TouchableOpacity>
360
+ {!!offer?.id && (
361
+ <OfferAlert offerId={offer?.id} />
362
+ )}
324
363
  </OSRow>
325
364
  <OText size={12} lineHeight={18}>
326
365
  - {parsePrice(offer?.summary?.discount)}
@@ -328,7 +367,7 @@ const CartUI = (props: any) => {
328
367
  </OSTable>
329
368
  ))
330
369
  }
331
- {cart?.driver_tip > 0 && (
370
+ {cart?.driver_tip > 0 && !hideDriverTip && (
332
371
  <OSTable>
333
372
  <OText size={12} lineHeight={18}>
334
373
  {t('DRIVER_TIP', 'Driver tip')}
@@ -350,18 +389,19 @@ const CartUI = (props: any) => {
350
389
  <OText size={12}>-{parsePrice(event.amount, { isTruncable: true })}</OText>
351
390
  </OSTable>
352
391
  ))}
353
- {isCouponEnabled && !isCartPending && (
392
+ {isCouponEnabled && !isCartPending && !hideCouponInput && (
354
393
  <OSTable>
355
394
  <OSCoupon>
356
395
  <CouponControl
357
396
  businessId={businessId}
358
397
  price={cart.total}
398
+ cart={cart}
359
399
  />
360
400
  </OSCoupon>
361
401
  </OSTable>
362
402
  )}
363
403
 
364
- {isMultiCheckout &&
404
+ {!isMultiCheckout &&
365
405
  cart &&
366
406
  cart?.valid &&
367
407
  orderState?.options?.type === 1 &&
@@ -369,30 +409,31 @@ const CartUI = (props: any) => {
369
409
  validationFields?.fields?.checkout?.driver_tip?.enabled &&
370
410
  driverTipsOptions && driverTipsOptions?.length > 0 &&
371
411
  (
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>
412
+ <DriverTipsContainer>
413
+ <OText size={14} lineHeight={20} color={theme.colors.textNormal}>
414
+ {t('DRIVER_TIPS', 'Driver Tips')}
415
+ </OText>
416
+ <DriverTips
417
+ uuid={cart?.uuid}
418
+ businessId={cart?.business_id}
419
+ driverTipsOptions={!driverTipsOptions.includes(0) ? [0, ...driverTipsOptions] : driverTipsOptions}
420
+ isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1}
421
+ isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
422
+ driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1
423
+ ? cart?.driver_tip
424
+ : cart?.driver_tip_rate}
425
+ useOrderContext
426
+ cart={cart}
427
+ />
428
+ </DriverTipsContainer>
388
429
  )}
389
430
 
390
431
  <OSTotal>
391
432
  <OSTable style={{ marginTop: 15 }}>
392
- <OText size={14} lineHeight={21} weight={'600'}>
433
+ <OText size={14} lineHeight={21} weight={'bold'} color={theme.colors.textNormal}>
393
434
  {t('TOTAL', 'Total')}
394
435
  </OText>
395
- <OText size={14} lineHeight={21} weight={'600'}>
436
+ <OText size={14} lineHeight={21} weight={'bold'} color={theme.colors.textNormal}>
396
437
  {parsePrice(cart?.balance >= 0 ? cart?.balance : 0)}
397
438
  </OText>
398
439
  </OSTable>
@@ -455,15 +496,15 @@ const CartUI = (props: any) => {
455
496
  {cart?.valid_products ? (
456
497
  <CheckoutAction>
457
498
  <OButton
458
- text={(cart?.subtotal >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
499
+ text={(subtotalWithTaxes >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
459
500
  !openUpselling !== canOpenUpselling ? t('CHECKOUT', 'Checkout') : t('LOADING', 'Loading')
460
501
  ) : !cart?.valid_address ? (
461
502
  `${t('OUT_OF_COVERAGE', 'Out of Coverage')}`
462
503
  ) : (
463
504
  `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`
464
505
  )}
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}
506
+ bgColor={(subtotalWithTaxes < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
507
+ isDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
467
508
  borderColor={theme.colors.primary}
468
509
  imgRightSrc={null}
469
510
  textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
@@ -516,14 +557,6 @@ const CartUI = (props: any) => {
516
557
  setOpenPlaceModal={setOpenPlaceModal}
517
558
  />
518
559
  </OModal>
519
- <OAlert
520
- open={confirm.open}
521
- title={confirm.title}
522
- content={confirm.content}
523
- onAccept={confirm.handleOnAccept}
524
- onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
525
- onClose={() => setConfirm({ ...confirm, open: false, title: null })}
526
- />
527
560
  </CContainer>
528
561
  )
529
562
  }
@@ -1,12 +1,13 @@
1
1
  import React, { useState } from 'react';
2
2
  import { View } from 'react-native';
3
- import { useLanguage } from 'ordering-components/native';
3
+ import { useLanguage, useConfig, useUtils } from 'ordering-components/native';
4
4
  import { useTheme } from 'styled-components/native';
5
- import { CCContainer, CCNotCarts, CCList } from './styles';
5
+ import { CCContainer, CCNotCarts, CCList, CheckoutAction, ChCartsTotal } from './styles';
6
6
 
7
7
  import { Cart } from '../Cart';
8
8
  import { OButton, OText } from '../shared';
9
9
  import Spinner from 'react-native-loading-spinner-overlay';
10
+ import { NotFoundSource } from '../NotFoundSource';
10
11
 
11
12
  export const CartContent = (props: any) => {
12
13
  const {
@@ -17,14 +18,61 @@ export const CartContent = (props: any) => {
17
18
 
18
19
  const theme = useTheme();
19
20
  const [, t] = useLanguage()
21
+ const [{ configs }] = useConfig()
22
+ const [{ parsePrice }] = useUtils();
20
23
  const [isCartsLoading, setIsCartsLoading] = useState(false)
21
24
 
25
+ const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
26
+ const isMultiCheckout = configs?.checkout_multi_business_enabled?.value === '1'
27
+ const cartsAvailable: any = Object.values(carts)?.filter((cart: any) => cart?.valid && cart?.status !== 2)
28
+
29
+ const totalCartsPrice = cartsAvailable?.length && cartsAvailable.reduce((total: any, cart: any) => { return total + cart?.total }, 0)
30
+ const totalCartsFee = cartsAvailable?.length && cartsAvailable
31
+ ?.filter((cart: any) => cart?.status !== 1 && cart?.valid && cart?.products?.length)
32
+ ?.reduce((total: any, cart: any) => { return total + (cart?.delivery_price_with_discount) }, 0)
33
+
34
+ const handleCheckoutRedirect = () => {
35
+ if (cartsAvailable.length === 1) {
36
+ onNavigationRedirect('CheckoutNavigator', {
37
+ screen: 'CheckoutPage',
38
+ cartUuid: cartsAvailable[0]?.uuid,
39
+ businessLogo: cartsAvailable[0]?.business?.logo,
40
+ businessName: cartsAvailable[0]?.business?.name,
41
+ cartTotal: cartsAvailable[0]?.total
42
+ })
43
+ } else {
44
+ const groupKeys: any = {}
45
+ cartsAvailable.forEach((_cart: any) => {
46
+ groupKeys[_cart?.group?.uuid]
47
+ ? groupKeys[_cart?.group?.uuid] += 1
48
+ : groupKeys[_cart?.group?.uuid ?? 'null'] = 1
49
+ })
50
+
51
+ if (
52
+ (Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
53
+ Object.keys(groupKeys).length > 1
54
+ ) {
55
+ onNavigationRedirect('CheckoutNavigator', {
56
+ screen: 'MultiCheckout',
57
+ checkCarts: true
58
+ })
59
+ } else {
60
+ onNavigationRedirect('CheckoutNavigator', {
61
+ screen: 'MultiCheckout',
62
+ cartUuid: cartsAvailable[0]?.group?.uuid
63
+ })
64
+ }
65
+ }
66
+ }
67
+
22
68
  return (
23
- <CCContainer>
69
+ <CCContainer
70
+ style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}
71
+ >
24
72
  {isOrderStateCarts && carts?.length > 0 && (
25
73
  <>
26
74
  {carts.map((cart: any, i: number) => (
27
- <CCList key={i} style={{ overflow: 'visible' }}>
75
+ <CCList nestedScrollEnabled={true} key={i} style={{ overflow: 'visible' }}>
28
76
  {cart.products.length > 0 && (
29
77
  <>
30
78
  <Cart
@@ -35,32 +83,80 @@ export const CartContent = (props: any) => {
35
83
  onNavigationRedirect={props.onNavigationRedirect}
36
84
  isCartsLoading={isCartsLoading}
37
85
  setIsCartsLoading={setIsCartsLoading}
86
+ isMultiCheckout={isMultiCheckout}
38
87
  hideUpselling
88
+ businessConfigs={cart?.business?.configs}
89
+ hideCouponInput={configs?.multi_business_checkout_coupon_input_style?.value === 'group'}
90
+ hideDeliveryFee={configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1'}
91
+ hideDriverTip={configs?.multi_business_checkout_show_combined_driver_tip?.value === '1'}
39
92
  />
40
93
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40, marginTop: 20 }} />
41
94
  </>
42
95
  )}
43
96
  </CCList>
44
97
  ))}
98
+ {isMultiCheckout && (
99
+ <>
100
+ {!!cartsAvailable.length && (
101
+ <ChCartsTotal>
102
+ {!!totalCartsFee && configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' && (
103
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
104
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
105
+ {t('TOTAL_DELIVERY_FEE', 'Total delivery fee')}
106
+ </OText>
107
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
108
+ {parsePrice(totalCartsFee)}
109
+ </OText>
110
+ </View>
111
+ )}
112
+ {cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0) > 0 &&
113
+ configs?.multi_business_checkout_show_combined_driver_tip?.value === '1' && (
114
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
115
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
116
+ {t('DRIVER_TIP', 'Driver tip')}
117
+ </OText>
118
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
119
+ {parsePrice(cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0))}
120
+ </OText>
121
+ </View>
122
+ )}
123
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
124
+ <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>
125
+ {t('TOTAL_FOR_ALL_CARTS', 'Total for all Carts')}
126
+ </OText>
127
+ <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>{parsePrice(totalCartsPrice)}</OText>
128
+ </View>
129
+ <View style={{ flexDirection: 'row', justifyContent: 'center', marginVertical: 20 }}>
130
+ <OText size={14} color={theme.colors.textNormal} weight={'300'} style={{ textAlign: 'center' }}>
131
+ {t('CART_GROUP_MESSAGE_ALERT', 'Discounts may be applied at the time of payment for this group.')}
132
+ </OText>
133
+ </View>
134
+ </ChCartsTotal>
135
+ )}
136
+ <CheckoutAction style={{ marginTop: 0 }}>
137
+ <OButton
138
+ text={t('CHECKOUT', 'Checkout')}
139
+ bgColor={!cartsAvailable.length ? theme.colors.secundary : theme.colors.primary}
140
+ isDisabled={!cartsAvailable.length}
141
+ borderColor={theme.colors.primary}
142
+ imgRightSrc={null}
143
+ textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
144
+ onClick={() => handleCheckoutRedirect()}
145
+ style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
146
+ />
147
+ </CheckoutAction>
148
+ </>
149
+ )}
45
150
  </>
46
151
  )}
47
152
  {(!carts || carts?.length === 0) && (
48
153
  <CCNotCarts>
49
- <OText size={24} style={{ textAlign: 'center' }}>
50
- {t('CARTS_NOT_FOUND', 'You don\'t have carts available')}
51
- </OText>
52
- <OButton
53
- text={t('START_SHOPPING', 'Start shopping')}
54
- bgColor={theme.colors.primary}
55
- borderColor={theme.colors.primary}
56
- textStyle={{
57
- color: theme.colors.white,
58
- fontSize: 14,
59
- paddingRight: 0
60
- }}
61
- style={{ height: 35, marginVertical: 20, borderRadius: 8 }}
62
- imgRightSrc={null}
63
- onClick={() => onNavigationRedirect('BusinessList')}
154
+ <NotFoundSource
155
+ hideImage
156
+ btnStyle={{ borderRadius: 8 }}
157
+ content={t('CARTS_NOT_FOUND', 'You don\'t have carts available')}
158
+ btnTitle={t('START_SHOPPING', 'Start shopping')}
159
+ onClickButton={() => onNavigationRedirect('BusinessList')}
64
160
  />
65
161
  </CCNotCarts>
66
162
  )}
@@ -1,19 +1,29 @@
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`
8
- height: 300px;
9
- display: flex;
10
8
  flex-direction: column;
11
- justify-content: center;
12
- align-items: center;
13
- width: 80%;
14
- margin: auto;
9
+ align-items: center;
10
+ margin-top: 40px;
15
11
  `
16
12
 
17
13
  export const CCList = styled.ScrollView`
18
14
  padding: 10px 0px;
19
15
  `
16
+
17
+ export const CheckoutAction = styled.View`
18
+ width: 100%;
19
+ display: flex;
20
+ justify-content: center;
21
+ flex-direction: column;
22
+ align-items: center;
23
+ margin-top: 10px;
24
+ margin-bottom: 10px;
25
+ `
26
+
27
+ export const ChCartsTotal = styled.View`
28
+ margin-bottom: 16px;
29
+ `