ordering-ui-react-native 0.17.87 → 0.17.88-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 (216) 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 +33 -26
  15. package/themes/business/src/components/BusinessController/index.tsx +0 -1
  16. package/themes/business/src/components/Chat/index.tsx +163 -123
  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/FloatingButton/index.tsx +34 -31
  20. package/themes/business/src/components/GoogleMap/index.tsx +58 -57
  21. package/themes/business/src/components/LoginForm/Otp/index.tsx +31 -3
  22. package/themes/business/src/components/LoginForm/index.tsx +15 -22
  23. package/themes/business/src/components/MapView/index.tsx +8 -8
  24. package/themes/business/src/components/MessagesOption/index.tsx +20 -93
  25. package/themes/business/src/components/NewOrderNotification/index.tsx +123 -96
  26. package/themes/business/src/components/NotFoundSource/index.tsx +2 -2
  27. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  28. package/themes/business/src/components/OrderDetails/Delivery.tsx +202 -12
  29. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +84 -37
  30. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +81 -66
  31. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +200 -0
  32. package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
  33. package/themes/business/src/components/OrderMessage/index.tsx +19 -18
  34. package/themes/business/src/components/OrderSummary/index.tsx +114 -123
  35. package/themes/business/src/components/OrdersOption/index.tsx +22 -22
  36. package/themes/business/src/components/PreviousMessages/FooterMessageComponent.tsx +103 -0
  37. package/themes/business/src/components/PreviousMessages/index.tsx +97 -55
  38. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +17 -12
  39. package/themes/business/src/components/PreviousOrders/OrderList.tsx +93 -0
  40. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +1 -1
  41. package/themes/business/src/components/PreviousOrders/index.tsx +198 -221
  42. package/themes/business/src/components/ProductItemAccordion/index.tsx +7 -1
  43. package/themes/business/src/components/ReviewCustomer/index.tsx +18 -13
  44. package/themes/business/src/components/StoresList/index.tsx +3 -4
  45. package/themes/business/src/components/UserProfileForm/index.tsx +14 -15
  46. package/themes/business/src/components/shared/OModal.tsx +16 -9
  47. package/themes/business/src/types/index.tsx +25 -10
  48. package/themes/business/src/utils/index.tsx +29 -2
  49. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  50. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  51. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  52. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  53. package/themes/kiosk/src/components/Intro/index.tsx +16 -1
  54. package/themes/kiosk/src/components/LoginForm/index.tsx +7 -9
  55. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  56. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  57. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  58. package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +2 -2
  59. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  60. package/themes/original/index.tsx +1 -1
  61. package/themes/original/src/components/AddressDetails/index.tsx +19 -3
  62. package/themes/original/src/components/AddressForm/index.tsx +35 -17
  63. package/themes/original/src/components/AddressList/index.tsx +5 -8
  64. package/themes/original/src/components/AnalyticsSegment/index.tsx +193 -10
  65. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  66. package/themes/original/src/components/AppleLogin/styles.tsx +3 -1
  67. package/themes/original/src/components/BusinessBasicInformation/index.tsx +73 -37
  68. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +10 -12
  69. package/themes/original/src/components/BusinessController/index.tsx +35 -44
  70. package/themes/original/src/components/BusinessController/styles.tsx +12 -5
  71. package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
  72. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
  73. package/themes/original/src/components/BusinessInformation/index.tsx +140 -85
  74. package/themes/original/src/components/BusinessItemAccordion/index.tsx +15 -20
  75. package/themes/original/src/components/BusinessListingSearch/index.tsx +347 -336
  76. package/themes/original/src/components/BusinessListingSearch/styles.tsx +0 -18
  77. package/themes/original/src/components/BusinessPreorder/index.tsx +103 -19
  78. package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -2
  79. package/themes/original/src/components/BusinessProductsList/index.tsx +15 -7
  80. package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
  81. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +1 -1
  82. package/themes/original/src/components/BusinessProductsListing/index.tsx +663 -556
  83. package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -3
  84. package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
  85. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
  86. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
  87. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
  88. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +38 -405
  89. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  90. package/themes/original/src/components/Cart/index.tsx +60 -51
  91. package/themes/original/src/components/CartContent/index.tsx +102 -58
  92. package/themes/original/src/components/CartContent/styles.tsx +6 -6
  93. package/themes/original/src/components/Checkout/index.tsx +280 -35
  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 +1 -5
  99. package/themes/original/src/components/GPSButton/index.tsx +6 -4
  100. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +8 -3
  101. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +42 -5
  102. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +2 -0
  103. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +86 -10
  104. package/themes/original/src/components/GoogleLogin/styles.tsx +1 -1
  105. package/themes/original/src/components/GoogleMap/index.tsx +63 -7
  106. package/themes/original/src/components/Home/index.tsx +13 -4
  107. package/themes/original/src/components/LastOrder/index.tsx +2 -1
  108. package/themes/original/src/components/LastOrders/index.tsx +2 -1
  109. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -25
  110. package/themes/original/src/components/LoginForm/index.tsx +64 -34
  111. package/themes/original/src/components/LottieAnimation/index.tsx +88 -63
  112. package/themes/original/src/components/MessageListing/index.tsx +9 -2
  113. package/themes/original/src/components/Messages/index.tsx +15 -4
  114. package/themes/original/src/components/MomentOption/index.tsx +193 -92
  115. package/themes/original/src/components/MomentSelector/index.tsx +1 -1
  116. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +162 -50
  117. package/themes/original/src/components/MultiCheckout/index.tsx +385 -52
  118. package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
  119. package/themes/original/src/components/MultiOrdersDetails/index.tsx +23 -19
  120. package/themes/original/src/components/MyOrders/index.tsx +25 -16
  121. package/themes/original/src/components/NavBar/index.tsx +20 -13
  122. package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
  123. package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
  124. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +21 -5
  125. package/themes/original/src/components/OrderDetails/index.tsx +50 -38
  126. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  127. package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
  128. package/themes/original/src/components/OrderProgress/index.tsx +34 -25
  129. package/themes/original/src/components/OrderSummary/index.tsx +83 -57
  130. package/themes/original/src/components/OrderTypeSelector/index.tsx +5 -6
  131. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +14 -14
  132. package/themes/original/src/components/OrdersOption/index.tsx +59 -46
  133. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  134. package/themes/original/src/components/PageBanner/index.tsx +65 -29
  135. package/themes/original/src/components/PageBanner/styles.tsx +0 -3
  136. package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
  137. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +3 -0
  138. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  139. package/themes/original/src/components/PaymentOptions/index.tsx +100 -34
  140. package/themes/original/src/components/PhoneInputNumber/index.tsx +18 -4
  141. package/themes/original/src/components/ProductForm/index.tsx +88 -31
  142. package/themes/original/src/components/ProductForm/styles.tsx +3 -3
  143. package/themes/original/src/components/ProductItemAccordion/index.tsx +8 -6
  144. package/themes/original/src/components/ProductOptionSubOption/index.tsx +49 -20
  145. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +10 -9
  146. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  147. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
  148. package/themes/original/src/components/ProfessionalProfile/index.tsx +36 -7
  149. package/themes/original/src/components/Promotions/index.tsx +2 -2
  150. package/themes/original/src/components/Promotions/styles.tsx +3 -1
  151. package/themes/original/src/components/ReviewProducts/index.tsx +16 -7
  152. package/themes/original/src/components/ScheduleAccordion/index.tsx +3 -3
  153. package/themes/original/src/components/ServiceForm/index.tsx +63 -20
  154. package/themes/original/src/components/Sessions/styles.tsx +1 -0
  155. package/themes/original/src/components/SignupForm/index.tsx +43 -27
  156. package/themes/original/src/components/SingleOrderCard/index.tsx +42 -19
  157. package/themes/original/src/components/SingleOrderCard/styles.tsx +1 -1
  158. package/themes/original/src/components/SingleProductCard/index.tsx +37 -26
  159. package/themes/original/src/components/SingleProductCard/styles.tsx +9 -3
  160. package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
  161. package/themes/original/src/components/StripeCardsList/index.tsx +61 -5
  162. package/themes/original/src/components/StripeElementsForm/index.tsx +48 -34
  163. package/themes/original/src/components/StripeElementsForm/naked.tsx +12 -1
  164. package/themes/original/src/components/UpsellingProducts/index.tsx +5 -10
  165. package/themes/original/src/components/UserDetails/index.tsx +3 -1
  166. package/themes/original/src/components/UserFormDetails/index.tsx +78 -9
  167. package/themes/original/src/components/UserFormDetails/styles.tsx +1 -1
  168. package/themes/original/src/components/UserProfile/index.tsx +8 -26
  169. package/themes/original/src/components/UserProfileForm/index.tsx +30 -31
  170. package/themes/original/src/components/UserVerification/index.tsx +55 -50
  171. package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
  172. package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
  173. package/themes/original/src/components/Wallets/index.tsx +52 -62
  174. package/themes/original/src/components/Wallets/styles.tsx +2 -4
  175. package/themes/original/src/components/shared/OButton.tsx +3 -3
  176. package/themes/original/src/components/shared/OInput.tsx +4 -5
  177. package/themes/original/src/components/shared/OModal.tsx +3 -3
  178. package/themes/original/src/types/index.tsx +37 -10
  179. package/themes/original/src/utils/index.tsx +185 -13
  180. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  181. package/src/navigators/BottomNavigator.tsx +0 -117
  182. package/src/navigators/CheckoutNavigator.tsx +0 -66
  183. package/src/navigators/HomeNavigator.tsx +0 -202
  184. package/src/navigators/NavigationRef.tsx +0 -7
  185. package/src/navigators/RootNavigator.tsx +0 -269
  186. package/src/pages/Account.tsx +0 -34
  187. package/src/pages/AddressForm.tsx +0 -62
  188. package/src/pages/AddressList.tsx +0 -24
  189. package/src/pages/BusinessProductsList.tsx +0 -81
  190. package/src/pages/BusinessesListing.tsx +0 -43
  191. package/src/pages/CartList.tsx +0 -49
  192. package/src/pages/Checkout.tsx +0 -101
  193. package/src/pages/ForgotPassword.tsx +0 -24
  194. package/src/pages/Help.tsx +0 -23
  195. package/src/pages/HelpAccountAndPayment.tsx +0 -23
  196. package/src/pages/HelpGuide.tsx +0 -23
  197. package/src/pages/HelpOrder.tsx +0 -23
  198. package/src/pages/Home.tsx +0 -36
  199. package/src/pages/IntroductoryTutorial.tsx +0 -170
  200. package/src/pages/Login.tsx +0 -47
  201. package/src/pages/MomentOption.tsx +0 -30
  202. package/src/pages/MultiCheckout.tsx +0 -31
  203. package/src/pages/MultiOrdersDetails.tsx +0 -27
  204. package/src/pages/MyOrders.tsx +0 -40
  205. package/src/pages/NetworkError.tsx +0 -24
  206. package/src/pages/NotFound.tsx +0 -22
  207. package/src/pages/OrderDetails.tsx +0 -25
  208. package/src/pages/ProductDetails.tsx +0 -55
  209. package/src/pages/Profile.tsx +0 -36
  210. package/src/pages/ReviewDriver.tsx +0 -30
  211. package/src/pages/ReviewOrder.tsx +0 -32
  212. package/src/pages/ReviewProducts.tsx +0 -30
  213. package/src/pages/Sessions.tsx +0 -22
  214. package/src/pages/Signup.tsx +0 -53
  215. package/src/pages/SpinnerLoader.tsx +0 -10
  216. package/src/pages/Splash.tsx +0 -21
@@ -10,17 +10,24 @@ import {
10
10
  ToastType,
11
11
  MultiCheckout as MultiCheckoutController
12
12
  } from 'ordering-components/native'
13
- import { View, StyleSheet, Platform } from 'react-native'
13
+ import { View, StyleSheet, Platform, ScrollView } from 'react-native'
14
14
  import { useTheme } from 'styled-components/native';
15
15
  import { Container } from '../../layouts/Container';
16
16
  import NavBar from '../NavBar';
17
- import { OText, OIcon, OModal } from '../shared';
17
+ import { OText, OIcon, OModal, OButton } from '../shared';
18
18
  import { getTypesText } from '../../utils';
19
19
  import { UserDetails } from '../UserDetails'
20
20
  import { AddressDetails } from '../AddressDetails'
21
+ import { MultiCart as MultiCartController } from '../MultiCart'
21
22
  import { MultiCartsPaymethodsAndWallets } from '../MultiCartsPaymethodsAndWallets'
22
23
  import { Cart } from '../Cart'
23
24
  import { FloatingButton } from '../FloatingButton'
25
+ import { DriverTips } from '../DriverTips'
26
+ import { CouponControl } from '../CouponControl';
27
+ import { DriverTipsContainer } from '../Cart/styles'
28
+ import { OSTable, OSCoupon } from '../OrderSummary/styles';
29
+ import { SignupForm } from '../SignupForm'
30
+ import { LoginForm } from '../LoginForm'
24
31
 
25
32
  import {
26
33
  ChContainer,
@@ -48,15 +55,19 @@ const MultiCheckoutUI = (props: any) => {
48
55
  navigation,
49
56
  placing,
50
57
  openCarts,
51
- totalCartsPrice,
52
58
  handleGroupPlaceOrder,
53
59
  paymethodSelected,
54
60
  handleSelectPaymethod,
55
61
  handleSelectWallet,
56
62
  handlePaymethodDataChange,
57
63
  cartUuid,
64
+ loyaltyPlansState,
58
65
  totalCartsFee,
59
- cartGroup
66
+ cartGroup,
67
+ walletState,
68
+ onNavigationRedirectReplace,
69
+ merchantId,
70
+ cartsInvalid
60
71
  } = props
61
72
 
62
73
  const theme = useTheme();
@@ -65,7 +76,11 @@ const MultiCheckoutUI = (props: any) => {
65
76
  paddingLeft: 40,
66
77
  paddingRight: 40
67
78
  },
68
- wrapperNavbar: { paddingHorizontal: 40 }
79
+ wrapperNavbar: { paddingHorizontal: 40 },
80
+ detailWrapper: {
81
+ paddingHorizontal: 40,
82
+ width: '100%'
83
+ },
69
84
  })
70
85
 
71
86
  const [, { showToast }] = useToast();
@@ -74,17 +89,69 @@ const MultiCheckoutUI = (props: any) => {
74
89
  const [{ parsePrice, parseDate }] = useUtils();
75
90
  const [{ options, carts, loading }, { confirmCart }] = useOrder();
76
91
  const [validationFields] = useValidationFields();
77
- const [{ user }] = useSession()
92
+ const [{ user }, { login }] = useSession()
78
93
 
79
94
  const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
80
95
  const isPreOrder = configs?.preorder_status_enabled?.value === '1'
81
- const maximumCarts = 5
82
- const isDisablePlaceOrderButton = !(paymethodSelected?.paymethod_id || paymethodSelected?.wallet_id) || openCarts.length > maximumCarts || (paymethodSelected?.paymethod?.gateway === 'stripe' && !paymethodSelected?.paymethod_data)
96
+ const isMultiDriverTips = configs?.checkout_multi_business_enabled?.value === '1'
83
97
  const walletCarts = (Object.values(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) || []
98
+ const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
99
+ const cartsToShow = openCarts?.length > 0 ? openCarts : cartsInvalid
100
+ const walletName: any = {
101
+ cash: {
102
+ name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
103
+ },
104
+ credit_point: {
105
+ name: t('PAY_WITH_CREDITS_POINTS_WALLET', 'Pay with Credit Points Wallet'),
106
+ }
107
+ }
108
+
109
+ const totalCartsPrice = cartGroup?.result?.balance
110
+
111
+ const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
112
+ ? JSON.parse(configs?.driver_tip_options?.value) || []
113
+ : configs?.driver_tip_options?.value || []
114
+
115
+ const creditPointGeneralPlan = loyaltyPlansState?.result?.find((loyal: any) => loyal.type === 'credit_point')
116
+ const loyalBusinessAvailable = creditPointGeneralPlan?.businesses?.filter((b: any) => b.accumulates) ?? []
117
+
118
+ const accumulationRateBusiness = (businessId: number) => {
119
+ const value = loyalBusinessAvailable?.find((loyal: any) => loyal.business_id === businessId)?.accumulation_rate ?? 0
120
+ return value || (creditPointGeneralPlan?.accumulation_rate ?? 0)
121
+ }
122
+
123
+ const getIncludedTaxes = (cart: any) => {
124
+ if (cart?.taxes === null || !cart?.taxes) {
125
+ return cart.business.tax_type === 1 ? cart?.tax : 0
126
+ } else {
127
+ return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
128
+ return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
129
+ }, 0)
130
+ }
131
+ }
132
+
133
+ const clearAmount = (value: any) => parseFloat((Math.trunc(value * 100) / 100).toFixed(configs.format_number_decimal_length?.value ?? 2))
134
+
135
+ const loyaltyRewardValue = openCarts
136
+ ?.reduce((sum: any, cart: any) => sum + clearAmount((cart?.subtotal + getIncludedTaxes(cart)) * accumulationRateBusiness(cart?.business_id)), 0)
137
+ ?.toFixed(configs.format_number_decimal_length?.value ?? 2)
84
138
 
85
139
  const [isUserDetailsEdit, setIsUserDetailsEdit] = useState(false);
86
140
  const [phoneUpdate, setPhoneUpdate] = useState(false);
87
141
  const [userErrors, setUserErrors] = useState<any>([]);
142
+ const [placeByMethodPay, setPlaceByMethodPay] = useState(false)
143
+ const [allowedGuest, setAllowedGuest] = useState(false)
144
+ const [isOpen, setIsOpen] = useState(false)
145
+ const [requiredFields, setRequiredFields] = useState<any>([])
146
+ const stripePaymethods: any = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect']
147
+ const [openModal, setOpenModal] = useState({ login: false, signup: false, isGuest: false })
148
+ const [methodPaySupported, setMethodPaySupported] = useState({ enabled: false, message: null, loading: true })
149
+ const methodsPay = ['global_google_pay', 'global_apple_pay']
150
+ const isDisablePlaceOrderButton = cartGroup?.loading || (!(paymethodSelected?.paymethod_id || paymethodSelected?.wallet_id) && cartGroup?.result?.balance > 0) ||
151
+ (paymethodSelected?.paymethod?.gateway === 'stripe' && !paymethodSelected?.paymethod_data) ||
152
+ walletCarts.length > 0
153
+ || (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading)) || openCarts?.length === 0
154
+
88
155
  const handleMomentClick = () => {
89
156
  if (isPreOrder) {
90
157
  navigation.navigate('MomentOption')
@@ -95,11 +162,12 @@ const MultiCheckoutUI = (props: any) => {
95
162
  setUserErrors([])
96
163
  const errors = []
97
164
  const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes']
165
+ const _requiredFields: any = []
98
166
 
99
167
  Object.values(validationFields?.fields?.checkout).map((field: any) => {
100
168
  if (field?.required && !notFields.includes(field.code)) {
101
169
  if (!user[field?.code]) {
102
- errors.push(t(`VALIDATION_ERROR_${field.code.toUpperCase()}_REQUIRED`, `The field ${field?.name} is required`))
170
+ _requiredFields.push(field?.code)
103
171
  }
104
172
  }
105
173
  })
@@ -110,8 +178,9 @@ const MultiCheckoutUI = (props: any) => {
110
178
  validationFields?.fields?.checkout?.cellphone?.required) ||
111
179
  configs?.verification_phone_required?.value === '1')
112
180
  ) {
113
- errors.push(t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Phone number is required'))
181
+ _requiredFields.push('cellphone')
114
182
  }
183
+ setRequiredFields(_requiredFields)
115
184
 
116
185
  if (phoneUpdate) {
117
186
  errors.push(t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number'))
@@ -124,11 +193,20 @@ const MultiCheckoutUI = (props: any) => {
124
193
  setPhoneUpdate(val)
125
194
  }
126
195
 
127
- const handlePlaceOrder = () => {
128
- if (!userErrors.length) {
129
- handleGroupPlaceOrder && handleGroupPlaceOrder()
196
+ const handlePlaceOrder = (confirmPayment?: any) => {
197
+ if (stripePaymethods.includes(paymethodSelected?.gateway) && user?.guest_id) {
198
+ setOpenModal({ ...openModal, signup: true, isGuest: true })
199
+ return
200
+ }
201
+
202
+ if (!userErrors.length && (!requiredFields?.length || allowedGuest)) {
203
+ handleGroupPlaceOrder && handleGroupPlaceOrder(confirmPayment)
130
204
  return
131
205
  }
206
+ if (requiredFields?.length) {
207
+ setIsOpen(true)
208
+ return
209
+ }
132
210
  let stringError = ''
133
211
  Object.values(userErrors).map((item: any, i: number) => {
134
212
  stringError += (i + 1) === userErrors.length ? `- ${item?.message || item}` : `- ${item?.message || item}\n`
@@ -137,12 +215,62 @@ const MultiCheckoutUI = (props: any) => {
137
215
  setIsUserDetailsEdit(true)
138
216
  }
139
217
 
218
+ const handlePlaceOrderAsGuest = () => {
219
+ setIsOpen(false)
220
+ handleGroupPlaceOrder && handleGroupPlaceOrder()
221
+ }
222
+
223
+ const handleSuccessSignup = (user: any) => {
224
+ login({
225
+ user,
226
+ token: user?.session?.access_token
227
+ })
228
+ openModal?.isGuest && handlePlaceOrderAsGuest()
229
+ setOpenModal({ ...openModal, signup: false, isGuest: false })
230
+ }
231
+
232
+ const handleSuccessLogin = (user: any) => {
233
+ if (user) setOpenModal({ ...openModal, login: false })
234
+ }
235
+
140
236
  useEffect(() => {
141
237
  if (validationFields && validationFields?.fields?.checkout) {
142
238
  checkValidationFields()
143
239
  }
144
240
  }, [validationFields, user])
145
241
 
242
+ useEffect(() => {
243
+ if (cartsToShow?.length === 1) {
244
+ onNavigationRedirectReplace('CheckoutPage', {
245
+ cartUuid: cartsToShow[0]?.uuid,
246
+ fromMulti: true
247
+ })
248
+ return
249
+ }
250
+ }, [cartsToShow])
251
+
252
+ useEffect(() => {
253
+ if (walletState.error) {
254
+ showToast(ToastType.Error, t(walletState.error, walletState.error?.[0]?.replace(/_/g, ' ')))
255
+ }
256
+ }, [walletState.error])
257
+
258
+ useEffect(() => {
259
+ if (!cartUuid) {
260
+ onNavigationRedirectReplace('BottomTab', { screen: 'Cart' })
261
+ }
262
+ }, [cartUuid])
263
+
264
+ useEffect(() => {
265
+ if (paymethodSelected?.gateway === 'global_google_pay') {
266
+ setMethodPaySupported({
267
+ enabled: true,
268
+ loading: false,
269
+ message: null
270
+ })
271
+ }
272
+ }, [paymethodSelected])
273
+
146
274
  return (
147
275
  <>
148
276
  <Container noPadding>
@@ -159,8 +287,15 @@ const MultiCheckoutUI = (props: any) => {
159
287
  <ChContainer style={styles.pagePadding}>
160
288
  <ChSection style={{ paddingTop: 0 }}>
161
289
  <ChHeader>
162
- <CHMomentWrapper onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes })}>
163
- <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textSecondary}>{t(getTypesText(options?.type || 1), 'Delivery')}</OText>
290
+ <CHMomentWrapper isCustomColor={isChewLayout} onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes })}>
291
+ <OText
292
+ size={12}
293
+ numberOfLines={1}
294
+ ellipsizeMode={'tail'}
295
+ color={theme.colors?.[isChewLayout ? 'white' : 'textSecondary']}
296
+ >
297
+ {t(getTypesText(options?.type || 1), 'Delivery')}
298
+ </OText>
164
299
  <OIcon
165
300
  src={theme.images.general.arrow_down}
166
301
  width={10}
@@ -190,15 +325,45 @@ const MultiCheckoutUI = (props: any) => {
190
325
 
191
326
  <ChSection>
192
327
  <ChUserDetails>
193
- <UserDetails
194
- isUserDetailsEdit={isUserDetailsEdit}
195
- useValidationFields
196
- useDefualtSessionManager
197
- useSessionUser
198
- isCheckout
199
- phoneUpdate={phoneUpdate}
200
- togglePhoneUpdate={togglePhoneUpdate}
201
- />
328
+ {(user?.guest_id && !allowedGuest) ? (
329
+ <View>
330
+ <OText size={14} numberOfLines={1} ellipsizeMode='tail' color={theme.colors.textNormal}>
331
+ {t('CUSTOMER_DETAILS', 'Customer details')}
332
+ </OText>
333
+ <OButton
334
+ text={t('SIGN_UP', 'Sign up')}
335
+ textStyle={{ color: theme.colors.white }}
336
+ style={{ borderRadius: 7.6, marginTop: 20 }}
337
+ onClick={() => setOpenModal({ ...openModal, signup: true })}
338
+ />
339
+ <OButton
340
+ text={t('LOGIN', 'Login')}
341
+ textStyle={{ color: theme.colors.primary }}
342
+ bgColor={theme.colors.white}
343
+ borderColor={theme.colors.primary}
344
+ style={{ borderRadius: 7.6, marginTop: 20 }}
345
+ onClick={() => setOpenModal({ ...openModal, login: true })}
346
+ />
347
+ <OButton
348
+ text={t('CONTINUE_AS_GUEST', 'Continue as guest')}
349
+ textStyle={{ color: theme.colors.black }}
350
+ bgColor={theme.colors.white}
351
+ borderColor={theme.colors.black}
352
+ style={{ borderRadius: 7.6, marginTop: 20 }}
353
+ onClick={() => setAllowedGuest(true)}
354
+ />
355
+ </View>
356
+ ) : (
357
+ <UserDetails
358
+ isUserDetailsEdit={isUserDetailsEdit}
359
+ useValidationFields
360
+ useDefualtSessionManager
361
+ useSessionUser
362
+ isCheckout
363
+ phoneUpdate={phoneUpdate}
364
+ togglePhoneUpdate={togglePhoneUpdate}
365
+ />
366
+ )}
202
367
  </ChUserDetails>
203
368
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
204
369
  </ChSection>
@@ -215,18 +380,80 @@ const MultiCheckoutUI = (props: any) => {
215
380
  </ChAddress>
216
381
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
217
382
  </ChSection>
383
+ {openCarts?.length > 0 && (
384
+ <ChSection>
385
+ <MultiCartsPaymethodsAndWallets
386
+ openCarts={openCarts}
387
+ paymethodSelected={paymethodSelected}
388
+ walletsPaymethod={cartGroup?.result?.wallets}
389
+ handleSelectPaymethod={handleSelectPaymethod}
390
+ handleSelectWallet={handleSelectWallet}
391
+ handlePaymethodDataChange={handlePaymethodDataChange}
392
+ cartUuid={cartUuid}
393
+ merchantId={merchantId}
394
+ setMethodPaySupported={setMethodPaySupported}
395
+ methodPaySupported={methodPaySupported}
396
+ placeByMethodPay={placeByMethodPay}
397
+ setPlaceByMethodPay={setPlaceByMethodPay}
398
+ cartTotal={totalCartsPrice}
399
+ handlePlaceOrder={handlePlaceOrder}
400
+ />
401
+ <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
402
+ </ChSection>
403
+ )}
404
+ {
405
+ isMultiDriverTips &&
406
+ options?.type === 1 &&
407
+ validationFields?.fields?.checkout?.driver_tip?.enabled &&
408
+ openCarts.every((cart: any) => cart.business_id && cart.status !== 2) &&
409
+ driverTipsOptions && driverTipsOptions?.length > 0 &&
410
+ (
411
+ <ChSection>
412
+ <DriverTipsContainer>
413
+ <OText size={14} lineHeight={20} color={theme.colors.textNormal}>
414
+ {t('DRIVER_TIPS', 'Driver Tips')}
415
+ </OText>
416
+ <DriverTips
417
+ isMulti
418
+ isLoading={loading}
419
+ carts={openCarts}
420
+ businessIds={openCarts.map((cart: any) => cart.business_id)}
421
+ driverTipsOptions={driverTipsOptions}
422
+ isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1}
423
+ isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
424
+ driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1
425
+ ? openCarts?.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0)
426
+ : openCarts[0]?.driver_tip_rate}
427
+ useOrderContext
428
+ />
429
+ </DriverTipsContainer>
430
+ <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
431
+ </ChSection>
432
+ )}
218
433
 
219
- <ChSection>
220
- <MultiCartsPaymethodsAndWallets
221
- openCarts={openCarts}
222
- paymethodSelected={paymethodSelected}
223
- handleSelectPaymethod={handleSelectPaymethod}
224
- handleSelectWallet={handleSelectWallet}
225
- handlePaymethodDataChange={handlePaymethodDataChange}
226
- cartUuid={cartUuid}
227
- />
228
- <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
229
- </ChSection>
434
+ {
435
+ validationFields?.fields?.checkout?.coupon?.enabled &&
436
+ openCarts.every((cart: any) => cart.business_id && cart.status !== 2) &&
437
+ configs?.multi_business_checkout_coupon_input_style?.value === 'group' &&
438
+ openCarts?.length > 0 &&
439
+ (
440
+ <ChSection>
441
+ <OText size={14} lineHeight={20} color={theme.colors.textNormal}>
442
+ {t('DISCOUNT_COUPON', 'Discount coupon')}
443
+ </OText>
444
+ <OSTable>
445
+ <OSCoupon>
446
+ <CouponControl
447
+ isMulti
448
+ carts={openCarts}
449
+ businessIds={openCarts.map((cart: any) => cart.business_id)}
450
+ price={openCarts.reduce((total: any, cart: any) => total + cart.total, 0)}
451
+ />
452
+ </OSCoupon>
453
+ </OSTable>
454
+ <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
455
+ </ChSection>
456
+ )}
230
457
 
231
458
  <ChSection>
232
459
  <ChCarts>
@@ -235,20 +462,24 @@ const MultiCheckoutUI = (props: any) => {
235
462
  {t('MOBILE_FRONT_YOUR_ORDER', 'Your order')}
236
463
  </OText>
237
464
  </CartsHeader>
238
- {openCarts.map((cart: any) => (
465
+ {cartsToShow.map((cart: any) => (
239
466
  <React.Fragment key={cart.uuid}>
240
467
  <Cart
241
468
  cart={cart}
242
469
  cartuuid={cart.uuid}
243
470
  isMultiCheckout
471
+ hideCouponInput={configs?.multi_business_checkout_coupon_input_style?.value === 'group'}
244
472
  hideDeliveryFee={configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1'}
245
473
  hideDriverTip={configs?.multi_business_checkout_show_combined_driver_tip?.value === '1'}
246
474
  onNavigationRedirect={(route: string, params: any) => props.navigation.navigate(route, params)}
475
+ businessConfigs={cart?.business?.configs}
247
476
  />
248
- <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
477
+ {openCarts.length > 1 && (
478
+ <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
479
+ )}
249
480
  </React.Fragment>
250
481
  ))}
251
- {!cartGroup?.loading && openCarts.length === 0 && (
482
+ {!cartGroup?.loading && openCarts.length === 0 && cartsInvalid?.length === 0 && (
252
483
  <CCNotCarts>
253
484
  <OText size={24} style={{ textAlign: 'center' }}>
254
485
  {t('CARTS_NOT_FOUND', 'You don\'t have carts available')}
@@ -260,50 +491,127 @@ const MultiCheckoutUI = (props: any) => {
260
491
  {t('WARNING_PARTIAL_WALLET_CARTS', 'Important: One or more carts can`t be completed due a partial payment with cash/points wallet and requires to be paid individually')}
261
492
  </OText>
262
493
  )}
263
- {openCarts.length > 0 && (
494
+ {openCarts.length > 1 && (
264
495
  <ChCartsTotal>
265
- {totalCartsFee && configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' && (
496
+ {!!totalCartsFee && configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' && (
266
497
  <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
267
498
  <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
268
499
  {t('TOTAL_DELIVERY_FEE', 'Total delivery fee')}
269
500
  </OText>
270
- <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>{parsePrice(totalCartsFee)}</OText>
501
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
502
+ {parsePrice(totalCartsFee)}
503
+ </OText>
271
504
  </View>
272
505
  )}
273
506
  {openCarts.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0) > 0 &&
274
507
  configs?.multi_business_checkout_show_combined_driver_tip?.value === '1' && (
275
- <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
508
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
509
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
510
+ {t('DRIVER_TIP', 'Driver tip')}
511
+ </OText>
512
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
513
+ {parsePrice(openCarts.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0))}
514
+ </OText>
515
+ </View>
516
+ )}
517
+ {!cartGroup?.loading && cartGroup?.result?.payment_events?.length > 0 && cartGroup?.result?.payment_events?.map((event: any) => (
518
+ <View key={event.id} style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
276
519
  <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
277
- {t('DRIVER_TIP', 'Driver tip')}
520
+ {walletName[cartGroup?.result?.wallets?.find((wallet: any) => wallet.wallet_id === event.wallet_id)?.type]?.name}
278
521
  </OText>
279
522
  <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
280
- {parsePrice(openCarts.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0))}
523
+ -{parsePrice(event.amount, { isTruncable: true })}
281
524
  </OText>
282
525
  </View>
283
- )}
526
+ ))}
284
527
  <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
285
528
  <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>
286
529
  {t('TOTAL_FOR_ALL_CARTS', 'Total for all Carts')}
287
530
  </OText>
288
531
  <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>{parsePrice(totalCartsPrice)}</OText>
289
532
  </View>
533
+ {!!loyaltyRewardValue && (
534
+ <View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'flex-end' }}>
535
+ <OText size={12} color={theme.colors.textNormal}>
536
+ {t('REWARD_LOYALTY_POINT', 'Reward :amount: on loyalty points').replace(':amount:', loyaltyRewardValue)}
537
+ </OText>
538
+ </View>
539
+ )}
540
+
290
541
  <OText size={12} color={theme.colors.mediumGray} mRight={70} style={{ marginTop: 10 }}>
291
542
  {t('MULTI_CHECKOUT_DESCRIPTION', 'You will receive a receipt for each business. The payment is not combined between multiple stores. Each payment is processed by the store')}
292
543
  </OText>
293
544
  </ChCartsTotal>
294
545
  )}
295
- {openCarts.length > maximumCarts && (
296
- <OText size={14} color={theme.colors.danger5} style={{ marginVertical: 20 }}>
297
- {t('WARNING_MAXIMUM_CARTS', 'You can only pay for a maximum of 5 carts, please discard one or more to continue.')}
298
- </OText>
299
- )}
300
546
  </ChCarts>
301
547
  </ChSection>
548
+ {cartsToShow?.some((cart: any) => !cart?.valid_products && cart?.status !== 2) && (
549
+ <OText
550
+ color={theme.colors.error}
551
+ size={12}
552
+ >
553
+ {t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
554
+ </OText>
555
+ )}
302
556
  </ChContainer>
557
+ <OModal
558
+ open={openModal.signup}
559
+ onClose={() => setOpenModal({ ...openModal, signup: false, isGuest: false })}
560
+ >
561
+ <ScrollView style={{ paddingHorizontal: 20, width: '100%' }}>
562
+ <SignupForm
563
+ handleSuccessSignup={handleSuccessSignup}
564
+ isGuest
565
+ signupButtonText={t('SIGNUP', 'Signup')}
566
+ useSignupByEmail
567
+ useChekoutFileds
568
+ />
569
+ </ScrollView>
570
+ </OModal>
571
+ <OModal
572
+ open={openModal.login}
573
+ onClose={() => setOpenModal({ ...openModal, login: false })}
574
+ >
575
+ <ScrollView style={{ paddingHorizontal: 20, width: '100%' }}>
576
+ <LoginForm
577
+ handleSuccessLogin={handleSuccessLogin}
578
+ isGuest
579
+ loginButtonText={t('LOGIN', 'Login')}
580
+ loginButtonBackground={theme.colors.primary}
581
+ />
582
+ </ScrollView>
583
+ </OModal>
584
+ <OModal
585
+ open={isOpen}
586
+ onClose={() => setIsOpen(false)}
587
+ >
588
+ <View style={styles.detailWrapper}>
589
+ <UserDetails
590
+ isUserDetailsEdit
591
+ useValidationFields
592
+ useDefualtSessionManager
593
+ useSessionUser
594
+ isCheckout
595
+ isEdit
596
+ phoneUpdate={phoneUpdate}
597
+ togglePhoneUpdate={togglePhoneUpdate}
598
+ requiredFields={requiredFields}
599
+ hideUpdateButton
600
+ handlePlaceOrderAsGuest={handlePlaceOrderAsGuest}
601
+ onClose={() => {
602
+ setIsOpen(false)
603
+ handlePlaceOrder()
604
+ }}
605
+ setIsOpen={setIsOpen}
606
+ />
607
+ </View>
608
+ </OModal>
303
609
  </Container>
304
610
 
305
611
  <FloatingButton
306
- handleClick={() => handlePlaceOrder()}
612
+ handleClick={methodsPay.includes(paymethodSelected?.gateway)
613
+ ? () => setPlaceByMethodPay(true)
614
+ : () => handlePlaceOrder()}
307
615
  isSecondaryBtn={isDisablePlaceOrderButton}
308
616
  disabled={isDisablePlaceOrderButton}
309
617
  btnText={placing ? t('PLACING', 'Placing') : t('PLACE_ORDER', 'Place Order')}
@@ -316,9 +624,34 @@ const MultiCheckoutUI = (props: any) => {
316
624
  }
317
625
 
318
626
  export const MultiCheckout = (props: any) => {
627
+ const [loadMultiCarts, setLoadMultiCarts] = useState(!!props.route?.params?.checkCarts)
628
+ const [cartUuid, setCartUuid] = useState('')
629
+
319
630
  const multiCheckoutProps = {
320
631
  ...props,
632
+ cartUuid: props.route?.params?.cartUuid ?? cartUuid,
321
633
  UIComponent: MultiCheckoutUI
322
634
  }
323
- return <MultiCheckoutController {...multiCheckoutProps} />
635
+
636
+ const multiCartProps = {
637
+ ...props,
638
+ handleOnRedirectMultiCheckout: (cartUuid: string) => {
639
+ setCartUuid(cartUuid)
640
+ setLoadMultiCarts(false)
641
+ },
642
+ handleOnRedirectCheckout: (cartUuid: string) => {
643
+ props.navigation.navigate('CheckoutNavigator', {
644
+ screen: 'CheckoutPage',
645
+ cartUuid
646
+ })
647
+ }
648
+ }
649
+
650
+ return (
651
+ loadMultiCarts ? (
652
+ <MultiCartController {...multiCartProps} />
653
+ ) : (
654
+ <MultiCheckoutController {...multiCheckoutProps} />
655
+ )
656
+ )
324
657
  }
@@ -13,7 +13,9 @@ export const ChHeader = styled.View`
13
13
  margin: 0px;
14
14
  `
15
15
  export const CHMomentWrapper = styled.TouchableOpacity`
16
- background-color: ${(props: any) => props.theme.colors.backgroundGray100};
16
+ background-color: ${(props: any) => props.isCustomColor
17
+ ? props.theme.colors.primary
18
+ : props.theme.colors.backgroundGray100};
17
19
  border-radius: 7.6px;
18
20
  font-size: 12px;
19
21
  max-width: 240px;