ordering-ui-react-native 0.16.36 → 0.16.37-release
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -5
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/ActiveOrders/index.tsx +61 -63
- package/src/components/ActiveOrders/styles.tsx +8 -14
- package/src/components/BusinessBasicInformation/index.tsx +11 -19
- package/src/components/BusinessInformation/index.tsx +33 -4
- package/src/components/BusinessInformation/styles.tsx +2 -2
- package/src/components/BusinessProductsList/index.tsx +10 -10
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +2 -1
- package/src/components/LanguageSelector/index.tsx +21 -16
- package/src/components/LoginForm/index.tsx +15 -0
- package/src/components/Messages/index.tsx +2 -2
- package/src/components/NotificationSetting/index.tsx +85 -0
- package/src/components/OrderDetails/index.tsx +2 -20
- package/src/components/OrdersOption/index.tsx +54 -56
- package/src/components/PaymentOptions/index.tsx +335 -365
- package/src/components/PaymentOptionsWebView/index.tsx +120 -121
- package/src/components/ReviewDriver/index.tsx +1 -1
- package/src/components/ReviewOrder/index.tsx +2 -1
- package/src/components/ReviewProducts/index.tsx +11 -0
- package/src/components/SignupForm/index.tsx +15 -0
- package/src/components/SingleProductReview/index.tsx +8 -5
- package/src/components/StripeElementsForm/index.tsx +25 -16
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OBottomPopup.tsx +6 -2
- package/src/index.tsx +2 -0
- package/src/pages/BusinessesListing.tsx +7 -6
- package/src/pages/OrderDetails.tsx +1 -1
- package/src/pages/ReviewDriver.tsx +2 -2
- package/src/pages/ReviewOrder.tsx +2 -2
- package/src/types/@fatnlazycat/react-native-recaptcha-v3/index.d.ts +1 -0
- package/src/utils/index.tsx +2 -1
- package/themes/business/src/components/BusinessController/index.tsx +2 -2
- package/themes/business/src/components/Chat/index.tsx +38 -30
- package/themes/business/src/components/DriverMap/index.tsx +7 -5
- package/themes/business/src/components/DriverSchedule/index.tsx +36 -19
- package/themes/business/src/components/LoginForm/index.tsx +111 -74
- package/themes/business/src/components/MapView/index.tsx +12 -1
- package/themes/business/src/components/MessagesOption/index.tsx +11 -1
- package/themes/business/src/components/NewOrderNotification/index.tsx +26 -41
- package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +25 -19
- package/themes/business/src/components/OrdersListManager/index.tsx +10 -3
- package/themes/business/src/components/OrdersOption/index.tsx +65 -21
- package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
- package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
- package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
- package/themes/business/src/components/PreviousMessages/index.tsx +17 -18
- package/themes/business/src/components/PreviousOrders/index.tsx +22 -24
- package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
- package/themes/business/src/components/ReviewCustomer/index.tsx +27 -13
- package/themes/business/src/components/ScheduleBlocked/index.tsx +2 -2
- package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
- package/themes/business/src/components/UserProfileForm/index.tsx +2 -0
- package/themes/business/src/components/shared/ODropDown.tsx +42 -8
- package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
- package/themes/business/src/types/index.tsx +15 -9
- package/themes/business/src/utils/index.tsx +10 -0
- 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/index.tsx +121 -10
- package/themes/kiosk/src/components/LoginForm/styles.tsx +5 -0
- 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/ProductForm/index.tsx +1 -14
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/kiosk/src/types/index.d.ts +2 -0
- package/themes/original/index.tsx +4 -0
- package/themes/original/src/components/AddressDetails/index.tsx +2 -2
- package/themes/original/src/components/AddressForm/index.tsx +151 -140
- package/themes/original/src/components/AddressList/index.tsx +1 -1
- package/themes/original/src/components/AppleLogin/index.tsx +4 -4
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +324 -162
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
- package/themes/original/src/components/BusinessController/index.tsx +190 -113
- package/themes/original/src/components/BusinessController/styles.tsx +0 -7
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -6
- package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
- package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
- package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
- package/themes/original/src/components/BusinessListingSearch/index.tsx +80 -128
- package/themes/original/src/components/BusinessListingSearch/styles.tsx +10 -12
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
- package/themes/original/src/components/BusinessProductsList/index.tsx +49 -52
- package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +179 -104
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +18 -11
- package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +3 -2
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +37 -25
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +5 -4
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +278 -104
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +47 -10
- package/themes/original/src/components/BusinessesListing/index.tsx +95 -7
- package/themes/original/src/components/Cart/index.tsx +54 -16
- package/themes/original/src/components/Cart/styles.tsx +4 -0
- package/themes/original/src/components/CartContent/index.tsx +22 -16
- package/themes/original/src/components/Checkout/index.tsx +78 -67
- package/themes/original/src/components/Checkout/styles.tsx +0 -1
- package/themes/original/src/components/DriverTips/index.tsx +4 -4
- package/themes/original/src/components/DriverTips/styles.tsx +2 -1
- package/themes/original/src/components/Favorite/index.tsx +1 -0
- package/themes/original/src/components/FavoriteList/index.tsx +32 -2
- package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
- package/themes/original/src/components/GPSButton/index.tsx +20 -19
- package/themes/original/src/components/GoogleMap/index.tsx +20 -12
- package/themes/original/src/components/HelpAccountAndPayment/index.tsx +25 -10
- package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +4 -0
- package/themes/original/src/components/HelpGuide/index.tsx +9 -8
- package/themes/original/src/components/HelpOrder/index.tsx +9 -8
- package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
- package/themes/original/src/components/LoginForm/Otp/index.tsx +95 -72
- package/themes/original/src/components/LoginForm/index.tsx +107 -50
- package/themes/original/src/components/LottieAnimation/index.tsx +69 -0
- package/themes/original/src/components/Messages/index.tsx +17 -17
- package/themes/original/src/components/MomentOption/index.tsx +8 -6
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +92 -92
- package/themes/original/src/components/MultiCheckout/index.tsx +6 -0
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +20 -16
- package/themes/original/src/components/MyOrders/index.tsx +70 -6
- package/themes/original/src/components/NavBar/index.tsx +15 -9
- package/themes/original/src/components/NetworkError/index.tsx +5 -3
- package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
- package/themes/original/src/components/Notifications/index.tsx +148 -0
- package/themes/original/src/components/Notifications/styles.tsx +17 -0
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
- package/themes/original/src/components/OrderDetails/index.tsx +200 -37
- package/themes/original/src/components/OrderDetails/styles.tsx +15 -2
- package/themes/original/src/components/OrderItAgain/index.tsx +75 -0
- package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
- package/themes/original/src/components/OrderProgress/index.tsx +77 -66
- package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
- package/themes/original/src/components/OrderSummary/index.tsx +3 -36
- package/themes/original/src/components/OrderTypeSelector/index.tsx +85 -36
- package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
- package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +97 -106
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +3 -0
- package/themes/original/src/components/OrdersOption/index.tsx +71 -55
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
- package/themes/original/src/components/PaymentOptions/index.tsx +41 -23
- package/themes/original/src/components/PhoneInputNumber/index.tsx +5 -11
- package/themes/original/src/components/PlaceSpot/index.tsx +243 -47
- package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
- package/themes/original/src/components/PreviousOrders/index.tsx +3 -2
- package/themes/original/src/components/ProductForm/index.tsx +635 -664
- package/themes/original/src/components/ProductForm/styles.tsx +9 -8
- package/themes/original/src/components/ProductItemAccordion/index.tsx +199 -128
- package/themes/original/src/components/ProductOption/index.tsx +1 -1
- package/themes/original/src/components/ProfessionalFilter/index.tsx +2 -1
- package/themes/original/src/components/ProfessionalProfile/index.tsx +26 -14
- package/themes/original/src/components/ReviewDriver/index.tsx +7 -7
- package/themes/original/src/components/ReviewOrder/index.tsx +18 -3
- package/themes/original/src/components/ReviewProducts/index.tsx +2 -2
- package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
- package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
- package/themes/original/src/components/SearchBar/index.tsx +5 -3
- package/themes/original/src/components/ServiceForm/index.tsx +410 -258
- package/themes/original/src/components/SignupForm/index.tsx +362 -210
- package/themes/original/src/components/SingleOrderCard/index.tsx +229 -181
- package/themes/original/src/components/SingleOrderCard/styles.tsx +0 -7
- package/themes/original/src/components/SingleProductCard/index.tsx +200 -110
- package/themes/original/src/components/SingleProductCard/styles.tsx +2 -10
- package/themes/original/src/components/SingleProductReview/index.tsx +38 -5
- package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
- package/themes/original/src/components/StripeElementsForm/index.tsx +18 -7
- package/themes/original/src/components/UpsellingProducts/index.tsx +15 -5
- package/themes/original/src/components/UserFormDetails/index.tsx +6 -48
- package/themes/original/src/components/UserProfile/index.tsx +56 -31
- package/themes/original/src/components/UserProfile/styles.ts +17 -0
- package/themes/original/src/components/UserProfileForm/index.tsx +10 -10
- package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
- package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
- package/themes/original/src/components/Wallets/index.tsx +176 -164
- package/themes/original/src/components/Wallets/styles.tsx +12 -8
- package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
- package/themes/original/src/components/shared/OBottomPopup.tsx +48 -15
- package/themes/original/src/components/shared/OButton.tsx +10 -3
- package/themes/original/src/components/shared/OIcon.tsx +8 -1
- package/themes/original/src/components/shared/OInput.tsx +13 -3
- package/themes/original/src/layouts/Container.tsx +13 -9
- package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
- package/themes/original/src/types/index.tsx +91 -30
- package/themes/original/src/utils/index.tsx +121 -10
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
|
@@ -1,17 +1,105 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { useOrder, useSession, useLanguage, useConfig } from 'ordering-components/native';
|
|
1
3
|
|
|
2
|
-
import React from 'react'
|
|
3
4
|
import { useTheme } from 'styled-components/native'
|
|
4
5
|
import { BusinessesListing as OriginalBusinessListing } from './Layout/Original'
|
|
5
6
|
import { BusinessesListing as AppointmentBusinessListing } from './Layout/Appointment'
|
|
7
|
+
import { OBottomPopup } from '../shared';
|
|
8
|
+
import { ReviewTrigger } from '../ReviewTrigger';
|
|
9
|
+
import { NotificationSetting } from '../../../../../src/components/NotificationSetting';
|
|
6
10
|
|
|
7
11
|
export const BusinessesListing = (props: any) => {
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
const { logosLayout } = props
|
|
13
|
+
const theme = useTheme()
|
|
14
|
+
const layout = theme?.business_listing_view?.components?.layout?.type || 'original'
|
|
15
|
+
const [, t] = useLanguage();
|
|
16
|
+
const [{ auth }] = useSession()
|
|
17
|
+
const [, { getLastOrderHasNoReview }] = useOrder();
|
|
18
|
+
const [{ configs }] = useConfig()
|
|
19
|
+
const isShowReviewsPopupEnabled = configs?.show_reviews_popups_enabled?.value === '1'
|
|
10
20
|
|
|
11
|
-
|
|
21
|
+
const [, setIsReviewed] = useState()
|
|
22
|
+
const [checkNotificationStatus, setCheckNotificationStatus] = useState({ open: false, checked: false })
|
|
23
|
+
const defaultOrder = {
|
|
24
|
+
id: 0,
|
|
25
|
+
business_id: 0,
|
|
26
|
+
business_name: '',
|
|
27
|
+
logo: '',
|
|
28
|
+
driver: {},
|
|
29
|
+
products: [],
|
|
30
|
+
review: {},
|
|
31
|
+
user_review: {},
|
|
32
|
+
delivery_datetime: ''
|
|
33
|
+
}
|
|
34
|
+
const [lastOrderReview, setLastOrderReview] = useState({
|
|
35
|
+
isReviewOpen: false,
|
|
36
|
+
order: defaultOrder,
|
|
37
|
+
defaultStar: 5,
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const _getLastOrderHasNoReview = async () => {
|
|
41
|
+
const lastOrderHasNoReview = await getLastOrderHasNoReview()
|
|
42
|
+
lastOrderHasNoReview && OrderReviewRequired(lastOrderHasNoReview)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const OrderReviewRequired = (order: any) => {
|
|
46
|
+
setLastOrderReview({
|
|
47
|
+
isReviewOpen: true,
|
|
48
|
+
order: {
|
|
49
|
+
id: order?.id,
|
|
50
|
+
business_id: order?.business_id,
|
|
51
|
+
business_name: order?.business?.name,
|
|
52
|
+
logo: order.business?.logo,
|
|
53
|
+
driver: order?.driver,
|
|
54
|
+
products: order?.products,
|
|
55
|
+
review: order?.review,
|
|
56
|
+
user_review: order?.user_review,
|
|
57
|
+
delivery_datetime: order?.delivery_datetime_utc
|
|
58
|
+
},
|
|
59
|
+
defaultStar: 5
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const handleOpenOrderReview = (star: number) => {
|
|
64
|
+
setLastOrderReview({
|
|
65
|
+
...lastOrderReview, isReviewOpen: false, order: defaultOrder
|
|
66
|
+
})
|
|
67
|
+
props?.navigation && props.navigation.navigate(
|
|
68
|
+
'ReviewOrder',
|
|
69
|
+
{
|
|
70
|
+
order: lastOrderReview.order,
|
|
71
|
+
defaultStar: star || 5,
|
|
72
|
+
setIsReviewed
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (!isShowReviewsPopupEnabled) return
|
|
79
|
+
(checkNotificationStatus?.checked && auth) && _getLastOrderHasNoReview()
|
|
80
|
+
}, [checkNotificationStatus, auth, isShowReviewsPopupEnabled])
|
|
81
|
+
|
|
82
|
+
return (
|
|
12
83
|
<>
|
|
13
|
-
{(layout === 'original') && <OriginalBusinessListing {...props} />}
|
|
14
|
-
{(layout === '
|
|
84
|
+
{((layout === 'original') || logosLayout) && <OriginalBusinessListing {...props} />}
|
|
85
|
+
{(layout === 'appointments') && !logosLayout && <AppointmentBusinessListing {...props} />}
|
|
86
|
+
|
|
87
|
+
{lastOrderReview?.isReviewOpen && (
|
|
88
|
+
<OBottomPopup
|
|
89
|
+
open={lastOrderReview?.isReviewOpen}
|
|
90
|
+
transparent={true}
|
|
91
|
+
onClose={() => setLastOrderReview({ ...lastOrderReview, isReviewOpen: false, order: defaultOrder })}
|
|
92
|
+
title={t('HEY', 'Hey! ') + t('HOW_WAS_YOUR_ORDER', 'How was your order?')}
|
|
93
|
+
bottomContainerStyle={{ height: 'auto', borderRadius: 10 }}
|
|
94
|
+
titleStyle={{ textAlign: 'center' }}
|
|
95
|
+
closeIcon={theme.images.general.close}
|
|
96
|
+
presentationStyle='overFullScreen'
|
|
97
|
+
>
|
|
98
|
+
{lastOrderReview?.order && <ReviewTrigger order={lastOrderReview?.order} handleOpenOrderReview={handleOpenOrderReview} />}
|
|
99
|
+
</OBottomPopup>
|
|
100
|
+
)}
|
|
101
|
+
<NotificationSetting checkNotificationStatus={checkNotificationStatus}
|
|
102
|
+
setCheckNotificationStatus={setCheckNotificationStatus} />
|
|
15
103
|
</>
|
|
16
|
-
|
|
104
|
+
)
|
|
17
105
|
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
useValidationFields,
|
|
9
9
|
} from 'ordering-components/native';
|
|
10
10
|
import { useTheme } from 'styled-components/native';
|
|
11
|
-
import { CContainer, CheckoutAction, Divider } from './styles';
|
|
11
|
+
import { CContainer, CheckoutAction, Divider, DriverTipsContainer } from './styles';
|
|
12
12
|
|
|
13
13
|
import { OSBill, OSTable, OSCoupon, OSTotal, OSRow } from '../OrderSummary/styles';
|
|
14
14
|
|
|
@@ -25,6 +25,7 @@ import { TaxInformation } from '../TaxInformation';
|
|
|
25
25
|
import { CartStoresListing } from '../CartStoresListing';
|
|
26
26
|
import { OAlert } from '../../../../../src/components/shared'
|
|
27
27
|
import { PlaceSpot } from '../PlaceSpot'
|
|
28
|
+
import { DriverTips } from '../DriverTips'
|
|
28
29
|
|
|
29
30
|
const CartUI = (props: any) => {
|
|
30
31
|
const {
|
|
@@ -60,11 +61,16 @@ const CartUI = (props: any) => {
|
|
|
60
61
|
|
|
61
62
|
const isCartPending = cart?.status === 2
|
|
62
63
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
|
|
63
|
-
|
|
64
|
+
const isCheckoutMultiBusinessEnabled: Boolean = configs?.checkout_multi_business_enabled?.value === '1'
|
|
65
|
+
const openCarts = (Object.values(orderState?.carts)?.filter((cart: any) => cart?.products && cart?.products?.length && cart?.status !== 2 && cart?.valid_schedule && cart?.valid_products && cart?.valid_address && cart?.valid_maximum && cart?.valid_minimum && !cart?.wallets) || null) || []
|
|
64
66
|
|
|
65
67
|
const business: any = (orderState?.carts && Object.values(orderState.carts).find((_cart: any) => _cart?.uuid === props.cartuuid)) ?? {}
|
|
66
68
|
const businessId = business?.business_id ?? null
|
|
67
|
-
const placeSpotTypes = [
|
|
69
|
+
const placeSpotTypes = [4]
|
|
70
|
+
|
|
71
|
+
const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
|
|
72
|
+
? JSON.parse(configs?.driver_tip_options?.value) || []
|
|
73
|
+
: configs?.driver_tip_options?.value || []
|
|
68
74
|
|
|
69
75
|
const momentFormatted = !orderState?.option?.moment
|
|
70
76
|
? t('RIGHT_NOW', 'Right Now')
|
|
@@ -98,11 +104,11 @@ const CartUI = (props: any) => {
|
|
|
98
104
|
const handleUpsellingPage = () => {
|
|
99
105
|
setOpenUpselling(false)
|
|
100
106
|
setCanOpenUpselling(false)
|
|
101
|
-
if (isCheckoutMultiBusinessEnabled) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
if (isCheckoutMultiBusinessEnabled && openCarts.length > 1) {
|
|
108
|
+
props.onNavigationRedirect('CheckoutNavigator', {
|
|
109
|
+
screen: 'MultiCheckout'
|
|
110
|
+
})
|
|
111
|
+
} else {
|
|
106
112
|
props.onNavigationRedirect('CheckoutNavigator', {
|
|
107
113
|
screen: 'CheckoutPage',
|
|
108
114
|
cartUuid: cart?.uuid,
|
|
@@ -148,6 +154,12 @@ const CartUI = (props: any) => {
|
|
|
148
154
|
}
|
|
149
155
|
}
|
|
150
156
|
|
|
157
|
+
const subtotalWithTaxes = cart?.taxes?.reduce((acc: any, item: any) => {
|
|
158
|
+
if (item?.type === 1)
|
|
159
|
+
return acc = acc + item?.summary?.tax
|
|
160
|
+
return acc = acc
|
|
161
|
+
}, cart?.subtotal)
|
|
162
|
+
|
|
151
163
|
return (
|
|
152
164
|
<CContainer>
|
|
153
165
|
{openUpselling && (
|
|
@@ -172,7 +184,7 @@ const CartUI = (props: any) => {
|
|
|
172
184
|
onNavigationRedirect={props.onNavigationRedirect}
|
|
173
185
|
handleChangeStore={() => setOpenChangeStore(true)}
|
|
174
186
|
handleClickCheckout={() => setOpenUpselling(true)}
|
|
175
|
-
checkoutButtonDisabled={(openUpselling && !canOpenUpselling) ||
|
|
187
|
+
checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
|
|
176
188
|
isMultiCheckout={isMultiCheckout}
|
|
177
189
|
>
|
|
178
190
|
{cart?.products?.length > 0 && cart?.products.map((product: any, i: number) => (
|
|
@@ -355,13 +367,39 @@ const CartUI = (props: any) => {
|
|
|
355
367
|
</OSTable>
|
|
356
368
|
)}
|
|
357
369
|
|
|
370
|
+
{isMultiCheckout &&
|
|
371
|
+
cart &&
|
|
372
|
+
cart?.valid &&
|
|
373
|
+
orderState?.options?.type === 1 &&
|
|
374
|
+
cart?.status !== 2 &&
|
|
375
|
+
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
376
|
+
driverTipsOptions && driverTipsOptions?.length > 0 &&
|
|
377
|
+
(
|
|
378
|
+
<DriverTipsContainer>
|
|
379
|
+
<OText size={14} lineHeight={20} color={theme.colors.textNormal}>
|
|
380
|
+
{t('DRIVER_TIPS', 'Driver Tips')}
|
|
381
|
+
</OText>
|
|
382
|
+
<DriverTips
|
|
383
|
+
uuid={cart?.uuid}
|
|
384
|
+
businessId={cart?.business_id}
|
|
385
|
+
driverTipsOptions={driverTipsOptions}
|
|
386
|
+
isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)}
|
|
387
|
+
isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
|
|
388
|
+
driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)
|
|
389
|
+
? cart?.driver_tip
|
|
390
|
+
: cart?.driver_tip_rate}
|
|
391
|
+
useOrderContext
|
|
392
|
+
/>
|
|
393
|
+
</DriverTipsContainer>
|
|
394
|
+
)}
|
|
395
|
+
|
|
358
396
|
<OSTotal>
|
|
359
397
|
<OSTable style={{ marginTop: 15 }}>
|
|
360
|
-
<OText size={14} lineHeight={21} weight={'
|
|
398
|
+
<OText size={14} lineHeight={21} weight={'bold'} color={theme.colors.textNormal}>
|
|
361
399
|
{t('TOTAL', 'Total')}
|
|
362
400
|
</OText>
|
|
363
|
-
<OText size={14} lineHeight={21} weight={'
|
|
364
|
-
{parsePrice(cart?.
|
|
401
|
+
<OText size={14} lineHeight={21} weight={'bold'} color={theme.colors.textNormal}>
|
|
402
|
+
{parsePrice(cart?.balance >= 0 ? cart?.balance : 0)}
|
|
365
403
|
</OText>
|
|
366
404
|
</OSTable>
|
|
367
405
|
</OSTotal>
|
|
@@ -423,15 +461,15 @@ const CartUI = (props: any) => {
|
|
|
423
461
|
{cart?.valid_products ? (
|
|
424
462
|
<CheckoutAction>
|
|
425
463
|
<OButton
|
|
426
|
-
text={(
|
|
464
|
+
text={(subtotalWithTaxes >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
|
|
427
465
|
!openUpselling !== canOpenUpselling ? t('CHECKOUT', 'Checkout') : t('LOADING', 'Loading')
|
|
428
466
|
) : !cart?.valid_address ? (
|
|
429
467
|
`${t('OUT_OF_COVERAGE', 'Out of Coverage')}`
|
|
430
468
|
) : (
|
|
431
469
|
`${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`
|
|
432
470
|
)}
|
|
433
|
-
bgColor={(
|
|
434
|
-
isDisabled={(openUpselling && !canOpenUpselling) ||
|
|
471
|
+
bgColor={(subtotalWithTaxes < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
|
|
472
|
+
isDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
|
|
435
473
|
borderColor={theme.colors.primary}
|
|
436
474
|
imgRightSrc={null}
|
|
437
475
|
textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
|
|
@@ -446,7 +484,7 @@ const CartUI = (props: any) => {
|
|
|
446
484
|
</OText>
|
|
447
485
|
</View>
|
|
448
486
|
)}
|
|
449
|
-
</>
|
|
487
|
+
</>
|
|
450
488
|
)}
|
|
451
489
|
</BusinessItemAccordion>
|
|
452
490
|
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import {
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { useLanguage } from 'ordering-components/native';
|
|
3
4
|
import { useTheme } from 'styled-components/native';
|
|
4
5
|
import { CCContainer, CCNotCarts, CCList } from './styles';
|
|
5
6
|
|
|
6
7
|
import { Cart } from '../Cart';
|
|
7
|
-
import {
|
|
8
|
+
import { OButton, OText } from '../shared';
|
|
8
9
|
import Spinner from 'react-native-loading-spinner-overlay';
|
|
9
|
-
import { View } from 'react-native';
|
|
10
10
|
|
|
11
11
|
export const CartContent = (props: any) => {
|
|
12
12
|
const {
|
|
13
13
|
carts,
|
|
14
|
-
isOrderStateCarts
|
|
14
|
+
isOrderStateCarts,
|
|
15
|
+
onNavigationRedirect
|
|
15
16
|
} = props
|
|
16
17
|
|
|
17
18
|
const theme = useTheme();
|
|
@@ -22,18 +23,15 @@ export const CartContent = (props: any) => {
|
|
|
22
23
|
<CCContainer>
|
|
23
24
|
{isOrderStateCarts && carts?.length > 0 && (
|
|
24
25
|
<>
|
|
25
|
-
{/* <OText size={24} lineHeight={36} weight={'600'} style={{ marginBottom: 20 }}>
|
|
26
|
-
{carts.length > 1 ? t('MY_CARTS', 'My Carts') : t('CART', 'Cart')}
|
|
27
|
-
</OText> */}
|
|
28
26
|
{carts.map((cart: any, i: number) => (
|
|
29
27
|
<CCList key={i} style={{ overflow: 'visible' }}>
|
|
30
28
|
{cart.products.length > 0 && (
|
|
31
29
|
<>
|
|
32
30
|
<Cart
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
singleBusiness={props.singleBusiness}
|
|
32
|
+
isFranchiseApp={props.isFranchiseApp}
|
|
35
33
|
cart={cart}
|
|
36
|
-
|
|
34
|
+
cartuuid={cart.uuid}
|
|
37
35
|
onNavigationRedirect={props.onNavigationRedirect}
|
|
38
36
|
isCartsLoading={isCartsLoading}
|
|
39
37
|
setIsCartsLoading={setIsCartsLoading}
|
|
@@ -48,14 +46,22 @@ export const CartContent = (props: any) => {
|
|
|
48
46
|
)}
|
|
49
47
|
{(!carts || carts?.length === 0) && (
|
|
50
48
|
<CCNotCarts>
|
|
51
|
-
{/* <OIcon
|
|
52
|
-
url={props.icon}
|
|
53
|
-
width={200}
|
|
54
|
-
height={122}
|
|
55
|
-
/> */}
|
|
56
49
|
<OText size={24} style={{ textAlign: 'center' }}>
|
|
57
50
|
{t('CARTS_NOT_FOUND', 'You don\'t have carts available')}
|
|
58
51
|
</OText>
|
|
52
|
+
<OButton
|
|
53
|
+
text={t('START_SHOPPING', 'Start shopping')}
|
|
54
|
+
bgColor={theme.colors.primary}
|
|
55
|
+
borderColor={theme.colors.primary}
|
|
56
|
+
textStyle={{
|
|
57
|
+
color: theme.colors.white,
|
|
58
|
+
fontSize: 14,
|
|
59
|
+
paddingRight: 0
|
|
60
|
+
}}
|
|
61
|
+
style={{ height: 35, marginVertical: 20, borderRadius: 8 }}
|
|
62
|
+
imgRightSrc={null}
|
|
63
|
+
onClick={() => onNavigationRedirect('BusinessList')}
|
|
64
|
+
/>
|
|
59
65
|
</CCNotCarts>
|
|
60
66
|
)}
|
|
61
67
|
<Spinner visible={isCartsLoading} />
|
|
@@ -24,6 +24,7 @@ import { DriverTips } from '../DriverTips';
|
|
|
24
24
|
import { NotFoundSource } from '../NotFoundSource';
|
|
25
25
|
import { UserDetails } from '../UserDetails';
|
|
26
26
|
import { PaymentOptionWallet } from '../PaymentOptionWallet';
|
|
27
|
+
import { PlaceSpot } from '../PlaceSpot'
|
|
27
28
|
|
|
28
29
|
import {
|
|
29
30
|
ChContainer,
|
|
@@ -105,8 +106,7 @@ const CheckoutUI = (props: any) => {
|
|
|
105
106
|
padding: 20
|
|
106
107
|
},
|
|
107
108
|
pagePadding: {
|
|
108
|
-
|
|
109
|
-
paddingRight: 40
|
|
109
|
+
paddingHorizontal: 40
|
|
110
110
|
},
|
|
111
111
|
icon: {
|
|
112
112
|
top: 15,
|
|
@@ -118,9 +118,11 @@ const CheckoutUI = (props: any) => {
|
|
|
118
118
|
paddingHorizontal: 40,
|
|
119
119
|
width: '100%'
|
|
120
120
|
},
|
|
121
|
-
wrapperNavbar:
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
wrapperNavbar: {
|
|
122
|
+
paddingVertical: 0,
|
|
123
|
+
paddingHorizontal: 40,
|
|
124
|
+
marginVertical: 2
|
|
125
|
+
}
|
|
124
126
|
})
|
|
125
127
|
|
|
126
128
|
const [, { showToast }] = useToast();
|
|
@@ -141,9 +143,10 @@ const CheckoutUI = (props: any) => {
|
|
|
141
143
|
const [showGateway, setShowGateway] = useState<any>({ closedByUsed: false, open: false });
|
|
142
144
|
const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
|
|
143
145
|
const [isOpen, setIsOpen] = useState(false)
|
|
144
|
-
|
|
146
|
+
const [requiredFields, setRequiredFields] = useState<any>([])
|
|
145
147
|
|
|
146
|
-
const placeSpotTypes = [3, 4]
|
|
148
|
+
const placeSpotTypes = [3, 4, 5]
|
|
149
|
+
const placeSpotsEnabled = placeSpotTypes.includes(options?.type)
|
|
147
150
|
const businessConfigs = businessDetails?.business?.configs ?? []
|
|
148
151
|
const isWalletCashEnabled = businessConfigs.find((config: any) => config.key === 'wallet_cash_enabled')?.value === '1'
|
|
149
152
|
const isWalletCreditPointsEnabled = businessConfigs.find((config: any) => config.key === 'wallet_credit_point_enabled')?.value === '1'
|
|
@@ -151,8 +154,14 @@ const CheckoutUI = (props: any) => {
|
|
|
151
154
|
const isBusinessChangeEnabled = configs?.cart_change_business_validation?.value === '1'
|
|
152
155
|
|
|
153
156
|
const isPreOrder = configs?.preorder_status_enabled?.value === '1'
|
|
154
|
-
const
|
|
155
|
-
|
|
157
|
+
const subtotalWithTaxes = cart?.taxes?.reduce((acc: any, item: any) => {
|
|
158
|
+
if (item?.type === 1)
|
|
159
|
+
return acc = acc + item?.summary?.tax
|
|
160
|
+
return acc = acc
|
|
161
|
+
}, cart?.subtotal)
|
|
162
|
+
const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) ||
|
|
163
|
+
placing || errorCash || subtotalWithTaxes < cart?.minimum ||
|
|
164
|
+
// (placeSpotTypes.includes(options?.type) && !cart?.place) ||
|
|
156
165
|
(options.type === 1 &&
|
|
157
166
|
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
158
167
|
validationFields?.fields?.checkout?.driver_tip?.required &&
|
|
@@ -178,15 +187,15 @@ const CheckoutUI = (props: any) => {
|
|
|
178
187
|
}
|
|
179
188
|
}
|
|
180
189
|
|
|
181
|
-
const handlePlaceOrder = (confirmPayment) => {
|
|
182
|
-
if (!userErrors.length && !requiredFields?.length) {
|
|
190
|
+
const handlePlaceOrder = (confirmPayment: any, forcePlace: boolean = false) => {
|
|
191
|
+
if (!userErrors.length && !requiredFields?.length || forcePlace) {
|
|
183
192
|
handlerClickPlaceOrder && handlerClickPlaceOrder(null, null, confirmPayment)
|
|
184
193
|
return
|
|
185
194
|
}
|
|
186
195
|
if (requiredFields?.length) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
196
|
+
setIsOpen(true)
|
|
197
|
+
return
|
|
198
|
+
}
|
|
190
199
|
let stringError = ''
|
|
191
200
|
Object.values(userErrors).map((item: any, i: number) => {
|
|
192
201
|
stringError += (i + 1) === userErrors.length ? `- ${item?.message || item}` : `- ${item?.message || item}\n`
|
|
@@ -217,7 +226,7 @@ const CheckoutUI = (props: any) => {
|
|
|
217
226
|
const _requiredFields: any = []
|
|
218
227
|
|
|
219
228
|
Object.values(validationFields?.fields?.checkout).map((field: any) => {
|
|
220
|
-
if (field?.required && !notFields.includes(field.code)) {
|
|
229
|
+
if (field?.required && !notFields.includes(field.code) && field?.enabled) {
|
|
221
230
|
if (!user[field?.code]) {
|
|
222
231
|
_requiredFields.push(field?.code)
|
|
223
232
|
}
|
|
@@ -282,7 +291,6 @@ const CheckoutUI = (props: any) => {
|
|
|
282
291
|
onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
|
|
283
292
|
showCall={false}
|
|
284
293
|
btnStyle={{ paddingLeft: 0 }}
|
|
285
|
-
style={{ marginTop: Platform.OS === 'ios' ? 0 : 30 }}
|
|
286
294
|
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
287
295
|
titleStyle={{ marginRight: 0, marginLeft: 0 }}
|
|
288
296
|
/>
|
|
@@ -327,10 +335,10 @@ const CheckoutUI = (props: any) => {
|
|
|
327
335
|
!businessDetails?.error &&
|
|
328
336
|
(
|
|
329
337
|
<Placeholder Animation={Fade}>
|
|
330
|
-
<PlaceholderLine height={20}
|
|
331
|
-
<PlaceholderLine height={
|
|
332
|
-
<PlaceholderLine height={
|
|
333
|
-
<PlaceholderLine height={
|
|
338
|
+
<PlaceholderLine height={20} />
|
|
339
|
+
<PlaceholderLine height={12} />
|
|
340
|
+
<PlaceholderLine height={12} />
|
|
341
|
+
<PlaceholderLine height={12} style={{ marginBottom: 20 }} />
|
|
334
342
|
</Placeholder>
|
|
335
343
|
)}
|
|
336
344
|
{
|
|
@@ -339,7 +347,7 @@ const CheckoutUI = (props: any) => {
|
|
|
339
347
|
Object.values(businessDetails?.business).length > 0 &&
|
|
340
348
|
(
|
|
341
349
|
<>
|
|
342
|
-
<OText size={16} lineHeight={24} weight={'500'} mBottom={10}>
|
|
350
|
+
<OText size={16} lineHeight={24} weight={'500'} mBottom={10} color={theme.colors.textNormal}>
|
|
343
351
|
{t('BUSINESS_DETAILS', 'Business Details')}
|
|
344
352
|
</OText>
|
|
345
353
|
<View>
|
|
@@ -360,7 +368,7 @@ const CheckoutUI = (props: any) => {
|
|
|
360
368
|
)}
|
|
361
369
|
{businessDetails?.error && businessDetails?.error?.length > 0 && (
|
|
362
370
|
<View>
|
|
363
|
-
<OText size={16} lineHeight={24} weight={'500'}>
|
|
371
|
+
<OText size={16} lineHeight={24} weight={'500'} color={theme.colors.textNormal}>
|
|
364
372
|
{t('BUSINESS_DETAILS', 'Business Details')}
|
|
365
373
|
</OText>
|
|
366
374
|
<NotFoundSource
|
|
@@ -376,10 +384,10 @@ const CheckoutUI = (props: any) => {
|
|
|
376
384
|
<ChUserDetails>
|
|
377
385
|
{cartState.loading ? (
|
|
378
386
|
<Placeholder Animation={Fade}>
|
|
379
|
-
<PlaceholderLine height={20}
|
|
380
|
-
<PlaceholderLine height={
|
|
381
|
-
<PlaceholderLine height={
|
|
382
|
-
<PlaceholderLine height={
|
|
387
|
+
<PlaceholderLine height={20} />
|
|
388
|
+
<PlaceholderLine height={12} />
|
|
389
|
+
<PlaceholderLine height={12} />
|
|
390
|
+
<PlaceholderLine height={12} style={{ marginBottom: 20 }} />
|
|
383
391
|
</Placeholder>
|
|
384
392
|
) : (
|
|
385
393
|
<UserDetails
|
|
@@ -403,13 +411,13 @@ const CheckoutUI = (props: any) => {
|
|
|
403
411
|
{cartState.loading || deliveryOptionSelected === undefined ? (
|
|
404
412
|
<View style={{ height: 110 }}>
|
|
405
413
|
<Placeholder Animation={Fade}>
|
|
406
|
-
<PlaceholderLine height={20}
|
|
407
|
-
<PlaceholderLine height={40}
|
|
414
|
+
<PlaceholderLine height={20} />
|
|
415
|
+
<PlaceholderLine height={40} />
|
|
408
416
|
</Placeholder>
|
|
409
417
|
</View>
|
|
410
418
|
) : (
|
|
411
419
|
<>
|
|
412
|
-
<OText size={16}>{t('DELIVERY_OPTIONS', 'Delivery options')}</OText>
|
|
420
|
+
<OText size={16} color={theme.colors.textNormal} mBottom={10}>{t('DELIVERY_OPTIONS', 'Delivery options')}</OText>
|
|
413
421
|
<View
|
|
414
422
|
style={{
|
|
415
423
|
backgroundColor: theme.colors.inputDisabled,
|
|
@@ -595,6 +603,20 @@ const CheckoutUI = (props: any) => {
|
|
|
595
603
|
)}
|
|
596
604
|
|
|
597
605
|
|
|
606
|
+
{!cartState.loading && placeSpotsEnabled && (
|
|
607
|
+
<>
|
|
608
|
+
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 30, marginHorizontal: -40 }} />
|
|
609
|
+
<PlaceSpot
|
|
610
|
+
isCheckout
|
|
611
|
+
isInputMode
|
|
612
|
+
cart={cart}
|
|
613
|
+
spotNumberDefault={cartState?.cart?.spot_number ?? cart?.spot_number}
|
|
614
|
+
vehicleDefault={cart?.vehicle}
|
|
615
|
+
/>
|
|
616
|
+
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
617
|
+
</>
|
|
618
|
+
)}
|
|
619
|
+
|
|
598
620
|
{!cartState.loading && cart && (
|
|
599
621
|
<ChSection>
|
|
600
622
|
<ChCart>
|
|
@@ -610,7 +632,6 @@ const CheckoutUI = (props: any) => {
|
|
|
610
632
|
size={16}
|
|
611
633
|
lineHeight={24}
|
|
612
634
|
color={theme.colors.textNormal}
|
|
613
|
-
style={{ fontWeight: '500' }}
|
|
614
635
|
>
|
|
615
636
|
{t('MOBILE_FRONT_YOUR_ORDER', 'Your order')}
|
|
616
637
|
</OText>
|
|
@@ -618,7 +639,7 @@ const CheckoutUI = (props: any) => {
|
|
|
618
639
|
onPress={() => onNavigationRedirect('Business', { store: cart?.business?.slug })}
|
|
619
640
|
>
|
|
620
641
|
<OText
|
|
621
|
-
size={
|
|
642
|
+
size={12}
|
|
622
643
|
lineHeight={15}
|
|
623
644
|
color={theme.colors.primary}
|
|
624
645
|
style={{ textDecorationLine: 'underline' }}
|
|
@@ -635,7 +656,7 @@ const CheckoutUI = (props: any) => {
|
|
|
635
656
|
<OText
|
|
636
657
|
size={12}
|
|
637
658
|
lineHeight={18}
|
|
638
|
-
color={theme.colors.
|
|
659
|
+
color={theme.colors.primary}
|
|
639
660
|
style={{ textDecorationLine: 'underline' }}
|
|
640
661
|
>
|
|
641
662
|
{t('CHANGE_STORE', 'Change store')}
|
|
@@ -646,6 +667,7 @@ const CheckoutUI = (props: any) => {
|
|
|
646
667
|
cart={cart}
|
|
647
668
|
isCartPending={cart?.status === 2}
|
|
648
669
|
onNavigationRedirect={onNavigationRedirect}
|
|
670
|
+
placeSpotTypes={placeSpotTypes}
|
|
649
671
|
/>
|
|
650
672
|
</>
|
|
651
673
|
)}
|
|
@@ -682,14 +704,6 @@ const CheckoutUI = (props: any) => {
|
|
|
682
704
|
{t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
|
|
683
705
|
</OText>
|
|
684
706
|
)}
|
|
685
|
-
{placeSpotTypes.includes(options?.type) && !cart?.place && (
|
|
686
|
-
<OText
|
|
687
|
-
color={theme.colors.error}
|
|
688
|
-
size={12}
|
|
689
|
-
>
|
|
690
|
-
{t('WARNING_PLACE_SPOT', 'Please, select your spot to place order.')}
|
|
691
|
-
</OText>
|
|
692
|
-
)}
|
|
693
707
|
{options.type === 1 &&
|
|
694
708
|
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
695
709
|
validationFields?.fields?.checkout?.driver_tip?.required &&
|
|
@@ -733,7 +747,10 @@ const CheckoutUI = (props: any) => {
|
|
|
733
747
|
togglePhoneUpdate={togglePhoneUpdate}
|
|
734
748
|
requiredFields={requiredFields}
|
|
735
749
|
hideUpdateButton
|
|
736
|
-
onClose={() =>
|
|
750
|
+
onClose={() => {
|
|
751
|
+
setIsOpen(false)
|
|
752
|
+
handlePlaceOrder(null, true)
|
|
753
|
+
}}
|
|
737
754
|
/>
|
|
738
755
|
</View>
|
|
739
756
|
</OModal>
|
|
@@ -741,10 +758,10 @@ const CheckoutUI = (props: any) => {
|
|
|
741
758
|
</Container>
|
|
742
759
|
{!cartState.loading && cart && cart?.status !== 2 && (
|
|
743
760
|
<FloatingButton
|
|
744
|
-
handleClick={() => handlePlaceOrder()}
|
|
761
|
+
handleClick={() => handlePlaceOrder(null)}
|
|
745
762
|
isSecondaryBtn={isDisabledButtonPlace}
|
|
746
763
|
disabled={isDisabledButtonPlace}
|
|
747
|
-
btnText={
|
|
764
|
+
btnText={subtotalWithTaxes >= cart?.minimum
|
|
748
765
|
? (
|
|
749
766
|
placing
|
|
750
767
|
? t('PLACING', 'Placing')
|
|
@@ -755,7 +772,7 @@ const CheckoutUI = (props: any) => {
|
|
|
755
772
|
: (`${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`)
|
|
756
773
|
}
|
|
757
774
|
btnRightValueShow
|
|
758
|
-
btnRightValue={parsePrice(cart?.
|
|
775
|
+
btnRightValue={parsePrice(cart?.balance)}
|
|
759
776
|
iosBottom={30}
|
|
760
777
|
/>
|
|
761
778
|
)}
|
|
@@ -771,19 +788,6 @@ const CheckoutUI = (props: any) => {
|
|
|
771
788
|
setShowGateway={setShowGateway}
|
|
772
789
|
/>
|
|
773
790
|
)}
|
|
774
|
-
{webviewPaymethod?.gateway === 'square' && showGateway.open && (
|
|
775
|
-
<PaymentOptionsWebView
|
|
776
|
-
onNavigationRedirect={onNavigationRedirect}
|
|
777
|
-
uri={`https://test-square-f50f7.web.app`}
|
|
778
|
-
user={user}
|
|
779
|
-
token={token}
|
|
780
|
-
cart={cart}
|
|
781
|
-
currency={currency}
|
|
782
|
-
webviewPaymethod={webviewPaymethod}
|
|
783
|
-
setShowGateway={setShowGateway}
|
|
784
|
-
locationId={'L1NGAY5M6KJRX'}
|
|
785
|
-
/>
|
|
786
|
-
)}
|
|
787
791
|
</>
|
|
788
792
|
)
|
|
789
793
|
}
|
|
@@ -809,16 +813,23 @@ export const Checkout = (props: any) => {
|
|
|
809
813
|
|
|
810
814
|
const getOrder = async (cartId: any) => {
|
|
811
815
|
try {
|
|
812
|
-
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
816
|
+
let result: any = {}
|
|
817
|
+
const cart = orderState?.carts.find((cart: any) => cart.uuid === cartId)
|
|
818
|
+
if (cart) {
|
|
819
|
+
result = { ...cart }
|
|
820
|
+
} else {
|
|
821
|
+
setCartState({ ...cartState, loading: true })
|
|
822
|
+
const url = `${ordering.root}/carts/${cartId}`
|
|
823
|
+
const response = await fetch(url, {
|
|
824
|
+
method: 'GET',
|
|
825
|
+
headers: {
|
|
826
|
+
'Content-Type': 'application/json',
|
|
827
|
+
Authorization: `Bearer ${token}`
|
|
828
|
+
}
|
|
829
|
+
})
|
|
830
|
+
const content = await response.json();
|
|
831
|
+
result = content.result
|
|
832
|
+
}
|
|
822
833
|
|
|
823
834
|
let publicKey = null
|
|
824
835
|
try {
|