ordering-ui-react-native 0.17.88 → 0.17.89-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 +14 -10
  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 -46
  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 +87 -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,16 +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 isDisablePlaceOrderButton = !(paymethodSelected?.paymethod_id || paymethodSelected?.wallet_id) || (paymethodSelected?.paymethod?.gateway === 'stripe' && !paymethodSelected?.paymethod_data)
96
+ const isMultiDriverTips = configs?.checkout_multi_business_enabled?.value === '1'
82
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)
83
138
 
84
139
  const [isUserDetailsEdit, setIsUserDetailsEdit] = useState(false);
85
140
  const [phoneUpdate, setPhoneUpdate] = useState(false);
86
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
+
87
155
  const handleMomentClick = () => {
88
156
  if (isPreOrder) {
89
157
  navigation.navigate('MomentOption')
@@ -94,11 +162,12 @@ const MultiCheckoutUI = (props: any) => {
94
162
  setUserErrors([])
95
163
  const errors = []
96
164
  const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes']
165
+ const _requiredFields: any = []
97
166
 
98
167
  Object.values(validationFields?.fields?.checkout).map((field: any) => {
99
168
  if (field?.required && !notFields.includes(field.code)) {
100
169
  if (!user[field?.code]) {
101
- errors.push(t(`VALIDATION_ERROR_${field.code.toUpperCase()}_REQUIRED`, `The field ${field?.name} is required`))
170
+ _requiredFields.push(field?.code)
102
171
  }
103
172
  }
104
173
  })
@@ -109,8 +178,9 @@ const MultiCheckoutUI = (props: any) => {
109
178
  validationFields?.fields?.checkout?.cellphone?.required) ||
110
179
  configs?.verification_phone_required?.value === '1')
111
180
  ) {
112
- errors.push(t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Phone number is required'))
181
+ _requiredFields.push('cellphone')
113
182
  }
183
+ setRequiredFields(_requiredFields)
114
184
 
115
185
  if (phoneUpdate) {
116
186
  errors.push(t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number'))
@@ -123,11 +193,20 @@ const MultiCheckoutUI = (props: any) => {
123
193
  setPhoneUpdate(val)
124
194
  }
125
195
 
126
- const handlePlaceOrder = () => {
127
- if (!userErrors.length) {
128
- 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)
129
204
  return
130
205
  }
206
+ if (requiredFields?.length) {
207
+ setIsOpen(true)
208
+ return
209
+ }
131
210
  let stringError = ''
132
211
  Object.values(userErrors).map((item: any, i: number) => {
133
212
  stringError += (i + 1) === userErrors.length ? `- ${item?.message || item}` : `- ${item?.message || item}\n`
@@ -136,12 +215,62 @@ const MultiCheckoutUI = (props: any) => {
136
215
  setIsUserDetailsEdit(true)
137
216
  }
138
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
+
139
236
  useEffect(() => {
140
237
  if (validationFields && validationFields?.fields?.checkout) {
141
238
  checkValidationFields()
142
239
  }
143
240
  }, [validationFields, user])
144
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
+
145
274
  return (
146
275
  <>
147
276
  <Container noPadding>
@@ -158,8 +287,15 @@ const MultiCheckoutUI = (props: any) => {
158
287
  <ChContainer style={styles.pagePadding}>
159
288
  <ChSection style={{ paddingTop: 0 }}>
160
289
  <ChHeader>
161
- <CHMomentWrapper onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes })}>
162
- <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>
163
299
  <OIcon
164
300
  src={theme.images.general.arrow_down}
165
301
  width={10}
@@ -189,15 +325,45 @@ const MultiCheckoutUI = (props: any) => {
189
325
 
190
326
  <ChSection>
191
327
  <ChUserDetails>
192
- <UserDetails
193
- isUserDetailsEdit={isUserDetailsEdit}
194
- useValidationFields
195
- useDefualtSessionManager
196
- useSessionUser
197
- isCheckout
198
- phoneUpdate={phoneUpdate}
199
- togglePhoneUpdate={togglePhoneUpdate}
200
- />
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
+ )}
201
367
  </ChUserDetails>
202
368
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
203
369
  </ChSection>
@@ -214,18 +380,80 @@ const MultiCheckoutUI = (props: any) => {
214
380
  </ChAddress>
215
381
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
216
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
+ )}
217
433
 
218
- <ChSection>
219
- <MultiCartsPaymethodsAndWallets
220
- openCarts={openCarts}
221
- paymethodSelected={paymethodSelected}
222
- handleSelectPaymethod={handleSelectPaymethod}
223
- handleSelectWallet={handleSelectWallet}
224
- handlePaymethodDataChange={handlePaymethodDataChange}
225
- cartUuid={cartUuid}
226
- />
227
- <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
228
- </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
+ )}
229
457
 
230
458
  <ChSection>
231
459
  <ChCarts>
@@ -234,20 +462,24 @@ const MultiCheckoutUI = (props: any) => {
234
462
  {t('MOBILE_FRONT_YOUR_ORDER', 'Your order')}
235
463
  </OText>
236
464
  </CartsHeader>
237
- {openCarts.map((cart: any) => (
465
+ {cartsToShow.map((cart: any) => (
238
466
  <React.Fragment key={cart.uuid}>
239
467
  <Cart
240
468
  cart={cart}
241
469
  cartuuid={cart.uuid}
242
470
  isMultiCheckout
471
+ hideCouponInput={configs?.multi_business_checkout_coupon_input_style?.value === 'group'}
243
472
  hideDeliveryFee={configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1'}
244
473
  hideDriverTip={configs?.multi_business_checkout_show_combined_driver_tip?.value === '1'}
245
474
  onNavigationRedirect={(route: string, params: any) => props.navigation.navigate(route, params)}
475
+ businessConfigs={cart?.business?.configs}
246
476
  />
247
- <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
+ )}
248
480
  </React.Fragment>
249
481
  ))}
250
- {!cartGroup?.loading && openCarts.length === 0 && (
482
+ {!cartGroup?.loading && openCarts.length === 0 && cartsInvalid?.length === 0 && (
251
483
  <CCNotCarts>
252
484
  <OText size={24} style={{ textAlign: 'center' }}>
253
485
  {t('CARTS_NOT_FOUND', 'You don\'t have carts available')}
@@ -259,33 +491,53 @@ const MultiCheckoutUI = (props: any) => {
259
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')}
260
492
  </OText>
261
493
  )}
262
- {openCarts.length > 0 && (
494
+ {openCarts.length > 1 && (
263
495
  <ChCartsTotal>
264
- {totalCartsFee && configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' && (
496
+ {!!totalCartsFee && configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' && (
265
497
  <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
266
498
  <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
267
499
  {t('TOTAL_DELIVERY_FEE', 'Total delivery fee')}
268
500
  </OText>
269
- <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>
270
504
  </View>
271
505
  )}
272
506
  {openCarts.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0) > 0 &&
273
507
  configs?.multi_business_checkout_show_combined_driver_tip?.value === '1' && (
274
- <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' }}>
275
519
  <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
276
- {t('DRIVER_TIP', 'Driver tip')}
520
+ {walletName[cartGroup?.result?.wallets?.find((wallet: any) => wallet.wallet_id === event.wallet_id)?.type]?.name}
277
521
  </OText>
278
522
  <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
279
- {parsePrice(openCarts.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0))}
523
+ -{parsePrice(event.amount, { isTruncable: true })}
280
524
  </OText>
281
525
  </View>
282
- )}
526
+ ))}
283
527
  <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
284
528
  <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>
285
529
  {t('TOTAL_FOR_ALL_CARTS', 'Total for all Carts')}
286
530
  </OText>
287
531
  <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>{parsePrice(totalCartsPrice)}</OText>
288
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
+
289
541
  <OText size={12} color={theme.colors.mediumGray} mRight={70} style={{ marginTop: 10 }}>
290
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')}
291
543
  </OText>
@@ -293,11 +545,73 @@ const MultiCheckoutUI = (props: any) => {
293
545
  )}
294
546
  </ChCarts>
295
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
+ )}
296
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>
297
609
  </Container>
298
610
 
299
611
  <FloatingButton
300
- handleClick={() => handlePlaceOrder()}
612
+ handleClick={methodsPay.includes(paymethodSelected?.gateway)
613
+ ? () => setPlaceByMethodPay(true)
614
+ : () => handlePlaceOrder()}
301
615
  isSecondaryBtn={isDisablePlaceOrderButton}
302
616
  disabled={isDisablePlaceOrderButton}
303
617
  btnText={placing ? t('PLACING', 'Placing') : t('PLACE_ORDER', 'Place Order')}
@@ -310,9 +624,34 @@ const MultiCheckoutUI = (props: any) => {
310
624
  }
311
625
 
312
626
  export const MultiCheckout = (props: any) => {
627
+ const [loadMultiCarts, setLoadMultiCarts] = useState(!!props.route?.params?.checkCarts)
628
+ const [cartUuid, setCartUuid] = useState('')
629
+
313
630
  const multiCheckoutProps = {
314
631
  ...props,
632
+ cartUuid: props.route?.params?.cartUuid ?? cartUuid,
315
633
  UIComponent: MultiCheckoutUI
316
634
  }
317
- 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
+ )
318
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;