ordering-ui-react-native 0.17.35 → 0.17.36-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.
- package/package.json +8 -7
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/OrderCreating/index.tsx +1 -21
- package/src/components/PaymentOptionsWebView/index.tsx +29 -8
- package/src/components/StripeMethodForm/index.tsx +108 -79
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OToast.tsx +4 -4
- package/src/types/index.tsx +5 -0
- package/src/utils/index.tsx +7 -1
- package/themes/business/index.tsx +2 -0
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +265 -240
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
- package/themes/business/src/components/BusinessController/index.tsx +0 -1
- package/themes/business/src/components/Chat/index.tsx +118 -107
- package/themes/business/src/components/DriverMap/index.tsx +17 -6
- package/themes/business/src/components/GoogleMap/index.tsx +58 -57
- package/themes/business/src/components/LoginForm/Otp/index.tsx +120 -0
- package/themes/business/src/components/LoginForm/Otp/styles.tsx +7 -0
- package/themes/business/src/components/LoginForm/index.tsx +238 -80
- package/themes/business/src/components/LoginForm/styles.tsx +10 -0
- package/themes/business/src/components/MapView/index.tsx +10 -10
- package/themes/business/src/components/NewOrderNotification/index.tsx +43 -50
- package/themes/business/src/components/OrderDetails/Delivery.tsx +4 -3
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +90 -47
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +59 -62
- package/themes/business/src/components/OrderDetailsLogistic/index.tsx +195 -0
- package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
- package/themes/business/src/components/OrderMessage/index.tsx +18 -17
- package/themes/business/src/components/OrderSummary/index.tsx +113 -121
- package/themes/business/src/components/OrdersOption/index.tsx +32 -75
- package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
- package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
- package/themes/business/src/components/PreviousOrders/index.tsx +445 -243
- package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
- package/themes/business/src/components/ProductItemAccordion/index.tsx +27 -3
- package/themes/business/src/components/ReviewCustomer/index.tsx +41 -24
- package/themes/business/src/components/StoresList/index.tsx +2 -2
- package/themes/business/src/components/shared/OLink.tsx +33 -13
- package/themes/business/src/components/shared/OModal.tsx +16 -9
- package/themes/business/src/components/shared/OText.tsx +8 -2
- package/themes/business/src/types/index.tsx +32 -2
- package/themes/business/src/utils/index.tsx +44 -1
- package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
- package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -1
- package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
- package/themes/kiosk/src/components/LoginForm/Otp/index.tsx +92 -0
- package/themes/kiosk/src/components/LoginForm/Otp/styles.tsx +7 -0
- package/themes/kiosk/src/components/LoginForm/index.tsx +473 -151
- package/themes/kiosk/src/components/LoginForm/styles.tsx +14 -1
- package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
- package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
- package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +3 -2
- package/themes/kiosk/src/components/PhoneInputNumber/styles.tsx +1 -3
- package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/kiosk/src/components/shared/OModal.tsx +14 -11
- package/themes/kiosk/src/layouts/Container.tsx +7 -1
- package/themes/kiosk/src/types/index.d.ts +13 -0
- package/themes/kiosk/src/utils/index.tsx +15 -0
- package/themes/original/index.tsx +6 -0
- package/themes/original/src/components/AddressDetails/index.tsx +29 -11
- package/themes/original/src/components/AddressForm/index.tsx +85 -49
- package/themes/original/src/components/AddressList/index.tsx +26 -21
- package/themes/original/src/components/AddressList/styles.tsx +4 -2
- package/themes/original/src/components/AnalyticsSegment/index.tsx +193 -10
- package/themes/original/src/components/AppleLogin/index.tsx +4 -4
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +159 -90
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +9 -7
- package/themes/original/src/components/BusinessController/index.tsx +154 -68
- package/themes/original/src/components/BusinessController/styles.tsx +22 -9
- package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
- package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
- package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +23 -22
- package/themes/original/src/components/BusinessListingSearch/index.tsx +351 -326
- package/themes/original/src/components/BusinessPreorder/index.tsx +97 -16
- package/themes/original/src/components/BusinessProductsList/index.tsx +20 -11
- package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
- package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +1 -1
- package/themes/original/src/components/BusinessProductsListing/index.tsx +684 -524
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +4 -6
- package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +106 -79
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -9
- package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
- package/themes/original/src/components/Cart/index.tsx +102 -69
- package/themes/original/src/components/CartContent/index.tsx +115 -19
- package/themes/original/src/components/CartContent/styles.tsx +17 -7
- package/themes/original/src/components/Checkout/index.tsx +375 -179
- package/themes/original/src/components/Checkout/styles.tsx +4 -2
- package/themes/original/src/components/CitiesControl/index.tsx +89 -0
- package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
- package/themes/original/src/components/CouponControl/index.tsx +10 -3
- package/themes/original/src/components/DriverTips/index.tsx +52 -34
- package/themes/original/src/components/Favorite/index.tsx +7 -4
- package/themes/original/src/components/Favorite/styles.tsx +1 -1
- package/themes/original/src/components/FavoriteList/index.tsx +51 -80
- package/themes/original/src/components/FloatingButton/index.tsx +1 -2
- package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
- package/themes/original/src/components/GPSButton/index.tsx +6 -4
- package/themes/original/src/components/GPSButton/styles.ts +3 -3
- package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +96 -0
- package/themes/original/src/components/GiftCard/GiftCardUI/styles.tsx +5 -0
- package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +100 -0
- package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +8 -0
- package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +191 -0
- package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +8 -0
- package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +165 -0
- package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +9 -0
- package/themes/original/src/components/GoogleMap/index.tsx +15 -4
- package/themes/original/src/components/Help/index.tsx +8 -8
- package/themes/original/src/components/HelpAccountAndPayment/index.tsx +11 -22
- package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +6 -0
- package/themes/original/src/components/HelpGuide/index.tsx +12 -16
- package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
- package/themes/original/src/components/HelpOrder/index.tsx +12 -25
- package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
- package/themes/original/src/components/Home/index.tsx +13 -4
- package/themes/original/src/components/LastOrder/index.tsx +1 -34
- package/themes/original/src/components/LoginForm/Otp/index.tsx +139 -75
- package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
- package/themes/original/src/components/LoginForm/index.tsx +71 -28
- package/themes/original/src/components/LottieAnimation/index.tsx +103 -0
- package/themes/original/src/components/MessageListing/index.tsx +16 -42
- package/themes/original/src/components/Messages/index.tsx +32 -10
- package/themes/original/src/components/MomentOption/index.tsx +195 -88
- package/themes/original/src/components/MultiCart/index.tsx +50 -0
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +197 -116
- package/themes/original/src/components/MultiCheckout/index.tsx +298 -88
- package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
- package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +68 -21
- package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
- package/themes/original/src/components/MyOrders/index.tsx +53 -51
- package/themes/original/src/components/NavBar/index.tsx +18 -18
- package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
- package/themes/original/src/components/Notifications/index.tsx +46 -50
- package/themes/original/src/components/Notifications/styles.tsx +6 -3
- package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +15 -3
- package/themes/original/src/components/OrderDetails/index.tsx +199 -359
- package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
- package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
- package/themes/original/src/components/OrderProgress/index.tsx +93 -114
- package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
- package/themes/original/src/components/OrderSummary/index.tsx +87 -59
- package/themes/original/src/components/OrderTypeSelector/index.tsx +1 -1
- package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +24 -19
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +14 -14
- package/themes/original/src/components/OrdersOption/index.tsx +70 -65
- package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
- package/themes/original/src/components/PageBanner/index.tsx +171 -0
- package/themes/original/src/components/PageBanner/styles.tsx +11 -0
- package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
- package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
- package/themes/original/src/components/PaymentOptions/index.tsx +58 -7
- package/themes/original/src/components/PhoneInputNumber/index.tsx +3 -3
- package/themes/original/src/components/PlaceSpot/index.tsx +12 -6
- package/themes/original/src/components/ProductForm/index.tsx +223 -232
- package/themes/original/src/components/ProductForm/styles.tsx +5 -8
- package/themes/original/src/components/ProductItemAccordion/index.tsx +59 -29
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +19 -11
- package/themes/original/src/components/ProductOptionSubOption/styles.tsx +1 -2
- package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
- package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
- package/themes/original/src/components/ProfessionalProfile/index.tsx +36 -7
- package/themes/original/src/components/Promotions/index.tsx +234 -220
- package/themes/original/src/components/Promotions/styles.tsx +10 -3
- package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
- package/themes/original/src/components/ReviewOrder/index.tsx +26 -9
- package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
- package/themes/original/src/components/ReviewProducts/index.tsx +23 -11
- package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
- package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
- package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
- package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
- package/themes/original/src/components/ServiceForm/index.tsx +74 -19
- package/themes/original/src/components/Sessions/index.tsx +11 -8
- package/themes/original/src/components/Sessions/styles.tsx +5 -0
- package/themes/original/src/components/SignupForm/index.tsx +42 -19
- package/themes/original/src/components/SingleOrderCard/index.tsx +156 -65
- package/themes/original/src/components/SingleOrderCard/styles.tsx +11 -9
- package/themes/original/src/components/SingleProductCard/index.tsx +100 -56
- package/themes/original/src/components/SingleProductCard/styles.tsx +22 -13
- package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
- package/themes/original/src/components/StripeCardsList/index.tsx +13 -3
- package/themes/original/src/components/StripeElementsForm/index.tsx +28 -15
- package/themes/original/src/components/UpsellingProducts/index.tsx +238 -224
- package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
- package/themes/original/src/components/UserDetails/index.tsx +8 -4
- package/themes/original/src/components/UserFormDetails/index.tsx +47 -7
- package/themes/original/src/components/UserProfile/index.tsx +5 -7
- package/themes/original/src/components/UserProfileForm/index.tsx +25 -28
- package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
- package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
- package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
- package/themes/original/src/components/Wallets/index.tsx +79 -36
- package/themes/original/src/components/Wallets/styles.tsx +5 -4
- package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
- package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
- package/themes/original/src/components/shared/OBottomPopup.tsx +1 -1
- package/themes/original/src/components/shared/OButton.tsx +6 -2
- package/themes/original/src/components/shared/OIcon.tsx +8 -1
- package/themes/original/src/components/shared/OInput.tsx +16 -2
- package/themes/original/src/components/shared/OModal.tsx +3 -3
- package/themes/original/src/layouts/Container.tsx +13 -9
- package/themes/original/src/types/index.tsx +38 -9
- package/themes/original/src/utils/index.tsx +364 -58
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { View, StyleSheet, TouchableOpacity, Platform, I18nManager } from 'react-native';
|
|
2
|
+
import { View, StyleSheet, TouchableOpacity, Platform, I18nManager, ScrollView } from 'react-native';
|
|
3
3
|
import { initStripe, useConfirmPayment } from '@stripe/stripe-react-native';
|
|
4
4
|
import Picker from 'react-native-country-picker-modal';
|
|
5
5
|
import MaterialIcons from 'react-native-vector-icons/MaterialIcons'
|
|
6
|
+
import ReactNativeHapticFeedback from "react-native-haptic-feedback";
|
|
6
7
|
import {
|
|
7
8
|
Checkout as CheckoutController,
|
|
8
9
|
useOrder,
|
|
@@ -14,9 +15,10 @@ import {
|
|
|
14
15
|
useConfig,
|
|
15
16
|
useToast,
|
|
16
17
|
ToastType,
|
|
18
|
+
useEvent
|
|
17
19
|
} from 'ordering-components/native';
|
|
18
20
|
import { useTheme } from 'styled-components/native';
|
|
19
|
-
import { OText, OIcon, OModal } from '../shared';
|
|
21
|
+
import { OText, OIcon, OModal, OButton } from '../shared';
|
|
20
22
|
|
|
21
23
|
import { AddressDetails } from '../AddressDetails';
|
|
22
24
|
import { PaymentOptions } from '../PaymentOptions';
|
|
@@ -25,6 +27,8 @@ import { NotFoundSource } from '../NotFoundSource';
|
|
|
25
27
|
import { UserDetails } from '../UserDetails';
|
|
26
28
|
import { PaymentOptionWallet } from '../PaymentOptionWallet';
|
|
27
29
|
import { PlaceSpot } from '../PlaceSpot'
|
|
30
|
+
import { SignupForm } from '../SignupForm'
|
|
31
|
+
import { LoginForm } from '../LoginForm'
|
|
28
32
|
|
|
29
33
|
import {
|
|
30
34
|
ChContainer,
|
|
@@ -78,6 +82,7 @@ const CheckoutUI = (props: any) => {
|
|
|
78
82
|
placing,
|
|
79
83
|
cartState,
|
|
80
84
|
cartUuid,
|
|
85
|
+
loyaltyPlansState,
|
|
81
86
|
businessDetails,
|
|
82
87
|
paymethodSelected,
|
|
83
88
|
handlePaymethodChange,
|
|
@@ -87,7 +92,9 @@ const CheckoutUI = (props: any) => {
|
|
|
87
92
|
instructionsOptions,
|
|
88
93
|
handleChangeDeliveryOption,
|
|
89
94
|
currency,
|
|
90
|
-
merchantId
|
|
95
|
+
merchantId,
|
|
96
|
+
setPlaceSpotNumber,
|
|
97
|
+
maxDate
|
|
91
98
|
} = props
|
|
92
99
|
|
|
93
100
|
const theme = useTheme();
|
|
@@ -118,19 +125,22 @@ const CheckoutUI = (props: any) => {
|
|
|
118
125
|
paddingHorizontal: 40,
|
|
119
126
|
width: '100%'
|
|
120
127
|
},
|
|
121
|
-
wrapperNavbar:
|
|
122
|
-
|
|
123
|
-
|
|
128
|
+
wrapperNavbar: {
|
|
129
|
+
paddingVertical: 0,
|
|
130
|
+
paddingHorizontal: 40,
|
|
131
|
+
marginVertical: 2
|
|
132
|
+
}
|
|
124
133
|
})
|
|
125
134
|
|
|
126
135
|
const [, { showToast }] = useToast();
|
|
127
136
|
const [, t] = useLanguage();
|
|
128
|
-
const [{ user, token }] = useSession();
|
|
137
|
+
const [{ user, token }, { login }] = useSession();
|
|
129
138
|
const [ordering] = useApi()
|
|
130
139
|
const [{ configs }] = useConfig();
|
|
131
140
|
const [{ parsePrice, parseDate }] = useUtils();
|
|
132
141
|
const [{ options, carts, loading }, { confirmCart }] = useOrder();
|
|
133
142
|
const [validationFields] = useValidationFields();
|
|
143
|
+
const [events] = useEvent()
|
|
134
144
|
|
|
135
145
|
const [errorCash, setErrorCash] = useState(false);
|
|
136
146
|
const [userErrors, setUserErrors] = useState<any>([]);
|
|
@@ -142,23 +152,48 @@ const CheckoutUI = (props: any) => {
|
|
|
142
152
|
const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
|
|
143
153
|
const [isOpen, setIsOpen] = useState(false)
|
|
144
154
|
const [requiredFields, setRequiredFields] = useState<any>([])
|
|
145
|
-
|
|
155
|
+
const [openModal, setOpenModal] = useState({ login: false, signup: false })
|
|
156
|
+
const [allowedGuest, setAllowedGuest] = useState(false)
|
|
157
|
+
const [placeByMethodPay, setPlaceByMethodPay] = useState(false)
|
|
158
|
+
const [methodPaySupported, setMethodPaySupported] = useState({ enabled: false, message: null, loading: true })
|
|
159
|
+
const [cardList, setCardList] = useState<any>({ cards: [], loading: false, error: null })
|
|
160
|
+
const cardsMethods = ['credomatic']
|
|
146
161
|
const placeSpotTypes = [3, 4, 5]
|
|
147
162
|
const placeSpotsEnabled = placeSpotTypes.includes(options?.type)
|
|
163
|
+
const isGiftCardCart = !cart?.business_id
|
|
148
164
|
const businessConfigs = businessDetails?.business?.configs ?? []
|
|
149
165
|
const isWalletCashEnabled = businessConfigs.find((config: any) => config.key === 'wallet_cash_enabled')?.value === '1'
|
|
150
166
|
const isWalletCreditPointsEnabled = businessConfigs.find((config: any) => config.key === 'wallet_credit_point_enabled')?.value === '1'
|
|
151
167
|
const isWalletEnabled = configs?.cash_wallet?.value && configs?.wallet_enabled?.value === '1' && (isWalletCashEnabled || isWalletCreditPointsEnabled)
|
|
152
168
|
const isBusinessChangeEnabled = configs?.cart_change_business_validation?.value === '1'
|
|
169
|
+
const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
|
|
170
|
+
const hideBusinessAddress = theme?.checkout?.components?.business?.components?.address?.hidden
|
|
171
|
+
const hideBusinessDetails = theme?.checkout?.components?.business?.hidden
|
|
172
|
+
const hideBusinessMap = theme?.checkout?.components?.business?.components?.map?.hidden
|
|
173
|
+
const hideCustomerDetails = theme?.checkout?.components?.customer?.hidden
|
|
174
|
+
|
|
175
|
+
const creditPointPlan = loyaltyPlansState?.result?.find((loyal: any) => loyal.type === 'credit_point')
|
|
176
|
+
const creditPointPlanOnBusiness = creditPointPlan?.businesses?.find((b: any) => b.business_id === cart?.business_id && b.accumulates)
|
|
177
|
+
const methodsPay = ['google_pay', 'apple_pay']
|
|
153
178
|
|
|
154
179
|
const isPreOrder = configs?.preorder_status_enabled?.value === '1'
|
|
180
|
+
const subtotalWithTaxes = cart?.taxes?.reduce((acc: any, item: any) => {
|
|
181
|
+
if (item?.type === 1)
|
|
182
|
+
return acc = acc + item?.summary?.tax
|
|
183
|
+
return acc = acc
|
|
184
|
+
}, cart?.subtotal)
|
|
185
|
+
|
|
186
|
+
const validateCommentsCartField = validationFields?.fields?.checkout?.comments?.enabled && validationFields?.fields?.checkout?.comments?.required && (cart?.comment === null || cart?.comment?.trim().length === 0)
|
|
187
|
+
|
|
155
188
|
const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) ||
|
|
156
|
-
placing || errorCash ||
|
|
157
|
-
|
|
189
|
+
placing || errorCash || subtotalWithTaxes < cart?.minimum ||
|
|
190
|
+
(cardsMethods.includes(paymethodSelected?.gateway) && cardList?.cards?.length === 0) ||
|
|
158
191
|
(options.type === 1 &&
|
|
159
192
|
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
160
193
|
validationFields?.fields?.checkout?.driver_tip?.required &&
|
|
161
|
-
(Number(cart?.driver_tip) <= 0))
|
|
194
|
+
(Number(cart?.driver_tip) <= 0)) ||
|
|
195
|
+
(validateCommentsCartField)
|
|
196
|
+
|| (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading))
|
|
162
197
|
|
|
163
198
|
const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
|
|
164
199
|
? JSON.parse(configs?.driver_tip_options?.value) || []
|
|
@@ -168,6 +203,9 @@ const CheckoutUI = (props: any) => {
|
|
|
168
203
|
|
|
169
204
|
const cartsWithProducts = carts && Object.values(carts).filter((cart: any) => cart.products.length) || null
|
|
170
205
|
|
|
206
|
+
const isSandboxCredomatic = configs?.credomatic_integration_sandbox?.value === '1'
|
|
207
|
+
const credomaticKeyId = isSandboxCredomatic ? configs?.credomatic_integration_public_sandbox_key?.value : configs?.credomatic_integration_public_production_key?.value
|
|
208
|
+
const credomaticUrl = `https://integrations.ordering.co/credomatic/front/auth_mobile.html?title=${t('CREDOMATIC_PAYMENT', 'Credomatic payment')}&body=${t('CREDOMATIC_PROCESSING', 'Processing transaction')}`
|
|
171
209
|
const deliveryOptions = instructionsOptions?.result && instructionsOptions?.result?.filter((option: any) => option?.enabled)?.map((option: any) => {
|
|
172
210
|
return {
|
|
173
211
|
value: option?.id, key: option?.id, label: t(option?.name.toUpperCase().replace(/\s/g, '_'), option?.name)
|
|
@@ -180,9 +218,30 @@ const CheckoutUI = (props: any) => {
|
|
|
180
218
|
}
|
|
181
219
|
}
|
|
182
220
|
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
221
|
+
const vibrateApp = (impact?: string) => {
|
|
222
|
+
const options = {
|
|
223
|
+
enableVibrateFallback: true,
|
|
224
|
+
ignoreAndroidSystemSettings: false
|
|
225
|
+
};
|
|
226
|
+
ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const handleSuccessSignup = (user: any) => {
|
|
230
|
+
login({
|
|
231
|
+
user,
|
|
232
|
+
token: user?.session?.access_token
|
|
233
|
+
})
|
|
234
|
+
setOpenModal({ ...openModal, signup: false })
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const handleSuccessLogin = (user: any) => {
|
|
238
|
+
if (user) setOpenModal({ ...openModal, login: false })
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const handlePlaceOrder = (confirmPayment: any, forcePlace: boolean = false) => {
|
|
242
|
+
if (!userErrors.length && (!requiredFields?.length || allowedGuest) || forcePlace) {
|
|
243
|
+
vibrateApp()
|
|
244
|
+
handlerClickPlaceOrder && handlerClickPlaceOrder(null, { isNative: true }, confirmPayment)
|
|
186
245
|
return
|
|
187
246
|
}
|
|
188
247
|
if (requiredFields?.length) {
|
|
@@ -197,6 +256,11 @@ const CheckoutUI = (props: any) => {
|
|
|
197
256
|
setIsUserDetailsEdit(true)
|
|
198
257
|
}
|
|
199
258
|
|
|
259
|
+
const handlePlaceOrderAsGuest = () => {
|
|
260
|
+
setIsOpen(false)
|
|
261
|
+
handlerClickPlaceOrder && handlerClickPlaceOrder()
|
|
262
|
+
}
|
|
263
|
+
|
|
200
264
|
const handlePaymentMethodClick = (paymethod: any) => {
|
|
201
265
|
setShowGateway({ closedByUser: false, open: true })
|
|
202
266
|
setWebviewPaymethod(paymethod)
|
|
@@ -260,13 +324,13 @@ const CheckoutUI = (props: any) => {
|
|
|
260
324
|
}
|
|
261
325
|
}, [errors])
|
|
262
326
|
|
|
263
|
-
// useEffect(() => {
|
|
264
|
-
// handlePaymethodChange(null)
|
|
265
|
-
// }, [cart?.total])
|
|
266
|
-
|
|
267
327
|
useEffect(() => {
|
|
268
328
|
if (cart?.products?.length === 0) {
|
|
269
|
-
|
|
329
|
+
if (cart?.business?.slug) {
|
|
330
|
+
onNavigationRedirect('Business', { store: cart?.business?.slug, header: null, logo: null })
|
|
331
|
+
} else {
|
|
332
|
+
onNavigationRedirect('Wallets')
|
|
333
|
+
}
|
|
270
334
|
}
|
|
271
335
|
}, [cart?.products])
|
|
272
336
|
|
|
@@ -274,6 +338,35 @@ const CheckoutUI = (props: any) => {
|
|
|
274
338
|
onFailPaypal()
|
|
275
339
|
}, [showGateway.closedByUser])
|
|
276
340
|
|
|
341
|
+
const HeaderTitle = (props: any) => {
|
|
342
|
+
const { text } = props
|
|
343
|
+
return (
|
|
344
|
+
<OText
|
|
345
|
+
size={16}
|
|
346
|
+
lineHeight={24}
|
|
347
|
+
weight={'500'}
|
|
348
|
+
mBottom={props.mb ?? 10}
|
|
349
|
+
color={theme.colors.textNormal}
|
|
350
|
+
>
|
|
351
|
+
{text}
|
|
352
|
+
</OText>
|
|
353
|
+
)
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
useEffect(() => {
|
|
357
|
+
cart && events.emit('checkout_started', cart)
|
|
358
|
+
}, [])
|
|
359
|
+
|
|
360
|
+
useEffect(() => {
|
|
361
|
+
if (cart?.paymethod_data?.gateway === 'credomatic') {
|
|
362
|
+
if (cart?.paymethod_data?.status === 2) {
|
|
363
|
+
setShowGateway({ ...showGateway, open: true })
|
|
364
|
+
} else if (cart?.paymethod_data?.gateway === 'credomatic' && cart?.paymethod_data?.status === 4) {
|
|
365
|
+
setShowGateway({ ...showGateway, open: false })
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}, [cart?.paymethod_data])
|
|
369
|
+
|
|
277
370
|
return (
|
|
278
371
|
<>
|
|
279
372
|
<Container noPadding>
|
|
@@ -281,24 +374,31 @@ const CheckoutUI = (props: any) => {
|
|
|
281
374
|
<NavBar
|
|
282
375
|
title={t('CHECKOUT', 'Checkout')}
|
|
283
376
|
titleAlign={'center'}
|
|
284
|
-
onActionLeft={() =>
|
|
377
|
+
onActionLeft={() => onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)}
|
|
285
378
|
showCall={false}
|
|
286
|
-
btnStyle={{ paddingLeft: 0 }}
|
|
287
|
-
style={{ marginTop: Platform.OS === 'ios' ? 0 : 30 }}
|
|
379
|
+
btnStyle={{ paddingLeft: 0, paddingTop: Platform.OS == 'ios' ? 0 : 2 }}
|
|
288
380
|
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
289
381
|
titleStyle={{ marginRight: 0, marginLeft: 0 }}
|
|
382
|
+
style={{ marginTop: 20 }}
|
|
290
383
|
/>
|
|
291
384
|
</View>
|
|
292
385
|
<ChContainer style={styles.pagePadding}>
|
|
293
386
|
<ChSection style={{ paddingTop: 0 }}>
|
|
294
387
|
<ChHeader>
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
388
|
+
<CHMomentWrapper isCustomColor={isChewLayout} onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes })}>
|
|
389
|
+
<OText
|
|
390
|
+
size={12}
|
|
391
|
+
numberOfLines={1}
|
|
392
|
+
ellipsizeMode={'tail'}
|
|
393
|
+
color={theme.colors?.[isChewLayout ? 'white' : 'textSecondary']}
|
|
394
|
+
>
|
|
395
|
+
{t(getTypesText(options?.type || 1), 'Delivery')}
|
|
396
|
+
</OText>
|
|
298
397
|
<OIcon
|
|
299
398
|
src={theme.images.general.arrow_down}
|
|
300
399
|
width={10}
|
|
301
400
|
style={{ marginStart: 8 }}
|
|
401
|
+
{...(isChewLayout && { color: 'white' })}
|
|
302
402
|
/>
|
|
303
403
|
</CHMomentWrapper>
|
|
304
404
|
<CHMomentWrapper
|
|
@@ -322,85 +422,116 @@ const CheckoutUI = (props: any) => {
|
|
|
322
422
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 18, marginHorizontal: -40 }} />
|
|
323
423
|
</ChSection>
|
|
324
424
|
|
|
325
|
-
|
|
326
|
-
<
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
425
|
+
{!isGiftCardCart && !hideBusinessDetails && (
|
|
426
|
+
<ChSection>
|
|
427
|
+
<ChBusinessDetails>
|
|
428
|
+
{
|
|
429
|
+
(businessDetails?.loading || cartState.loading || !businessDetails?.business || Object.values(businessDetails?.business).length === 0) &&
|
|
430
|
+
!businessDetails?.error &&
|
|
431
|
+
(
|
|
432
|
+
<Placeholder Animation={Fade}>
|
|
433
|
+
<PlaceholderLine height={20} />
|
|
434
|
+
<PlaceholderLine height={12} />
|
|
435
|
+
<PlaceholderLine height={12} />
|
|
436
|
+
<PlaceholderLine height={12} style={{ marginBottom: 20 }} />
|
|
437
|
+
</Placeholder>
|
|
438
|
+
)}
|
|
439
|
+
{
|
|
440
|
+
!cartState.loading &&
|
|
441
|
+
businessDetails?.business &&
|
|
442
|
+
Object.values(businessDetails?.business).length > 0 &&
|
|
443
|
+
(
|
|
444
|
+
<>
|
|
445
|
+
<HeaderTitle text={t('BUSINESS_DETAILS', 'Business Details')} />
|
|
446
|
+
<View>
|
|
447
|
+
<OText size={12} lineHeight={18} weight={'400'}>
|
|
448
|
+
{businessDetails?.business?.name}
|
|
449
|
+
</OText>
|
|
450
|
+
<OText size={12} lineHeight={18} weight={'400'}>
|
|
451
|
+
{businessDetails?.business?.email}
|
|
452
|
+
</OText>
|
|
453
|
+
<OText size={12} lineHeight={18} weight={'400'}>
|
|
454
|
+
{businessDetails?.business?.cellphone}
|
|
455
|
+
</OText>
|
|
456
|
+
{!hideBusinessAddress && (
|
|
457
|
+
<OText size={12} lineHeight={18} weight={'400'}>
|
|
458
|
+
{businessDetails?.business?.address}
|
|
459
|
+
</OText>
|
|
460
|
+
)}
|
|
461
|
+
</View>
|
|
462
|
+
</>
|
|
463
|
+
)}
|
|
464
|
+
{businessDetails?.error && businessDetails?.error?.length > 0 && (
|
|
465
|
+
<View>
|
|
466
|
+
<HeaderTitle text={t('BUSINESS_DETAILS', 'Business Details')} />
|
|
467
|
+
<NotFoundSource
|
|
468
|
+
content={businessDetails?.error[0]?.message || businessDetails?.error[0]}
|
|
469
|
+
/>
|
|
470
|
+
</View>
|
|
471
|
+
)}
|
|
472
|
+
</ChBusinessDetails>
|
|
473
|
+
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
474
|
+
</ChSection>
|
|
475
|
+
)}
|
|
476
|
+
{!hideCustomerDetails && (
|
|
477
|
+
|
|
478
|
+
<ChSection>
|
|
479
|
+
<ChUserDetails>
|
|
480
|
+
{cartState.loading ? (
|
|
331
481
|
<Placeholder Animation={Fade}>
|
|
332
482
|
<PlaceholderLine height={20} />
|
|
333
483
|
<PlaceholderLine height={12} />
|
|
334
484
|
<PlaceholderLine height={12} />
|
|
335
485
|
<PlaceholderLine height={12} style={{ marginBottom: 20 }} />
|
|
336
486
|
</Placeholder>
|
|
337
|
-
)
|
|
338
|
-
|
|
339
|
-
!cartState.loading &&
|
|
340
|
-
businessDetails?.business &&
|
|
341
|
-
Object.values(businessDetails?.business).length > 0 &&
|
|
342
|
-
(
|
|
343
|
-
<>
|
|
344
|
-
<OText size={16} lineHeight={24} weight={'500'} mBottom={10}>
|
|
345
|
-
{t('BUSINESS_DETAILS', 'Business Details')}
|
|
346
|
-
</OText>
|
|
487
|
+
) : (
|
|
488
|
+
(user?.guest_id && !allowedGuest) ? (
|
|
347
489
|
<View>
|
|
348
|
-
<
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
{
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
{
|
|
359
|
-
|
|
490
|
+
<HeaderTitle text={t('CUSTOMER_DETAILS', 'Customer details')} />
|
|
491
|
+
<OButton
|
|
492
|
+
text={t('SIGN_UP', 'Sign up')}
|
|
493
|
+
textStyle={{ color: theme.colors.white }}
|
|
494
|
+
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
495
|
+
onClick={() => setOpenModal({ ...openModal, signup: true })}
|
|
496
|
+
/>
|
|
497
|
+
<OButton
|
|
498
|
+
text={t('LOGIN', 'Login')}
|
|
499
|
+
textStyle={{ color: theme.colors.primary }}
|
|
500
|
+
bgColor={theme.colors.white}
|
|
501
|
+
borderColor={theme.colors.primary}
|
|
502
|
+
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
503
|
+
onClick={() => setOpenModal({ ...openModal, login: true })}
|
|
504
|
+
/>
|
|
505
|
+
<OButton
|
|
506
|
+
text={t('CONTINUE_AS_GUEST', 'Continue as guest')}
|
|
507
|
+
textStyle={{ color: theme.colors.black }}
|
|
508
|
+
bgColor={theme.colors.white}
|
|
509
|
+
borderColor={theme.colors.black}
|
|
510
|
+
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
511
|
+
onClick={() => setAllowedGuest(true)}
|
|
512
|
+
/>
|
|
360
513
|
</View>
|
|
361
|
-
|
|
514
|
+
) : (
|
|
515
|
+
<UserDetails
|
|
516
|
+
isUserDetailsEdit={isUserDetailsEdit}
|
|
517
|
+
HeaderTitle={<HeaderTitle text={t('CUSTOMER_DETAILS', 'Customer Details')} mb={0} />}
|
|
518
|
+
cartStatus={cart?.status}
|
|
519
|
+
businessId={cart?.business_id}
|
|
520
|
+
useValidationFields
|
|
521
|
+
useDefualtSessionManager
|
|
522
|
+
useSessionUser
|
|
523
|
+
isCheckout
|
|
524
|
+
phoneUpdate={phoneUpdate}
|
|
525
|
+
togglePhoneUpdate={togglePhoneUpdate}
|
|
526
|
+
/>
|
|
527
|
+
)
|
|
362
528
|
)}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
</OText>
|
|
368
|
-
<NotFoundSource
|
|
369
|
-
content={businessDetails?.error[0]?.message || businessDetails?.error[0]}
|
|
370
|
-
/>
|
|
371
|
-
</View>
|
|
372
|
-
)}
|
|
373
|
-
</ChBusinessDetails>
|
|
374
|
-
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
375
|
-
</ChSection>
|
|
376
|
-
|
|
377
|
-
<ChSection>
|
|
378
|
-
<ChUserDetails>
|
|
379
|
-
{cartState.loading ? (
|
|
380
|
-
<Placeholder Animation={Fade}>
|
|
381
|
-
<PlaceholderLine height={20} />
|
|
382
|
-
<PlaceholderLine height={12} />
|
|
383
|
-
<PlaceholderLine height={12} />
|
|
384
|
-
<PlaceholderLine height={12} style={{ marginBottom: 20 }} />
|
|
385
|
-
</Placeholder>
|
|
386
|
-
) : (
|
|
387
|
-
<UserDetails
|
|
388
|
-
isUserDetailsEdit={isUserDetailsEdit}
|
|
389
|
-
cartStatus={cart?.status}
|
|
390
|
-
businessId={cart?.business_id}
|
|
391
|
-
useValidationFields
|
|
392
|
-
useDefualtSessionManager
|
|
393
|
-
useSessionUser
|
|
394
|
-
isCheckout
|
|
395
|
-
phoneUpdate={phoneUpdate}
|
|
396
|
-
togglePhoneUpdate={togglePhoneUpdate}
|
|
397
|
-
/>
|
|
398
|
-
)}
|
|
399
|
-
</ChUserDetails>
|
|
400
|
-
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
401
|
-
</ChSection>
|
|
529
|
+
</ChUserDetails>
|
|
530
|
+
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
531
|
+
</ChSection>
|
|
532
|
+
)}
|
|
402
533
|
|
|
403
|
-
{options?.type === 1 && (
|
|
534
|
+
{options?.type === 1 && !isGiftCardCart && (
|
|
404
535
|
<DeliveryOptionsContainer>
|
|
405
536
|
{cartState.loading || deliveryOptionSelected === undefined ? (
|
|
406
537
|
<View style={{ height: 110 }}>
|
|
@@ -410,8 +541,8 @@ const CheckoutUI = (props: any) => {
|
|
|
410
541
|
</Placeholder>
|
|
411
542
|
</View>
|
|
412
543
|
) : (
|
|
413
|
-
|
|
414
|
-
<
|
|
544
|
+
<ChSection>
|
|
545
|
+
<HeaderTitle text={t('DELIVERY_OPTIONS', 'Delivery options')} />
|
|
415
546
|
<View
|
|
416
547
|
style={{
|
|
417
548
|
backgroundColor: theme.colors.inputDisabled,
|
|
@@ -430,7 +561,7 @@ const CheckoutUI = (props: any) => {
|
|
|
430
561
|
<OText
|
|
431
562
|
size={14}
|
|
432
563
|
>
|
|
433
|
-
{deliveryOptions.find((option: any) => option.value === deliveryOptionSelected)
|
|
564
|
+
{deliveryOptions.find((option: any) => option.value === deliveryOptionSelected)?.label}
|
|
434
565
|
</OText>
|
|
435
566
|
<MaterialIcons name='keyboard-arrow-down' style={styles.icon} />
|
|
436
567
|
</DeliveryOptionItem>
|
|
@@ -457,7 +588,7 @@ const CheckoutUI = (props: any) => {
|
|
|
457
588
|
/>
|
|
458
589
|
</View>
|
|
459
590
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
460
|
-
|
|
591
|
+
</ChSection>
|
|
461
592
|
)}
|
|
462
593
|
|
|
463
594
|
</DeliveryOptionsContainer>
|
|
@@ -479,50 +610,30 @@ const CheckoutUI = (props: any) => {
|
|
|
479
610
|
</ChSection>
|
|
480
611
|
)}
|
|
481
612
|
|
|
482
|
-
{
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
<ChAddress>
|
|
507
|
-
{(businessDetails?.loading || cartState.loading) ? (
|
|
508
|
-
<Placeholder Animation={Fade}>
|
|
509
|
-
<PlaceholderLine height={20} style={{ marginBottom: 50 }} />
|
|
510
|
-
<PlaceholderLine height={100} />
|
|
511
|
-
</Placeholder>
|
|
512
|
-
) : (
|
|
513
|
-
<AddressDetails
|
|
514
|
-
navigation={navigation}
|
|
515
|
-
location={businessDetails?.business?.location}
|
|
516
|
-
businessLogo={businessDetails?.business?.logo}
|
|
517
|
-
isCartPending={cart?.status === 2}
|
|
518
|
-
uuid={cartUuid}
|
|
519
|
-
apiKey={configs?.google_maps_api_key?.value}
|
|
520
|
-
mapConfigs={mapConfigs}
|
|
521
|
-
/>
|
|
522
|
-
)}
|
|
523
|
-
</ChAddress>
|
|
524
|
-
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
|
|
525
|
-
</ChSection>
|
|
613
|
+
{!isGiftCardCart && !hideBusinessMap && (
|
|
614
|
+
<ChSection>
|
|
615
|
+
<ChAddress>
|
|
616
|
+
{(businessDetails?.loading || cartState.loading) ? (
|
|
617
|
+
<Placeholder Animation={Fade}>
|
|
618
|
+
<PlaceholderLine height={20} style={{ marginBottom: 50 }} />
|
|
619
|
+
<PlaceholderLine height={100} />
|
|
620
|
+
</Placeholder>
|
|
621
|
+
) : (
|
|
622
|
+
<AddressDetails
|
|
623
|
+
navigation={navigation}
|
|
624
|
+
location={options?.address?.location}
|
|
625
|
+
businessLogo={businessDetails?.business?.logo}
|
|
626
|
+
isCartPending={cart?.status === 2}
|
|
627
|
+
uuid={cartUuid}
|
|
628
|
+
apiKey={configs?.google_maps_api_key?.value}
|
|
629
|
+
mapConfigs={mapConfigs}
|
|
630
|
+
HeaderTitle={<HeaderTitle text={t('DELIVERY_ADDRESS', 'Delivery address')} mb={0} />}
|
|
631
|
+
/>
|
|
632
|
+
)}
|
|
633
|
+
</ChAddress>
|
|
634
|
+
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
|
|
635
|
+
</ChSection>
|
|
636
|
+
)}
|
|
526
637
|
|
|
527
638
|
{!cartState.loading &&
|
|
528
639
|
cart &&
|
|
@@ -531,22 +642,22 @@ const CheckoutUI = (props: any) => {
|
|
|
531
642
|
cart?.status !== 2 &&
|
|
532
643
|
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
533
644
|
driverTipsOptions && driverTipsOptions?.length > 0 &&
|
|
645
|
+
!isGiftCardCart &&
|
|
534
646
|
(
|
|
535
647
|
<ChSection>
|
|
536
648
|
<ChDriverTips>
|
|
537
|
-
<
|
|
538
|
-
{t('DRIVER_TIPS', 'Driver Tips')}
|
|
539
|
-
</OText>
|
|
649
|
+
<HeaderTitle text={t('DRIVER_TIPS', 'Driver Tips')} mb={0} />
|
|
540
650
|
<DriverTips
|
|
541
651
|
uuid={cartUuid}
|
|
542
652
|
businessId={cart?.business_id}
|
|
543
|
-
driverTipsOptions={driverTipsOptions}
|
|
544
|
-
isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1
|
|
653
|
+
driverTipsOptions={!driverTipsOptions.includes(0) ? [0, ...driverTipsOptions] : driverTipsOptions}
|
|
654
|
+
isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1}
|
|
545
655
|
isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
|
|
546
|
-
driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1
|
|
656
|
+
driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1
|
|
547
657
|
? cart?.driver_tip
|
|
548
658
|
: cart?.driver_tip_rate}
|
|
549
659
|
useOrderContext
|
|
660
|
+
cart={cart}
|
|
550
661
|
/>
|
|
551
662
|
</ChDriverTips>
|
|
552
663
|
</ChSection>
|
|
@@ -555,9 +666,7 @@ const CheckoutUI = (props: any) => {
|
|
|
555
666
|
{!cartState.loading && cart && cart?.status !== 2 && cart?.valid && (
|
|
556
667
|
<ChSection>
|
|
557
668
|
<ChPaymethods>
|
|
558
|
-
<
|
|
559
|
-
{t('PAYMENT_METHOD', 'Payment Method')}
|
|
560
|
-
</OText>
|
|
669
|
+
<HeaderTitle text={t('PAYMENT_METHOD', 'Payment Method')} mb={0} />
|
|
561
670
|
{!cartState.loading && cart?.status === 4 && (
|
|
562
671
|
<OText
|
|
563
672
|
style={{ textAlign: 'center', marginTop: 20 }}
|
|
@@ -570,8 +679,8 @@ const CheckoutUI = (props: any) => {
|
|
|
570
679
|
<PaymentOptions
|
|
571
680
|
cart={cart}
|
|
572
681
|
isDisabled={cart?.status === 2}
|
|
573
|
-
businessId={businessDetails?.business?.id}
|
|
574
|
-
isLoading={businessDetails.loading}
|
|
682
|
+
businessId={!isGiftCardCart ? businessDetails?.business?.id : -1}
|
|
683
|
+
isLoading={!isGiftCardCart ? businessDetails.loading : false}
|
|
575
684
|
paymethods={businessDetails?.business?.paymethods}
|
|
576
685
|
onPaymentChange={handlePaymethodChange}
|
|
577
686
|
errorCash={errorCash}
|
|
@@ -581,6 +690,12 @@ const CheckoutUI = (props: any) => {
|
|
|
581
690
|
handlePaymentMethodClickCustom={handlePaymentMethodClick}
|
|
582
691
|
handlePlaceOrder={handlePlaceOrder}
|
|
583
692
|
merchantId={merchantId}
|
|
693
|
+
setMethodPaySupported={setMethodPaySupported}
|
|
694
|
+
methodPaySupported={methodPaySupported}
|
|
695
|
+
placeByMethodPay={placeByMethodPay}
|
|
696
|
+
setPlaceByMethodPay={setPlaceByMethodPay}
|
|
697
|
+
cardList={cardList}
|
|
698
|
+
setCardList={setCardList}
|
|
584
699
|
/>
|
|
585
700
|
</ChPaymethods>
|
|
586
701
|
</ChSection>
|
|
@@ -590,6 +705,7 @@ const CheckoutUI = (props: any) => {
|
|
|
590
705
|
<WalletPaymentOptionContainer>
|
|
591
706
|
<PaymentOptionWallet
|
|
592
707
|
cart={cart}
|
|
708
|
+
loyaltyPlansState={loyaltyPlansState}
|
|
593
709
|
businessId={cart?.business_id}
|
|
594
710
|
businessConfigs={businessDetails?.business?.configs}
|
|
595
711
|
/>
|
|
@@ -597,7 +713,7 @@ const CheckoutUI = (props: any) => {
|
|
|
597
713
|
)}
|
|
598
714
|
|
|
599
715
|
|
|
600
|
-
{!cartState.loading && placeSpotsEnabled && (
|
|
716
|
+
{!cartState.loading && placeSpotsEnabled && !isGiftCardCart && (
|
|
601
717
|
<>
|
|
602
718
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 30, marginHorizontal: -40 }} />
|
|
603
719
|
<PlaceSpot
|
|
@@ -605,6 +721,7 @@ const CheckoutUI = (props: any) => {
|
|
|
605
721
|
isInputMode
|
|
606
722
|
cart={cart}
|
|
607
723
|
spotNumberDefault={cartState?.cart?.spot_number ?? cart?.spot_number}
|
|
724
|
+
setPlaceSpotNumber={setPlaceSpotNumber}
|
|
608
725
|
vehicleDefault={cart?.vehicle}
|
|
609
726
|
/>
|
|
610
727
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
@@ -622,26 +739,21 @@ const CheckoutUI = (props: any) => {
|
|
|
622
739
|
) : (
|
|
623
740
|
<>
|
|
624
741
|
<CartHeader>
|
|
625
|
-
<
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
style={{ fontWeight: '500' }}
|
|
630
|
-
>
|
|
631
|
-
{t('MOBILE_FRONT_YOUR_ORDER', 'Your order')}
|
|
632
|
-
</OText>
|
|
633
|
-
<TouchableOpacity
|
|
634
|
-
onPress={() => onNavigationRedirect('Business', { store: cart?.business?.slug })}
|
|
635
|
-
>
|
|
636
|
-
<OText
|
|
637
|
-
size={10}
|
|
638
|
-
lineHeight={15}
|
|
639
|
-
color={theme.colors.primary}
|
|
640
|
-
style={{ textDecorationLine: 'underline' }}
|
|
742
|
+
<HeaderTitle text={t('MOBILE_FRONT_YOUR_ORDER', 'Your order')} mb={0} />
|
|
743
|
+
{!isGiftCardCart && (
|
|
744
|
+
<TouchableOpacity
|
|
745
|
+
onPress={() => onNavigationRedirect('Business', { store: cart?.business?.slug })}
|
|
641
746
|
>
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
747
|
+
<OText
|
|
748
|
+
size={12}
|
|
749
|
+
lineHeight={15}
|
|
750
|
+
color={theme.colors.primary}
|
|
751
|
+
style={{ textDecorationLine: 'underline' }}
|
|
752
|
+
>
|
|
753
|
+
{t('ADD_PRODUCTS', 'Add products')}
|
|
754
|
+
</OText>
|
|
755
|
+
</TouchableOpacity>
|
|
756
|
+
)}
|
|
645
757
|
</CartHeader>
|
|
646
758
|
{isBusinessChangeEnabled && (
|
|
647
759
|
<TouchableOpacity
|
|
@@ -651,7 +763,7 @@ const CheckoutUI = (props: any) => {
|
|
|
651
763
|
<OText
|
|
652
764
|
size={12}
|
|
653
765
|
lineHeight={18}
|
|
654
|
-
color={theme.colors.
|
|
766
|
+
color={theme.colors.primary}
|
|
655
767
|
style={{ textDecorationLine: 'underline' }}
|
|
656
768
|
>
|
|
657
769
|
{t('CHANGE_STORE', 'Change store')}
|
|
@@ -663,6 +775,12 @@ const CheckoutUI = (props: any) => {
|
|
|
663
775
|
isCartPending={cart?.status === 2}
|
|
664
776
|
onNavigationRedirect={onNavigationRedirect}
|
|
665
777
|
placeSpotTypes={placeSpotTypes}
|
|
778
|
+
businessConfigs={businessConfigs}
|
|
779
|
+
maxDate={maxDate}
|
|
780
|
+
loyaltyRewardRate={
|
|
781
|
+
creditPointPlanOnBusiness?.accumulation_rate ??
|
|
782
|
+
(!!creditPointPlanOnBusiness && creditPointPlan?.accumulation_rate) ?? 0
|
|
783
|
+
}
|
|
666
784
|
/>
|
|
667
785
|
</>
|
|
668
786
|
)}
|
|
@@ -672,7 +790,7 @@ const CheckoutUI = (props: any) => {
|
|
|
672
790
|
|
|
673
791
|
{!cartState.loading && cart && (
|
|
674
792
|
<View>
|
|
675
|
-
<ChErrors style={{ marginBottom: 10 }}>
|
|
793
|
+
<ChErrors style={{ marginBottom: Platform.OS === 'ios' ? 35 : 10 }}>
|
|
676
794
|
{!cart?.valid_address && cart?.status !== 2 && (
|
|
677
795
|
<OText
|
|
678
796
|
color={theme.colors.error}
|
|
@@ -699,6 +817,14 @@ const CheckoutUI = (props: any) => {
|
|
|
699
817
|
{t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
|
|
700
818
|
</OText>
|
|
701
819
|
)}
|
|
820
|
+
{cart?.valid_preorder !== undefined && !cart?.valid_preorder && (
|
|
821
|
+
<OText
|
|
822
|
+
color={theme.colors.error}
|
|
823
|
+
size={12}
|
|
824
|
+
>
|
|
825
|
+
{t('INVALID_CART_MOMENT', 'Selected schedule time is invalid, please select a schedule into the business schedule interval.')}
|
|
826
|
+
</OText>
|
|
827
|
+
)}
|
|
702
828
|
{options.type === 1 &&
|
|
703
829
|
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
704
830
|
validationFields?.fields?.checkout?.driver_tip?.required &&
|
|
@@ -710,6 +836,15 @@ const CheckoutUI = (props: any) => {
|
|
|
710
836
|
{t('WARNING_INVALID_DRIVER_TIP', 'Driver Tip is required.')}
|
|
711
837
|
</OText>
|
|
712
838
|
)}
|
|
839
|
+
|
|
840
|
+
{validateCommentsCartField && (
|
|
841
|
+
<OText
|
|
842
|
+
color={theme.colors.error}
|
|
843
|
+
size={12}
|
|
844
|
+
>
|
|
845
|
+
{t('WARNING_INVALID_CART_COMMENTS', 'Cart comments is required.')}
|
|
846
|
+
</OText>
|
|
847
|
+
)}
|
|
713
848
|
</ChErrors>
|
|
714
849
|
</View>
|
|
715
850
|
)}
|
|
@@ -742,18 +877,55 @@ const CheckoutUI = (props: any) => {
|
|
|
742
877
|
togglePhoneUpdate={togglePhoneUpdate}
|
|
743
878
|
requiredFields={requiredFields}
|
|
744
879
|
hideUpdateButton
|
|
745
|
-
|
|
880
|
+
handlePlaceOrderAsGuest={handlePlaceOrderAsGuest}
|
|
881
|
+
onClose={() => {
|
|
882
|
+
setIsOpen(false)
|
|
883
|
+
handlePlaceOrder(null, true)
|
|
884
|
+
}}
|
|
885
|
+
setIsOpen={setIsOpen}
|
|
746
886
|
/>
|
|
747
887
|
</View>
|
|
748
888
|
</OModal>
|
|
889
|
+
<OModal
|
|
890
|
+
open={openModal.signup}
|
|
891
|
+
onClose={() => setOpenModal({ ...openModal, signup: false })}
|
|
892
|
+
>
|
|
893
|
+
<ScrollView style={{ paddingHorizontal: 20, width: '100%' }}>
|
|
894
|
+
<SignupForm
|
|
895
|
+
handleSuccessSignup={handleSuccessSignup}
|
|
896
|
+
isGuest
|
|
897
|
+
signupButtonText={t('SIGNUP', 'Signup')}
|
|
898
|
+
useSignupByEmail
|
|
899
|
+
useChekoutFileds
|
|
900
|
+
/>
|
|
901
|
+
</ScrollView>
|
|
902
|
+
</OModal>
|
|
903
|
+
<OModal
|
|
904
|
+
open={openModal.login}
|
|
905
|
+
onClose={() => setOpenModal({ ...openModal, login: false })}
|
|
906
|
+
>
|
|
907
|
+
<ScrollView style={{ paddingHorizontal: 20, width: '100%' }}>
|
|
908
|
+
<LoginForm
|
|
909
|
+
handleSuccessLogin={handleSuccessLogin}
|
|
910
|
+
isGuest
|
|
911
|
+
loginButtonText={t('LOGIN', 'Login')}
|
|
912
|
+
loginButtonBackground={theme.colors.primary}
|
|
913
|
+
/>
|
|
914
|
+
</ScrollView>
|
|
915
|
+
</OModal>
|
|
749
916
|
</ChContainer>
|
|
750
917
|
</Container>
|
|
751
918
|
{!cartState.loading && cart && cart?.status !== 2 && (
|
|
752
919
|
<FloatingButton
|
|
753
|
-
handleClick={
|
|
920
|
+
handleClick={
|
|
921
|
+
isDisabledButtonPlace
|
|
922
|
+
? () => vibrateApp()
|
|
923
|
+
: methodsPay.includes(paymethodSelected?.gateway)
|
|
924
|
+
? () => setPlaceByMethodPay(true)
|
|
925
|
+
: () => handlePlaceOrder(null)}
|
|
754
926
|
isSecondaryBtn={isDisabledButtonPlace}
|
|
755
927
|
disabled={isDisabledButtonPlace}
|
|
756
|
-
btnText={
|
|
928
|
+
btnText={subtotalWithTaxes >= cart?.minimum
|
|
757
929
|
? (
|
|
758
930
|
placing
|
|
759
931
|
? t('PLACING', 'Placing')
|
|
@@ -793,6 +965,29 @@ const CheckoutUI = (props: any) => {
|
|
|
793
965
|
locationId={'L1NGAY5M6KJRX'}
|
|
794
966
|
/>
|
|
795
967
|
)}
|
|
968
|
+
{cart?.paymethod_data?.gateway === 'credomatic' && cart?.paymethod_data?.status === 2 && showGateway.open && (
|
|
969
|
+
<PaymentOptionsWebView
|
|
970
|
+
title={t('CREDOMATIC_PAYMENT', 'Credomatic payment')}
|
|
971
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
972
|
+
uri={credomaticUrl}
|
|
973
|
+
user={user}
|
|
974
|
+
cart={cart}
|
|
975
|
+
additionalParams={{
|
|
976
|
+
type: 'auth',
|
|
977
|
+
key_id: credomaticKeyId,
|
|
978
|
+
hash: cart?.paymethod_data?.result?.hash,
|
|
979
|
+
time: cart?.paymethod_data?.result?.time,
|
|
980
|
+
amount: cart?.total,
|
|
981
|
+
orderid: cart?.uuid,
|
|
982
|
+
ccnumber: cardList?.cards?.[0]?.number,
|
|
983
|
+
ccexp: cardList?.cards?.[0]?.expiryString,
|
|
984
|
+
cvv: cardList?.cards?.[0]?.cvc,
|
|
985
|
+
redirect: credomaticUrl
|
|
986
|
+
}}
|
|
987
|
+
webviewPaymethod={webviewPaymethod}
|
|
988
|
+
setShowGateway={setShowGateway}
|
|
989
|
+
/>
|
|
990
|
+
)}
|
|
796
991
|
</>
|
|
797
992
|
)
|
|
798
993
|
}
|
|
@@ -819,7 +1014,8 @@ export const Checkout = (props: any) => {
|
|
|
819
1014
|
const getOrder = async (cartId: any) => {
|
|
820
1015
|
try {
|
|
821
1016
|
let result: any = {}
|
|
822
|
-
const
|
|
1017
|
+
const cartsWithProducts = orderState?.carts && (Object.values(orderState?.carts)?.filter(cart => cart?.products && cart?.products?.length) || null)
|
|
1018
|
+
const cart = cartsWithProducts?.find((cart: any) => cart.uuid === cartId)
|
|
823
1019
|
if (cart) {
|
|
824
1020
|
result = { ...cart }
|
|
825
1021
|
} else {
|