ordering-ui-react-native 0.17.60 → 0.17.61-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/PhoneInputNumber/index.tsx +6 -2
- package/src/components/StripeMethodForm/index.tsx +136 -102
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OToast.tsx +2 -2
- package/src/types/index.tsx +5 -0
- package/src/utils/index.tsx +5 -0
- package/themes/business/index.tsx +2 -0
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +270 -245
- 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 +123 -111
- package/themes/business/src/components/DriverMap/index.tsx +17 -6
- package/themes/business/src/components/DriverSchedule/index.tsx +42 -5
- package/themes/business/src/components/GoogleMap/index.tsx +58 -57
- package/themes/business/src/components/LoginForm/Otp/index.tsx +31 -3
- package/themes/business/src/components/LoginForm/index.tsx +15 -22
- package/themes/business/src/components/MapView/index.tsx +10 -10
- package/themes/business/src/components/NewOrderNotification/index.tsx +35 -21
- package/themes/business/src/components/NotFoundSource/index.tsx +2 -2
- package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +191 -6
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +130 -61
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +64 -63
- 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 +19 -18
- 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 +249 -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 +30 -15
- package/themes/business/src/components/StoresList/index.tsx +3 -4
- package/themes/business/src/components/UserProfileForm/index.tsx +11 -13
- 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 +28 -12
- package/themes/business/src/utils/index.tsx +29 -2
- 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/Checkout/index.tsx +6 -0
- package/themes/kiosk/src/components/Intro/index.tsx +16 -1
- package/themes/kiosk/src/components/LoginForm/index.tsx +7 -9
- 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 +2 -2
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/original/index.tsx +4 -0
- package/themes/original/src/components/AddressDetails/index.tsx +28 -10
- package/themes/original/src/components/AddressForm/index.tsx +68 -40
- package/themes/original/src/components/AddressList/index.tsx +27 -22
- 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/AppleLogin/styles.tsx +3 -1
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +153 -96
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +10 -12
- package/themes/original/src/components/BusinessController/index.tsx +122 -68
- package/themes/original/src/components/BusinessController/styles.tsx +23 -4
- 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 +142 -109
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +15 -20
- package/themes/original/src/components/BusinessListingSearch/index.tsx +352 -326
- package/themes/original/src/components/BusinessListingSearch/styles.tsx +0 -18
- package/themes/original/src/components/BusinessPreorder/index.tsx +103 -19
- package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -2
- package/themes/original/src/components/BusinessProductsList/index.tsx +25 -15
- 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 -555
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -2
- 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 +97 -91
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +0 -1
- package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
- package/themes/original/src/components/Cart/index.tsx +77 -50
- package/themes/original/src/components/CartContent/index.tsx +117 -20
- package/themes/original/src/components/CartContent/styles.tsx +17 -7
- package/themes/original/src/components/Checkout/index.tsx +387 -172
- 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/FacebookLogin/styles.tsx +3 -1
- package/themes/original/src/components/Favorite/index.tsx +8 -9
- package/themes/original/src/components/Favorite/styles.tsx +1 -1
- package/themes/original/src/components/FavoriteList/index.tsx +1 -35
- 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/GoogleLogin/styles.tsx +1 -1
- package/themes/original/src/components/GoogleMap/index.tsx +60 -5
- package/themes/original/src/components/Help/index.tsx +8 -8
- package/themes/original/src/components/HelpAccountAndPayment/index.tsx +10 -31
- package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +5 -3
- package/themes/original/src/components/HelpGuide/index.tsx +6 -6
- package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
- package/themes/original/src/components/HelpOrder/index.tsx +6 -15
- 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 +55 -13
- package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
- package/themes/original/src/components/LoginForm/index.tsx +59 -34
- package/themes/original/src/components/LottieAnimation/index.tsx +89 -55
- package/themes/original/src/components/MessageListing/index.tsx +16 -42
- package/themes/original/src/components/Messages/index.tsx +29 -7
- package/themes/original/src/components/MomentOption/index.tsx +195 -90
- package/themes/original/src/components/MomentSelector/index.tsx +1 -1
- package/themes/original/src/components/MultiCart/index.tsx +50 -0
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +162 -51
- package/themes/original/src/components/MultiCheckout/index.tsx +308 -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 +76 -65
- package/themes/original/src/components/NavBar/index.tsx +20 -17
- 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 +190 -363
- 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 +33 -56
- package/themes/original/src/components/OrderSummary/index.tsx +88 -59
- package/themes/original/src/components/OrderTypeSelector/index.tsx +2 -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 +78 -67
- package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
- package/themes/original/src/components/PageBanner/index.tsx +106 -31
- package/themes/original/src/components/PageBanner/styles.tsx +4 -4
- 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 +78 -35
- package/themes/original/src/components/PhoneInputNumber/index.tsx +3 -3
- package/themes/original/src/components/ProductForm/index.tsx +114 -35
- package/themes/original/src/components/ProductForm/styles.tsx +6 -8
- package/themes/original/src/components/ProductItemAccordion/index.tsx +22 -19
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +34 -24
- package/themes/original/src/components/ProductOptionSubOption/styles.tsx +5 -10
- 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/ReviewOrder/index.tsx +26 -9
- package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
- package/themes/original/src/components/ReviewProducts/index.tsx +16 -7
- 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 +66 -17
- 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 +43 -27
- package/themes/original/src/components/SingleOrderCard/index.tsx +130 -56
- package/themes/original/src/components/SingleOrderCard/styles.tsx +11 -2
- package/themes/original/src/components/SingleProductCard/index.tsx +71 -34
- package/themes/original/src/components/SingleProductCard/styles.tsx +21 -4
- package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
- package/themes/original/src/components/StripeCardsList/index.tsx +49 -5
- package/themes/original/src/components/StripeElementsForm/index.tsx +48 -34
- package/themes/original/src/components/StripeElementsForm/naked.tsx +12 -1
- 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 +76 -7
- package/themes/original/src/components/UserFormDetails/styles.tsx +1 -1
- package/themes/original/src/components/UserProfile/index.tsx +88 -79
- package/themes/original/src/components/UserProfileForm/index.tsx +27 -29
- 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 +66 -30
- package/themes/original/src/components/Wallets/styles.tsx +3 -4
- package/themes/original/src/components/shared/HeaderTitle.tsx +1 -1
- package/themes/original/src/components/shared/OButton.tsx +6 -2
- package/themes/original/src/components/shared/OInput.tsx +6 -1
- package/themes/original/src/components/shared/OModal.tsx +3 -3
- package/themes/original/src/layouts/Container.tsx +1 -1
- package/themes/original/src/types/index.tsx +40 -10
- package/themes/original/src/utils/index.tsx +273 -1
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { View, StyleSheet, TouchableOpacity, Platform, I18nManager,
|
|
1
|
+
import React, { useState, useEffect, useCallback } from 'react';
|
|
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,
|
|
@@ -52,6 +56,8 @@ import { OrderSummary } from '../OrderSummary';
|
|
|
52
56
|
import { getTypesText } from '../../utils';
|
|
53
57
|
import { CartStoresListing } from '../CartStoresListing';
|
|
54
58
|
import { PaymentOptionsWebView } from '../../../../../src/components/PaymentOptionsWebView';
|
|
59
|
+
import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
|
|
60
|
+
const { useDeviceOrientation } = DeviceOrientationMethods
|
|
55
61
|
|
|
56
62
|
const mapConfigs = {
|
|
57
63
|
mapZoom: 16,
|
|
@@ -78,6 +84,7 @@ const CheckoutUI = (props: any) => {
|
|
|
78
84
|
placing,
|
|
79
85
|
cartState,
|
|
80
86
|
cartUuid,
|
|
87
|
+
loyaltyPlansState,
|
|
81
88
|
businessDetails,
|
|
82
89
|
paymethodSelected,
|
|
83
90
|
handlePaymethodChange,
|
|
@@ -88,7 +95,8 @@ const CheckoutUI = (props: any) => {
|
|
|
88
95
|
handleChangeDeliveryOption,
|
|
89
96
|
currency,
|
|
90
97
|
merchantId,
|
|
91
|
-
setPlaceSpotNumber
|
|
98
|
+
setPlaceSpotNumber,
|
|
99
|
+
maxDate
|
|
92
100
|
} = props
|
|
93
101
|
|
|
94
102
|
const theme = useTheme();
|
|
@@ -128,12 +136,17 @@ const CheckoutUI = (props: any) => {
|
|
|
128
136
|
|
|
129
137
|
const [, { showToast }] = useToast();
|
|
130
138
|
const [, t] = useLanguage();
|
|
131
|
-
const [{ user, token }] = useSession();
|
|
139
|
+
const [{ user, token }, { login }] = useSession();
|
|
132
140
|
const [ordering] = useApi()
|
|
133
141
|
const [{ configs }] = useConfig();
|
|
134
142
|
const [{ parsePrice, parseDate }] = useUtils();
|
|
135
143
|
const [{ options, carts, loading }, { confirmCart }] = useOrder();
|
|
136
144
|
const [validationFields] = useValidationFields();
|
|
145
|
+
const [events] = useEvent()
|
|
146
|
+
const [orientationState] = useDeviceOrientation();
|
|
147
|
+
const [isReadMore, setIsReadMore] = useState(false)
|
|
148
|
+
const [lengthMore, setLengthMore] = useState(false)
|
|
149
|
+
const WIDTH_SCREEN = orientationState?.dimensions?.width
|
|
137
150
|
|
|
138
151
|
const [errorCash, setErrorCash] = useState(false);
|
|
139
152
|
const [userErrors, setUserErrors] = useState<any>([]);
|
|
@@ -145,14 +158,29 @@ const CheckoutUI = (props: any) => {
|
|
|
145
158
|
const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
|
|
146
159
|
const [isOpen, setIsOpen] = useState(false)
|
|
147
160
|
const [requiredFields, setRequiredFields] = useState<any>([])
|
|
148
|
-
|
|
161
|
+
const [openModal, setOpenModal] = useState({ login: false, signup: false })
|
|
162
|
+
const [allowedGuest, setAllowedGuest] = useState(false)
|
|
163
|
+
const [placeByMethodPay, setPlaceByMethodPay] = useState(false)
|
|
164
|
+
const [methodPaySupported, setMethodPaySupported] = useState({ enabled: false, message: null, loading: true })
|
|
165
|
+
const [cardList, setCardList] = useState<any>({ cards: [], loading: false, error: null })
|
|
166
|
+
const cardsMethods = ['credomatic']
|
|
149
167
|
const placeSpotTypes = [3, 4, 5]
|
|
150
168
|
const placeSpotsEnabled = placeSpotTypes.includes(options?.type)
|
|
169
|
+
const isGiftCardCart = !cart?.business_id
|
|
151
170
|
const businessConfigs = businessDetails?.business?.configs ?? []
|
|
152
171
|
const isWalletCashEnabled = businessConfigs.find((config: any) => config.key === 'wallet_cash_enabled')?.value === '1'
|
|
153
172
|
const isWalletCreditPointsEnabled = businessConfigs.find((config: any) => config.key === 'wallet_credit_point_enabled')?.value === '1'
|
|
154
173
|
const isWalletEnabled = configs?.cash_wallet?.value && configs?.wallet_enabled?.value === '1' && (isWalletCashEnabled || isWalletCreditPointsEnabled)
|
|
155
174
|
const isBusinessChangeEnabled = configs?.cart_change_business_validation?.value === '1'
|
|
175
|
+
const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
|
|
176
|
+
const hideBusinessAddress = theme?.checkout?.components?.business?.components?.address?.hidden
|
|
177
|
+
const hideBusinessDetails = theme?.checkout?.components?.business?.hidden
|
|
178
|
+
const hideBusinessMap = theme?.checkout?.components?.business?.components?.map?.hidden
|
|
179
|
+
const hideCustomerDetails = theme?.checkout?.components?.customer?.hidden
|
|
180
|
+
|
|
181
|
+
const creditPointPlan = loyaltyPlansState?.result?.find((loyal: any) => loyal.type === 'credit_point')
|
|
182
|
+
const creditPointPlanOnBusiness = creditPointPlan?.businesses?.find((b: any) => b.business_id === cart?.business_id && b.accumulates)
|
|
183
|
+
const methodsPay = ['google_pay', 'apple_pay']
|
|
156
184
|
|
|
157
185
|
const isPreOrder = configs?.preorder_status_enabled?.value === '1'
|
|
158
186
|
const subtotalWithTaxes = cart?.taxes?.reduce((acc: any, item: any) => {
|
|
@@ -160,13 +188,18 @@ const CheckoutUI = (props: any) => {
|
|
|
160
188
|
return acc = acc + item?.summary?.tax
|
|
161
189
|
return acc = acc
|
|
162
190
|
}, cart?.subtotal)
|
|
191
|
+
|
|
192
|
+
const validateCommentsCartField = validationFields?.fields?.checkout?.comments?.enabled && validationFields?.fields?.checkout?.comments?.required && (cart?.comment === null || cart?.comment?.trim().length === 0)
|
|
193
|
+
|
|
163
194
|
const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) ||
|
|
164
195
|
placing || errorCash || subtotalWithTaxes < cart?.minimum ||
|
|
165
|
-
|
|
196
|
+
(cardsMethods.includes(paymethodSelected?.gateway) && cardList?.cards?.length === 0) ||
|
|
166
197
|
(options.type === 1 &&
|
|
167
198
|
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
168
199
|
validationFields?.fields?.checkout?.driver_tip?.required &&
|
|
169
|
-
(Number(cart?.driver_tip) <= 0))
|
|
200
|
+
(Number(cart?.driver_tip) <= 0)) ||
|
|
201
|
+
(validateCommentsCartField)
|
|
202
|
+
|| (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading))
|
|
170
203
|
|
|
171
204
|
const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
|
|
172
205
|
? JSON.parse(configs?.driver_tip_options?.value) || []
|
|
@@ -176,6 +209,9 @@ const CheckoutUI = (props: any) => {
|
|
|
176
209
|
|
|
177
210
|
const cartsWithProducts = carts && Object.values(carts).filter((cart: any) => cart.products.length) || null
|
|
178
211
|
|
|
212
|
+
const isSandboxCredomatic = configs?.credomatic_integration_sandbox?.value === '1'
|
|
213
|
+
const credomaticKeyId = isSandboxCredomatic ? configs?.credomatic_integration_public_sandbox_key?.value : configs?.credomatic_integration_public_production_key?.value
|
|
214
|
+
const credomaticUrl = `https://integrations.ordering.co/credomatic/front/auth_mobile.html?title=${t('CREDOMATIC_PAYMENT', 'Credomatic payment')}&body=${t('CREDOMATIC_PROCESSING', 'Processing transaction')}`
|
|
179
215
|
const deliveryOptions = instructionsOptions?.result && instructionsOptions?.result?.filter((option: any) => option?.enabled)?.map((option: any) => {
|
|
180
216
|
return {
|
|
181
217
|
value: option?.id, key: option?.id, label: t(option?.name.toUpperCase().replace(/\s/g, '_'), option?.name)
|
|
@@ -188,9 +224,30 @@ const CheckoutUI = (props: any) => {
|
|
|
188
224
|
}
|
|
189
225
|
}
|
|
190
226
|
|
|
227
|
+
const vibrateApp = (impact?: string) => {
|
|
228
|
+
const options = {
|
|
229
|
+
enableVibrateFallback: true,
|
|
230
|
+
ignoreAndroidSystemSettings: false
|
|
231
|
+
};
|
|
232
|
+
ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const handleSuccessSignup = (user: any) => {
|
|
236
|
+
login({
|
|
237
|
+
user,
|
|
238
|
+
token: user?.session?.access_token
|
|
239
|
+
})
|
|
240
|
+
setOpenModal({ ...openModal, signup: false })
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const handleSuccessLogin = (user: any) => {
|
|
244
|
+
if (user) setOpenModal({ ...openModal, login: false })
|
|
245
|
+
}
|
|
246
|
+
|
|
191
247
|
const handlePlaceOrder = (confirmPayment: any, forcePlace: boolean = false) => {
|
|
192
|
-
if (!userErrors.length && !requiredFields?.length || forcePlace) {
|
|
193
|
-
|
|
248
|
+
if (!userErrors.length && (!requiredFields?.length || allowedGuest) || forcePlace) {
|
|
249
|
+
vibrateApp()
|
|
250
|
+
handlerClickPlaceOrder && handlerClickPlaceOrder(null, { isNative: true }, confirmPayment)
|
|
194
251
|
return
|
|
195
252
|
}
|
|
196
253
|
if (requiredFields?.length) {
|
|
@@ -205,6 +262,11 @@ const CheckoutUI = (props: any) => {
|
|
|
205
262
|
setIsUserDetailsEdit(true)
|
|
206
263
|
}
|
|
207
264
|
|
|
265
|
+
const handlePlaceOrderAsGuest = () => {
|
|
266
|
+
setIsOpen(false)
|
|
267
|
+
handlerClickPlaceOrder && handlerClickPlaceOrder()
|
|
268
|
+
}
|
|
269
|
+
|
|
208
270
|
const handlePaymentMethodClick = (paymethod: any) => {
|
|
209
271
|
setShowGateway({ closedByUser: false, open: true })
|
|
210
272
|
setWebviewPaymethod(paymethod)
|
|
@@ -223,7 +285,7 @@ const CheckoutUI = (props: any) => {
|
|
|
223
285
|
const checkValidationFields = () => {
|
|
224
286
|
setUserErrors([])
|
|
225
287
|
const errors = []
|
|
226
|
-
const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes']
|
|
288
|
+
const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
|
|
227
289
|
const _requiredFields: any = []
|
|
228
290
|
|
|
229
291
|
Object.values(validationFields?.fields?.checkout).map((field: any) => {
|
|
@@ -268,13 +330,13 @@ const CheckoutUI = (props: any) => {
|
|
|
268
330
|
}
|
|
269
331
|
}, [errors])
|
|
270
332
|
|
|
271
|
-
// useEffect(() => {
|
|
272
|
-
// handlePaymethodChange(null)
|
|
273
|
-
// }, [cart?.total])
|
|
274
|
-
|
|
275
333
|
useEffect(() => {
|
|
276
334
|
if (cart?.products?.length === 0) {
|
|
277
|
-
|
|
335
|
+
if (cart?.business?.slug) {
|
|
336
|
+
onNavigationRedirect('Business', { store: cart?.business?.slug, header: null, logo: null, fromMulti: props.fromMulti })
|
|
337
|
+
} else {
|
|
338
|
+
onNavigationRedirect('Wallets')
|
|
339
|
+
}
|
|
278
340
|
}
|
|
279
341
|
}, [cart?.products])
|
|
280
342
|
|
|
@@ -282,6 +344,39 @@ const CheckoutUI = (props: any) => {
|
|
|
282
344
|
onFailPaypal()
|
|
283
345
|
}, [showGateway.closedByUser])
|
|
284
346
|
|
|
347
|
+
const HeaderTitle = (props: any) => {
|
|
348
|
+
const { text } = props
|
|
349
|
+
return (
|
|
350
|
+
<OText
|
|
351
|
+
size={16}
|
|
352
|
+
lineHeight={24}
|
|
353
|
+
weight={'500'}
|
|
354
|
+
mBottom={props.mb ?? 10}
|
|
355
|
+
color={theme.colors.textNormal}
|
|
356
|
+
>
|
|
357
|
+
{text}
|
|
358
|
+
</OText>
|
|
359
|
+
)
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
useEffect(() => {
|
|
363
|
+
cart && events.emit('checkout_started', cart)
|
|
364
|
+
}, [])
|
|
365
|
+
|
|
366
|
+
useEffect(() => {
|
|
367
|
+
if (cart?.paymethod_data?.gateway === 'credomatic') {
|
|
368
|
+
if (cart?.paymethod_data?.status === 2) {
|
|
369
|
+
setShowGateway({ ...showGateway, open: true })
|
|
370
|
+
} else if (cart?.paymethod_data?.gateway === 'credomatic' && cart?.paymethod_data?.status === 4) {
|
|
371
|
+
setShowGateway({ ...showGateway, open: false })
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}, [cart?.paymethod_data])
|
|
375
|
+
|
|
376
|
+
const onTextLayout = useCallback((e: any) => {
|
|
377
|
+
setLengthMore((e.nativeEvent.lines.length == 3 && e.nativeEvent.lines[2].width > WIDTH_SCREEN * .76) || e.nativeEvent.lines.length > 3)
|
|
378
|
+
}, [])
|
|
379
|
+
|
|
285
380
|
return (
|
|
286
381
|
<>
|
|
287
382
|
<Container noPadding>
|
|
@@ -289,23 +384,31 @@ const CheckoutUI = (props: any) => {
|
|
|
289
384
|
<NavBar
|
|
290
385
|
title={t('CHECKOUT', 'Checkout')}
|
|
291
386
|
titleAlign={'center'}
|
|
292
|
-
onActionLeft={() =>
|
|
387
|
+
onActionLeft={() => onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)}
|
|
293
388
|
showCall={false}
|
|
294
|
-
btnStyle={{ paddingLeft: 0 }}
|
|
389
|
+
btnStyle={{ paddingLeft: 0, paddingTop: Platform.OS == 'ios' ? 0 : 2 }}
|
|
295
390
|
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
296
391
|
titleStyle={{ marginRight: 0, marginLeft: 0 }}
|
|
392
|
+
style={{ marginTop: 20 }}
|
|
297
393
|
/>
|
|
298
394
|
</View>
|
|
299
395
|
<ChContainer style={styles.pagePadding}>
|
|
300
396
|
<ChSection style={{ paddingTop: 0 }}>
|
|
301
397
|
<ChHeader>
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
398
|
+
<CHMomentWrapper isCustomColor={isChewLayout} onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes })}>
|
|
399
|
+
<OText
|
|
400
|
+
size={12}
|
|
401
|
+
numberOfLines={1}
|
|
402
|
+
ellipsizeMode={'tail'}
|
|
403
|
+
color={theme.colors?.[isChewLayout ? 'white' : 'textSecondary']}
|
|
404
|
+
>
|
|
405
|
+
{t(getTypesText(options?.type || 1), 'Delivery')}
|
|
406
|
+
</OText>
|
|
305
407
|
<OIcon
|
|
306
408
|
src={theme.images.general.arrow_down}
|
|
307
409
|
width={10}
|
|
308
410
|
style={{ marginStart: 8 }}
|
|
411
|
+
{...(isChewLayout && { color: 'white' })}
|
|
309
412
|
/>
|
|
310
413
|
</CHMomentWrapper>
|
|
311
414
|
<CHMomentWrapper
|
|
@@ -329,85 +432,135 @@ const CheckoutUI = (props: any) => {
|
|
|
329
432
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 18, marginHorizontal: -40 }} />
|
|
330
433
|
</ChSection>
|
|
331
434
|
|
|
332
|
-
|
|
333
|
-
<
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
435
|
+
{!isGiftCardCart && !hideBusinessDetails && (
|
|
436
|
+
<ChSection>
|
|
437
|
+
<ChBusinessDetails>
|
|
438
|
+
{
|
|
439
|
+
(businessDetails?.loading || cartState.loading || !businessDetails?.business || Object.values(businessDetails?.business).length === 0) &&
|
|
440
|
+
!businessDetails?.error &&
|
|
441
|
+
(
|
|
442
|
+
<Placeholder Animation={Fade}>
|
|
443
|
+
<PlaceholderLine height={20} />
|
|
444
|
+
<PlaceholderLine height={12} />
|
|
445
|
+
<PlaceholderLine height={12} />
|
|
446
|
+
<PlaceholderLine height={12} style={{ marginBottom: 20 }} />
|
|
447
|
+
</Placeholder>
|
|
448
|
+
)}
|
|
449
|
+
{
|
|
450
|
+
!cartState.loading &&
|
|
451
|
+
businessDetails?.business &&
|
|
452
|
+
Object.values(businessDetails?.business).length > 0 &&
|
|
453
|
+
(
|
|
454
|
+
<>
|
|
455
|
+
<HeaderTitle text={t('BUSINESS_DETAILS', 'Business Details')} />
|
|
456
|
+
<View>
|
|
457
|
+
<OText size={12} lineHeight={18} weight={'400'}>
|
|
458
|
+
{businessDetails?.business?.name}
|
|
459
|
+
</OText>
|
|
460
|
+
<OText size={12} lineHeight={18} weight={'400'}>
|
|
461
|
+
{businessDetails?.business?.email}
|
|
462
|
+
</OText>
|
|
463
|
+
<OText size={12} lineHeight={18} weight={'400'}>
|
|
464
|
+
{businessDetails?.business?.cellphone}
|
|
465
|
+
</OText>
|
|
466
|
+
{!hideBusinessAddress && (
|
|
467
|
+
<OText size={12} lineHeight={18} weight={'400'}>
|
|
468
|
+
{businessDetails?.business?.address}
|
|
469
|
+
</OText>
|
|
470
|
+
)}
|
|
471
|
+
{businessDetails?.business?.address_notes && (
|
|
472
|
+
<>
|
|
473
|
+
<OText
|
|
474
|
+
size={12}
|
|
475
|
+
lineHeight={18}
|
|
476
|
+
numberOfLines={isReadMore ? 20 : 3}
|
|
477
|
+
onTextLayout={onTextLayout}
|
|
478
|
+
>
|
|
479
|
+
{businessDetails?.business?.address_notes}
|
|
480
|
+
</OText>
|
|
481
|
+
{lengthMore && (
|
|
482
|
+
<TouchableOpacity
|
|
483
|
+
onPress={() => setIsReadMore(!isReadMore)}
|
|
484
|
+
>
|
|
485
|
+
<OText size={12} color={theme.colors.primary}>{isReadMore ? t('SHOW_LESS', 'Show less') : t('READ_MORE', 'Read more')}</OText>
|
|
486
|
+
</TouchableOpacity>
|
|
487
|
+
)}
|
|
488
|
+
</>
|
|
489
|
+
)}
|
|
490
|
+
</View>
|
|
491
|
+
</>
|
|
492
|
+
)}
|
|
493
|
+
{businessDetails?.error && businessDetails?.error?.length > 0 && (
|
|
494
|
+
<View>
|
|
495
|
+
<HeaderTitle text={t('BUSINESS_DETAILS', 'Business Details')} />
|
|
496
|
+
<NotFoundSource
|
|
497
|
+
content={businessDetails?.error[0]?.message || businessDetails?.error[0]}
|
|
498
|
+
/>
|
|
499
|
+
</View>
|
|
500
|
+
)}
|
|
501
|
+
</ChBusinessDetails>
|
|
502
|
+
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
503
|
+
</ChSection>
|
|
504
|
+
)}
|
|
505
|
+
{!hideCustomerDetails && (
|
|
506
|
+
|
|
507
|
+
<ChSection>
|
|
508
|
+
<ChUserDetails>
|
|
509
|
+
{cartState.loading ? (
|
|
338
510
|
<Placeholder Animation={Fade}>
|
|
339
511
|
<PlaceholderLine height={20} />
|
|
340
512
|
<PlaceholderLine height={12} />
|
|
341
513
|
<PlaceholderLine height={12} />
|
|
342
514
|
<PlaceholderLine height={12} style={{ marginBottom: 20 }} />
|
|
343
515
|
</Placeholder>
|
|
344
|
-
)
|
|
345
|
-
|
|
346
|
-
!cartState.loading &&
|
|
347
|
-
businessDetails?.business &&
|
|
348
|
-
Object.values(businessDetails?.business).length > 0 &&
|
|
349
|
-
(
|
|
350
|
-
<>
|
|
351
|
-
<OText size={16} lineHeight={24} weight={'500'} mBottom={10} color={theme.colors.textNormal}>
|
|
352
|
-
{t('BUSINESS_DETAILS', 'Business Details')}
|
|
353
|
-
</OText>
|
|
516
|
+
) : (
|
|
517
|
+
(user?.guest_id && !allowedGuest) ? (
|
|
354
518
|
<View>
|
|
355
|
-
<
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
{
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
{
|
|
366
|
-
|
|
519
|
+
<HeaderTitle text={t('CUSTOMER_DETAILS', 'Customer details')} />
|
|
520
|
+
<OButton
|
|
521
|
+
text={t('SIGN_UP', 'Sign up')}
|
|
522
|
+
textStyle={{ color: theme.colors.white }}
|
|
523
|
+
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
524
|
+
onClick={() => setOpenModal({ ...openModal, signup: true })}
|
|
525
|
+
/>
|
|
526
|
+
<OButton
|
|
527
|
+
text={t('LOGIN', 'Login')}
|
|
528
|
+
textStyle={{ color: theme.colors.primary }}
|
|
529
|
+
bgColor={theme.colors.white}
|
|
530
|
+
borderColor={theme.colors.primary}
|
|
531
|
+
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
532
|
+
onClick={() => setOpenModal({ ...openModal, login: true })}
|
|
533
|
+
/>
|
|
534
|
+
<OButton
|
|
535
|
+
text={t('CONTINUE_AS_GUEST', 'Continue as guest')}
|
|
536
|
+
textStyle={{ color: theme.colors.black }}
|
|
537
|
+
bgColor={theme.colors.white}
|
|
538
|
+
borderColor={theme.colors.black}
|
|
539
|
+
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
540
|
+
onClick={() => setAllowedGuest(true)}
|
|
541
|
+
/>
|
|
367
542
|
</View>
|
|
368
|
-
|
|
543
|
+
) : (
|
|
544
|
+
<UserDetails
|
|
545
|
+
isUserDetailsEdit={isUserDetailsEdit}
|
|
546
|
+
HeaderTitle={<HeaderTitle text={t('CUSTOMER_DETAILS', 'Customer Details')} mb={0} />}
|
|
547
|
+
cartStatus={cart?.status}
|
|
548
|
+
businessId={cart?.business_id}
|
|
549
|
+
useValidationFields
|
|
550
|
+
useDefualtSessionManager
|
|
551
|
+
useSessionUser
|
|
552
|
+
isCheckout
|
|
553
|
+
phoneUpdate={phoneUpdate}
|
|
554
|
+
togglePhoneUpdate={togglePhoneUpdate}
|
|
555
|
+
/>
|
|
556
|
+
)
|
|
369
557
|
)}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
</OText>
|
|
375
|
-
<NotFoundSource
|
|
376
|
-
content={businessDetails?.error[0]?.message || businessDetails?.error[0]}
|
|
377
|
-
/>
|
|
378
|
-
</View>
|
|
379
|
-
)}
|
|
380
|
-
</ChBusinessDetails>
|
|
381
|
-
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
382
|
-
</ChSection>
|
|
383
|
-
|
|
384
|
-
<ChSection>
|
|
385
|
-
<ChUserDetails>
|
|
386
|
-
{cartState.loading ? (
|
|
387
|
-
<Placeholder Animation={Fade}>
|
|
388
|
-
<PlaceholderLine height={20} />
|
|
389
|
-
<PlaceholderLine height={12} />
|
|
390
|
-
<PlaceholderLine height={12} />
|
|
391
|
-
<PlaceholderLine height={12} style={{ marginBottom: 20 }} />
|
|
392
|
-
</Placeholder>
|
|
393
|
-
) : (
|
|
394
|
-
<UserDetails
|
|
395
|
-
isUserDetailsEdit={isUserDetailsEdit}
|
|
396
|
-
cartStatus={cart?.status}
|
|
397
|
-
businessId={cart?.business_id}
|
|
398
|
-
useValidationFields
|
|
399
|
-
useDefualtSessionManager
|
|
400
|
-
useSessionUser
|
|
401
|
-
isCheckout
|
|
402
|
-
phoneUpdate={phoneUpdate}
|
|
403
|
-
togglePhoneUpdate={togglePhoneUpdate}
|
|
404
|
-
/>
|
|
405
|
-
)}
|
|
406
|
-
</ChUserDetails>
|
|
407
|
-
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
408
|
-
</ChSection>
|
|
558
|
+
</ChUserDetails>
|
|
559
|
+
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
560
|
+
</ChSection>
|
|
561
|
+
)}
|
|
409
562
|
|
|
410
|
-
{options?.type === 1 && (
|
|
563
|
+
{options?.type === 1 && !isGiftCardCart && (
|
|
411
564
|
<DeliveryOptionsContainer>
|
|
412
565
|
{cartState.loading || deliveryOptionSelected === undefined ? (
|
|
413
566
|
<View style={{ height: 110 }}>
|
|
@@ -417,8 +570,8 @@ const CheckoutUI = (props: any) => {
|
|
|
417
570
|
</Placeholder>
|
|
418
571
|
</View>
|
|
419
572
|
) : (
|
|
420
|
-
|
|
421
|
-
<
|
|
573
|
+
<ChSection>
|
|
574
|
+
<HeaderTitle text={t('DELIVERY_OPTIONS', 'Delivery options')} />
|
|
422
575
|
<View
|
|
423
576
|
style={{
|
|
424
577
|
backgroundColor: theme.colors.inputDisabled,
|
|
@@ -437,7 +590,7 @@ const CheckoutUI = (props: any) => {
|
|
|
437
590
|
<OText
|
|
438
591
|
size={14}
|
|
439
592
|
>
|
|
440
|
-
{deliveryOptions.find((option: any) => option.value === deliveryOptionSelected)
|
|
593
|
+
{deliveryOptions.find((option: any) => option.value === deliveryOptionSelected)?.label}
|
|
441
594
|
</OText>
|
|
442
595
|
<MaterialIcons name='keyboard-arrow-down' style={styles.icon} />
|
|
443
596
|
</DeliveryOptionItem>
|
|
@@ -448,7 +601,7 @@ const CheckoutUI = (props: any) => {
|
|
|
448
601
|
data: deliveryOptions || [],
|
|
449
602
|
renderItem: ({ item }: any) => (
|
|
450
603
|
<TouchableOpacity
|
|
451
|
-
onPress={() => changeDeliveryOption(item.value)}
|
|
604
|
+
onPress={() => !!cart?.uuid && changeDeliveryOption(item.value)}
|
|
452
605
|
disabled={
|
|
453
606
|
deliveryOptionSelected === item.value
|
|
454
607
|
}
|
|
@@ -464,7 +617,7 @@ const CheckoutUI = (props: any) => {
|
|
|
464
617
|
/>
|
|
465
618
|
</View>
|
|
466
619
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
467
|
-
|
|
620
|
+
</ChSection>
|
|
468
621
|
)}
|
|
469
622
|
|
|
470
623
|
</DeliveryOptionsContainer>
|
|
@@ -486,50 +639,30 @@ const CheckoutUI = (props: any) => {
|
|
|
486
639
|
</ChSection>
|
|
487
640
|
)}
|
|
488
641
|
|
|
489
|
-
{
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
<ChAddress>
|
|
514
|
-
{(businessDetails?.loading || cartState.loading) ? (
|
|
515
|
-
<Placeholder Animation={Fade}>
|
|
516
|
-
<PlaceholderLine height={20} style={{ marginBottom: 50 }} />
|
|
517
|
-
<PlaceholderLine height={100} />
|
|
518
|
-
</Placeholder>
|
|
519
|
-
) : (
|
|
520
|
-
<AddressDetails
|
|
521
|
-
navigation={navigation}
|
|
522
|
-
location={businessDetails?.business?.location}
|
|
523
|
-
businessLogo={businessDetails?.business?.logo}
|
|
524
|
-
isCartPending={cart?.status === 2}
|
|
525
|
-
uuid={cartUuid}
|
|
526
|
-
apiKey={configs?.google_maps_api_key?.value}
|
|
527
|
-
mapConfigs={mapConfigs}
|
|
528
|
-
/>
|
|
529
|
-
)}
|
|
530
|
-
</ChAddress>
|
|
531
|
-
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
|
|
532
|
-
</ChSection>
|
|
642
|
+
{!isGiftCardCart && !hideBusinessMap && (
|
|
643
|
+
<ChSection>
|
|
644
|
+
<ChAddress>
|
|
645
|
+
{(businessDetails?.loading || cartState.loading) ? (
|
|
646
|
+
<Placeholder Animation={Fade}>
|
|
647
|
+
<PlaceholderLine height={20} style={{ marginBottom: 50 }} />
|
|
648
|
+
<PlaceholderLine height={100} />
|
|
649
|
+
</Placeholder>
|
|
650
|
+
) : (
|
|
651
|
+
<AddressDetails
|
|
652
|
+
navigation={navigation}
|
|
653
|
+
location={options?.address?.location}
|
|
654
|
+
businessLogo={businessDetails?.business?.logo}
|
|
655
|
+
isCartPending={cart?.status === 2}
|
|
656
|
+
uuid={cartUuid}
|
|
657
|
+
apiKey={configs?.google_maps_api_key?.value}
|
|
658
|
+
mapConfigs={mapConfigs}
|
|
659
|
+
HeaderTitle={<HeaderTitle text={t('DELIVERY_ADDRESS', 'Delivery address')} mb={0} />}
|
|
660
|
+
/>
|
|
661
|
+
)}
|
|
662
|
+
</ChAddress>
|
|
663
|
+
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
|
|
664
|
+
</ChSection>
|
|
665
|
+
)}
|
|
533
666
|
|
|
534
667
|
{!cartState.loading &&
|
|
535
668
|
cart &&
|
|
@@ -538,22 +671,22 @@ const CheckoutUI = (props: any) => {
|
|
|
538
671
|
cart?.status !== 2 &&
|
|
539
672
|
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
540
673
|
driverTipsOptions && driverTipsOptions?.length > 0 &&
|
|
674
|
+
!isGiftCardCart &&
|
|
541
675
|
(
|
|
542
676
|
<ChSection>
|
|
543
677
|
<ChDriverTips>
|
|
544
|
-
<
|
|
545
|
-
{t('DRIVER_TIPS', 'Driver Tips')}
|
|
546
|
-
</OText>
|
|
678
|
+
<HeaderTitle text={t('DRIVER_TIPS', 'Driver Tips')} mb={0} />
|
|
547
679
|
<DriverTips
|
|
548
680
|
uuid={cartUuid}
|
|
549
681
|
businessId={cart?.business_id}
|
|
550
|
-
driverTipsOptions={driverTipsOptions}
|
|
551
|
-
isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1
|
|
682
|
+
driverTipsOptions={!driverTipsOptions.includes(0) ? [0, ...driverTipsOptions] : driverTipsOptions}
|
|
683
|
+
isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1}
|
|
552
684
|
isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
|
|
553
|
-
driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1
|
|
685
|
+
driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1
|
|
554
686
|
? cart?.driver_tip
|
|
555
687
|
: cart?.driver_tip_rate}
|
|
556
688
|
useOrderContext
|
|
689
|
+
cart={cart}
|
|
557
690
|
/>
|
|
558
691
|
</ChDriverTips>
|
|
559
692
|
</ChSection>
|
|
@@ -562,9 +695,7 @@ const CheckoutUI = (props: any) => {
|
|
|
562
695
|
{!cartState.loading && cart && cart?.status !== 2 && cart?.valid && (
|
|
563
696
|
<ChSection>
|
|
564
697
|
<ChPaymethods>
|
|
565
|
-
<
|
|
566
|
-
{t('PAYMENT_METHOD', 'Payment Method')}
|
|
567
|
-
</OText>
|
|
698
|
+
<HeaderTitle text={t('PAYMENT_METHOD', 'Payment Method')} mb={0} />
|
|
568
699
|
{!cartState.loading && cart?.status === 4 && (
|
|
569
700
|
<OText
|
|
570
701
|
style={{ textAlign: 'center', marginTop: 20 }}
|
|
@@ -577,8 +708,8 @@ const CheckoutUI = (props: any) => {
|
|
|
577
708
|
<PaymentOptions
|
|
578
709
|
cart={cart}
|
|
579
710
|
isDisabled={cart?.status === 2}
|
|
580
|
-
businessId={businessDetails?.business?.id}
|
|
581
|
-
isLoading={businessDetails.loading}
|
|
711
|
+
businessId={!isGiftCardCart ? businessDetails?.business?.id : -1}
|
|
712
|
+
isLoading={!isGiftCardCart ? businessDetails.loading : false}
|
|
582
713
|
paymethods={businessDetails?.business?.paymethods}
|
|
583
714
|
onPaymentChange={handlePaymethodChange}
|
|
584
715
|
errorCash={errorCash}
|
|
@@ -588,6 +719,12 @@ const CheckoutUI = (props: any) => {
|
|
|
588
719
|
handlePaymentMethodClickCustom={handlePaymentMethodClick}
|
|
589
720
|
handlePlaceOrder={handlePlaceOrder}
|
|
590
721
|
merchantId={merchantId}
|
|
722
|
+
setMethodPaySupported={setMethodPaySupported}
|
|
723
|
+
methodPaySupported={methodPaySupported}
|
|
724
|
+
placeByMethodPay={placeByMethodPay}
|
|
725
|
+
setPlaceByMethodPay={setPlaceByMethodPay}
|
|
726
|
+
cardList={cardList}
|
|
727
|
+
setCardList={setCardList}
|
|
591
728
|
/>
|
|
592
729
|
</ChPaymethods>
|
|
593
730
|
</ChSection>
|
|
@@ -597,6 +734,7 @@ const CheckoutUI = (props: any) => {
|
|
|
597
734
|
<WalletPaymentOptionContainer>
|
|
598
735
|
<PaymentOptionWallet
|
|
599
736
|
cart={cart}
|
|
737
|
+
loyaltyPlansState={loyaltyPlansState}
|
|
600
738
|
businessId={cart?.business_id}
|
|
601
739
|
businessConfigs={businessDetails?.business?.configs}
|
|
602
740
|
/>
|
|
@@ -604,7 +742,7 @@ const CheckoutUI = (props: any) => {
|
|
|
604
742
|
)}
|
|
605
743
|
|
|
606
744
|
|
|
607
|
-
{!cartState.loading && placeSpotsEnabled && (
|
|
745
|
+
{!cartState.loading && placeSpotsEnabled && !isGiftCardCart && (
|
|
608
746
|
<>
|
|
609
747
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 30, marginHorizontal: -40 }} />
|
|
610
748
|
<PlaceSpot
|
|
@@ -630,25 +768,21 @@ const CheckoutUI = (props: any) => {
|
|
|
630
768
|
) : (
|
|
631
769
|
<>
|
|
632
770
|
<CartHeader>
|
|
633
|
-
<
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
>
|
|
638
|
-
{t('MOBILE_FRONT_YOUR_ORDER', 'Your order')}
|
|
639
|
-
</OText>
|
|
640
|
-
<TouchableOpacity
|
|
641
|
-
onPress={() => onNavigationRedirect('Business', { store: cart?.business?.slug })}
|
|
642
|
-
>
|
|
643
|
-
<OText
|
|
644
|
-
size={12}
|
|
645
|
-
lineHeight={15}
|
|
646
|
-
color={theme.colors.primary}
|
|
647
|
-
style={{ textDecorationLine: 'underline' }}
|
|
771
|
+
<HeaderTitle text={t('MOBILE_FRONT_YOUR_ORDER', 'Your order')} mb={0} />
|
|
772
|
+
{!isGiftCardCart && (
|
|
773
|
+
<TouchableOpacity
|
|
774
|
+
onPress={() => onNavigationRedirect('Business', { store: cart?.business?.slug })}
|
|
648
775
|
>
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
776
|
+
<OText
|
|
777
|
+
size={12}
|
|
778
|
+
lineHeight={15}
|
|
779
|
+
color={theme.colors.primary}
|
|
780
|
+
style={{ textDecorationLine: 'underline' }}
|
|
781
|
+
>
|
|
782
|
+
{t('ADD_PRODUCTS', 'Add products')}
|
|
783
|
+
</OText>
|
|
784
|
+
</TouchableOpacity>
|
|
785
|
+
)}
|
|
652
786
|
</CartHeader>
|
|
653
787
|
{isBusinessChangeEnabled && (
|
|
654
788
|
<TouchableOpacity
|
|
@@ -670,6 +804,12 @@ const CheckoutUI = (props: any) => {
|
|
|
670
804
|
isCartPending={cart?.status === 2}
|
|
671
805
|
onNavigationRedirect={onNavigationRedirect}
|
|
672
806
|
placeSpotTypes={placeSpotTypes}
|
|
807
|
+
businessConfigs={businessConfigs}
|
|
808
|
+
maxDate={maxDate}
|
|
809
|
+
loyaltyRewardRate={
|
|
810
|
+
creditPointPlanOnBusiness?.accumulation_rate ??
|
|
811
|
+
(!!creditPointPlanOnBusiness && creditPointPlan?.accumulation_rate) ?? 0
|
|
812
|
+
}
|
|
673
813
|
/>
|
|
674
814
|
</>
|
|
675
815
|
)}
|
|
@@ -679,7 +819,7 @@ const CheckoutUI = (props: any) => {
|
|
|
679
819
|
|
|
680
820
|
{!cartState.loading && cart && (
|
|
681
821
|
<View>
|
|
682
|
-
<ChErrors style={{ marginBottom: 10 }}>
|
|
822
|
+
<ChErrors style={{ marginBottom: Platform.OS === 'ios' ? 35 : 10 }}>
|
|
683
823
|
{!cart?.valid_address && cart?.status !== 2 && (
|
|
684
824
|
<OText
|
|
685
825
|
color={theme.colors.error}
|
|
@@ -706,6 +846,14 @@ const CheckoutUI = (props: any) => {
|
|
|
706
846
|
{t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
|
|
707
847
|
</OText>
|
|
708
848
|
)}
|
|
849
|
+
{cart?.valid_preorder !== undefined && !cart?.valid_preorder && (
|
|
850
|
+
<OText
|
|
851
|
+
color={theme.colors.error}
|
|
852
|
+
size={12}
|
|
853
|
+
>
|
|
854
|
+
{t('INVALID_CART_MOMENT', 'Selected schedule time is invalid, please select a schedule into the business schedule interval.')}
|
|
855
|
+
</OText>
|
|
856
|
+
)}
|
|
709
857
|
{options.type === 1 &&
|
|
710
858
|
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
711
859
|
validationFields?.fields?.checkout?.driver_tip?.required &&
|
|
@@ -717,6 +865,15 @@ const CheckoutUI = (props: any) => {
|
|
|
717
865
|
{t('WARNING_INVALID_DRIVER_TIP', 'Driver Tip is required.')}
|
|
718
866
|
</OText>
|
|
719
867
|
)}
|
|
868
|
+
|
|
869
|
+
{validateCommentsCartField && (
|
|
870
|
+
<OText
|
|
871
|
+
color={theme.colors.error}
|
|
872
|
+
size={12}
|
|
873
|
+
>
|
|
874
|
+
{t('WARNING_INVALID_CART_COMMENTS', 'Cart comments is required.')}
|
|
875
|
+
</OText>
|
|
876
|
+
)}
|
|
720
877
|
</ChErrors>
|
|
721
878
|
</View>
|
|
722
879
|
)}
|
|
@@ -749,18 +906,52 @@ const CheckoutUI = (props: any) => {
|
|
|
749
906
|
togglePhoneUpdate={togglePhoneUpdate}
|
|
750
907
|
requiredFields={requiredFields}
|
|
751
908
|
hideUpdateButton
|
|
909
|
+
handlePlaceOrderAsGuest={handlePlaceOrderAsGuest}
|
|
752
910
|
onClose={() => {
|
|
753
911
|
setIsOpen(false)
|
|
754
912
|
handlePlaceOrder(null, true)
|
|
755
913
|
}}
|
|
914
|
+
setIsOpen={setIsOpen}
|
|
756
915
|
/>
|
|
757
916
|
</View>
|
|
758
917
|
</OModal>
|
|
918
|
+
<OModal
|
|
919
|
+
open={openModal.signup}
|
|
920
|
+
onClose={() => setOpenModal({ ...openModal, signup: false })}
|
|
921
|
+
>
|
|
922
|
+
<ScrollView style={{ paddingHorizontal: 20, width: '100%' }}>
|
|
923
|
+
<SignupForm
|
|
924
|
+
handleSuccessSignup={handleSuccessSignup}
|
|
925
|
+
isGuest
|
|
926
|
+
signupButtonText={t('SIGNUP', 'Signup')}
|
|
927
|
+
useSignupByEmail
|
|
928
|
+
useChekoutFileds
|
|
929
|
+
/>
|
|
930
|
+
</ScrollView>
|
|
931
|
+
</OModal>
|
|
932
|
+
<OModal
|
|
933
|
+
open={openModal.login}
|
|
934
|
+
onClose={() => setOpenModal({ ...openModal, login: false })}
|
|
935
|
+
>
|
|
936
|
+
<ScrollView style={{ paddingHorizontal: 20, width: '100%' }}>
|
|
937
|
+
<LoginForm
|
|
938
|
+
handleSuccessLogin={handleSuccessLogin}
|
|
939
|
+
isGuest
|
|
940
|
+
loginButtonText={t('LOGIN', 'Login')}
|
|
941
|
+
loginButtonBackground={theme.colors.primary}
|
|
942
|
+
/>
|
|
943
|
+
</ScrollView>
|
|
944
|
+
</OModal>
|
|
759
945
|
</ChContainer>
|
|
760
946
|
</Container>
|
|
761
947
|
{!cartState.loading && cart && cart?.status !== 2 && (
|
|
762
948
|
<FloatingButton
|
|
763
|
-
handleClick={
|
|
949
|
+
handleClick={
|
|
950
|
+
isDisabledButtonPlace
|
|
951
|
+
? () => vibrateApp()
|
|
952
|
+
: methodsPay.includes(paymethodSelected?.gateway)
|
|
953
|
+
? () => setPlaceByMethodPay(true)
|
|
954
|
+
: () => handlePlaceOrder(null)}
|
|
764
955
|
isSecondaryBtn={isDisabledButtonPlace}
|
|
765
956
|
disabled={isDisabledButtonPlace}
|
|
766
957
|
btnText={subtotalWithTaxes >= cart?.minimum
|
|
@@ -803,6 +994,29 @@ const CheckoutUI = (props: any) => {
|
|
|
803
994
|
locationId={'L1NGAY5M6KJRX'}
|
|
804
995
|
/>
|
|
805
996
|
)}
|
|
997
|
+
{cart?.paymethod_data?.gateway === 'credomatic' && cart?.paymethod_data?.status === 2 && showGateway.open && (
|
|
998
|
+
<PaymentOptionsWebView
|
|
999
|
+
title={t('CREDOMATIC_PAYMENT', 'Credomatic payment')}
|
|
1000
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
1001
|
+
uri={credomaticUrl}
|
|
1002
|
+
user={user}
|
|
1003
|
+
cart={cart}
|
|
1004
|
+
additionalParams={{
|
|
1005
|
+
type: 'auth',
|
|
1006
|
+
key_id: credomaticKeyId,
|
|
1007
|
+
hash: cart?.paymethod_data?.result?.hash,
|
|
1008
|
+
time: cart?.paymethod_data?.result?.time,
|
|
1009
|
+
amount: cart?.total,
|
|
1010
|
+
orderid: cart?.uuid,
|
|
1011
|
+
ccnumber: cardList?.cards?.[0]?.number,
|
|
1012
|
+
ccexp: cardList?.cards?.[0]?.expiryString,
|
|
1013
|
+
cvv: cardList?.cards?.[0]?.cvc,
|
|
1014
|
+
redirect: credomaticUrl
|
|
1015
|
+
}}
|
|
1016
|
+
webviewPaymethod={webviewPaymethod}
|
|
1017
|
+
setShowGateway={setShowGateway}
|
|
1018
|
+
/>
|
|
1019
|
+
)}
|
|
806
1020
|
</>
|
|
807
1021
|
)
|
|
808
1022
|
}
|
|
@@ -829,7 +1043,8 @@ export const Checkout = (props: any) => {
|
|
|
829
1043
|
const getOrder = async (cartId: any) => {
|
|
830
1044
|
try {
|
|
831
1045
|
let result: any = {}
|
|
832
|
-
const
|
|
1046
|
+
const cartsWithProducts = orderState?.carts && (Object.values(orderState?.carts)?.filter(cart => cart?.products && cart?.products?.length) || null)
|
|
1047
|
+
const cart = cartsWithProducts?.find((cart: any) => cart.uuid === cartId)
|
|
833
1048
|
if (cart) {
|
|
834
1049
|
result = { ...cart }
|
|
835
1050
|
} else {
|