ordering-ui-react-native 0.21.51 → 0.21.52-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 -8
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/PaymentOptionsWebView/index.tsx +1 -0
- package/src/components/StripeMethodForm/index.tsx +6 -4
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/types/index.tsx +3 -1
- package/themes/business/index.tsx +4 -0
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +4 -3
- package/themes/business/src/components/BusinessController/index.tsx +19 -17
- package/themes/business/src/components/BusinessProductList/ProductList.tsx +72 -27
- package/themes/business/src/components/BusinessProductList/index.tsx +57 -25
- package/themes/business/src/components/DriverMap/index.tsx +36 -23
- package/themes/business/src/components/GoogleMap/index.tsx +15 -8
- package/themes/business/src/components/Home/index.tsx +5 -1
- package/themes/business/src/components/LanguageSelector/index.tsx +1 -2
- package/themes/business/src/components/LanguageSelector/lang_country.json +515 -70
- package/themes/business/src/components/LogoutButton/index.tsx +1 -1
- package/themes/business/src/components/MapView/index.tsx +30 -15
- package/themes/business/src/components/NewOrderNotification/index.tsx +66 -26
- package/themes/business/src/components/OrderDetails/Business.tsx +52 -2
- package/themes/business/src/components/OrderDetails/Delivery.tsx +42 -23
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +68 -61
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +36 -22
- package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +220 -0
- package/themes/business/src/components/OrderSummary/index.tsx +240 -76
- package/themes/business/src/components/OrdersOption/index.tsx +263 -135
- package/themes/business/src/components/PhoneInputNumber/index.tsx +8 -5
- package/themes/business/src/components/PreviousOrders/OrderItem.tsx +37 -40
- package/themes/business/src/components/PreviousOrders/OrderList.tsx +1 -1
- package/themes/business/src/components/PreviousOrders/index.tsx +5 -3
- package/themes/business/src/components/PreviousOrders/styles.tsx +10 -0
- package/themes/business/src/components/PrinterEdition/index.tsx +363 -0
- package/themes/business/src/components/PrinterEdition/styles.tsx +61 -0
- package/themes/business/src/components/PrinterSettings/index.tsx +267 -0
- package/themes/business/src/components/PrinterSettings/styles.tsx +30 -0
- package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
- package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
- package/themes/business/src/components/SearchBar/index.tsx +2 -1
- package/themes/business/src/components/Sessions/index.tsx +187 -0
- package/themes/business/src/components/Sessions/styles.tsx +20 -0
- package/themes/business/src/components/StoresList/index.tsx +5 -3
- package/themes/business/src/components/UserFormDetails/index.tsx +111 -107
- package/themes/business/src/components/UserProfileForm/index.tsx +106 -54
- package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
- package/themes/business/src/components/shared/OInput.tsx +2 -0
- package/themes/business/src/components/shared/OTextarea.tsx +8 -9
- package/themes/business/src/hooks/useLocation.tsx +5 -4
- package/themes/business/src/types/index.tsx +23 -5
- package/themes/business/src/utils/index.tsx +5 -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/Checkout/index.tsx +6 -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/shared/OButton.tsx +5 -18
- package/themes/original/index.tsx +6 -2
- package/themes/original/src/components/AddressDetails/index.tsx +20 -10
- package/themes/original/src/components/AddressForm/index.tsx +32 -17
- package/themes/original/src/components/AddressList/index.tsx +8 -7
- package/themes/original/src/components/AnalyticsSegment/index.tsx +6 -6
- package/themes/original/src/components/AppleLogin/index.tsx +4 -4
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +6 -9
- package/themes/original/src/components/BusinessController/index.tsx +18 -10
- package/themes/original/src/components/BusinessController/styles.tsx +8 -7
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +316 -0
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +94 -0
- package/themes/original/src/components/BusinessListingSearch/index.tsx +48 -359
- package/themes/original/src/components/BusinessPreorder/index.tsx +20 -16
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +5 -5
- package/themes/original/src/components/BusinessProductsList/index.tsx +3 -3
- package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +25 -13
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +9 -8
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +1 -1
- package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
- package/themes/original/src/components/Cart/index.tsx +19 -7
- package/themes/original/src/components/CartContent/index.tsx +58 -44
- package/themes/original/src/components/Checkout/index.tsx +106 -64
- package/themes/original/src/components/CitiesControl/index.tsx +0 -3
- package/themes/original/src/components/CouponControl/index.tsx +1 -3
- package/themes/original/src/components/DatePicker/index.tsx +18 -2
- package/themes/original/src/components/DriverTips/index.tsx +1 -3
- package/themes/original/src/components/Favorite/index.tsx +1 -5
- package/themes/original/src/components/FavoriteList/index.tsx +0 -1
- package/themes/original/src/components/ForgotPasswordForm/index.tsx +5 -7
- package/themes/original/src/components/GiftCard/GiftCardOrdersList/index.tsx +64 -0
- package/themes/original/src/components/GiftCard/GiftCardOrdersList/styles.tsx +8 -0
- package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +15 -17
- package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +3 -7
- package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +24 -32
- package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +9 -11
- package/themes/original/src/components/GiftCard/SingleGiftCard/index.tsx +101 -0
- package/themes/original/src/components/GiftCard/SingleGiftCard/styles.tsx +4 -0
- package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +82 -0
- package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/styles.tsx +9 -0
- package/themes/original/src/components/GoogleMap/index.tsx +39 -18
- package/themes/original/src/components/Help/index.tsx +2 -0
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +2 -2
- package/themes/original/src/components/Home/index.tsx +2 -10
- package/themes/original/src/components/LoginForm/Otp/index.tsx +4 -19
- package/themes/original/src/components/LoginForm/index.tsx +4 -7
- package/themes/original/src/components/MessageListing/index.tsx +1 -0
- package/themes/original/src/components/Messages/index.tsx +8 -7
- package/themes/original/src/components/MomentOption/index.tsx +13 -2
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +7 -3
- package/themes/original/src/components/MultiCheckout/index.tsx +124 -63
- package/themes/original/src/components/MultiCheckout/styles.tsx +17 -0
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +20 -14
- package/themes/original/src/components/MyOrders/index.tsx +21 -26
- package/themes/original/src/components/NavBar/index.tsx +4 -2
- package/themes/original/src/components/NetworkError/index.tsx +2 -8
- package/themes/original/src/components/NotFoundSource/index.tsx +0 -3
- package/themes/original/src/components/Notifications/index.tsx +2 -4
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +5 -7
- package/themes/original/src/components/OrderDetails/index.tsx +5 -7
- package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
- package/themes/original/src/components/OrderProgress/index.tsx +22 -3
- package/themes/original/src/components/OrderTypeSelector/index.tsx +7 -6
- package/themes/original/src/components/OrdersOption/index.tsx +2 -4
- package/themes/original/src/components/PaymentOptionCard/index.tsx +4 -2
- package/themes/original/src/components/PaymentOptionStripe/index.tsx +0 -5
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
- package/themes/original/src/components/PaymentOptions/index.tsx +47 -6
- package/themes/original/src/components/PlaceSpot/index.tsx +1 -3
- package/themes/original/src/components/PreviousOrders/index.tsx +1 -2
- package/themes/original/src/components/ProductForm/ActionButton.tsx +19 -19
- package/themes/original/src/components/ProductForm/index.tsx +123 -112
- package/themes/original/src/components/ProductItemAccordion/index.tsx +55 -49
- package/themes/original/src/components/ProductItemAccordion/styles.tsx +3 -4
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +112 -91
- package/themes/original/src/components/ProfessionalProfile/index.tsx +4 -5
- package/themes/original/src/components/Promotions/index.tsx +6 -9
- package/themes/original/src/components/ReviewDriver/index.tsx +1 -1
- package/themes/original/src/components/ReviewOrder/index.tsx +2 -2
- package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
- package/themes/original/src/components/ReviewTrigger/index.tsx +2 -2
- package/themes/original/src/components/ServiceForm/index.tsx +52 -54
- package/themes/original/src/components/Sessions/index.tsx +3 -3
- package/themes/original/src/components/SignupForm/index.tsx +65 -67
- package/themes/original/src/components/SingleOrderCard/index.tsx +1 -2
- package/themes/original/src/components/SingleProductCard/index.tsx +5 -6
- package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
- package/themes/original/src/components/StripeCardForm/index.tsx +0 -3
- package/themes/original/src/components/StripeCardsList/index.tsx +12 -35
- package/themes/original/src/components/StripeElementsForm/index.tsx +78 -59
- package/themes/original/src/components/StripeElementsForm/naked.tsx +48 -1
- package/themes/original/src/components/StripeRedirectForm/index.tsx +0 -3
- package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +3 -5
- package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +8 -3
- package/themes/original/src/components/UserFormDetails/index.tsx +88 -91
- package/themes/original/src/components/UserFormDetails/styles.tsx +7 -0
- package/themes/original/src/components/UserProfile/index.tsx +2 -1
- package/themes/original/src/components/Wallets/index.tsx +7 -4
- package/themes/original/src/components/Wallets/styles.tsx +1 -1
- package/themes/original/src/components/WebsocketStatus/index.tsx +169 -0
- package/themes/original/src/components/WebsocketStatus/styles.tsx +28 -0
- package/themes/original/src/components/shared/OButton.tsx +8 -7
- package/themes/original/src/components/shared/OInput.tsx +1 -4
- package/themes/original/src/layouts/Container.tsx +4 -2
- package/themes/original/src/types/index.tsx +6 -1
- package/themes/original/src/utils/index.tsx +12 -1
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
2
|
-
import { View, TouchableOpacity, StyleSheet, SafeAreaView, Dimensions, Platform, KeyboardAvoidingViewBase, KeyboardAvoidingView, Keyboard, KeyboardEvent, BackHandler } from 'react-native'
|
|
2
|
+
import { View, TouchableOpacity, StyleSheet, SafeAreaView, Dimensions, Platform, KeyboardAvoidingViewBase, KeyboardAvoidingView, Keyboard, KeyboardEvent, BackHandler, ScrollView } from 'react-native'
|
|
3
3
|
import { IOScrollView } from 'react-native-intersection-observer'
|
|
4
4
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
5
5
|
import { useTheme } from 'styled-components/native';
|
|
@@ -148,7 +148,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
148
148
|
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) || []
|
|
149
149
|
const currentCart: any = Object.values(orderState.carts).find((cart: any) => cart?.business?.slug === business?.slug) ?? {}
|
|
150
150
|
const isOpenFiltProducts = isOpenSearchBar && !!searchValue
|
|
151
|
-
const filtProductsHeight = Platform.OS === 'ios' ?
|
|
151
|
+
const filtProductsHeight = Platform.OS === 'ios' ? 65 : 30
|
|
152
152
|
const viewOrderButtonVisible = !loading && auth && currentCart?.products?.length > 0 && categoryState.products.length !== 0
|
|
153
153
|
|
|
154
154
|
const onRedirect = (route: string, params?: any) => {
|
|
@@ -190,13 +190,17 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
190
190
|
setOpenService(true)
|
|
191
191
|
return
|
|
192
192
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
193
|
+
if (product?.enabled) {
|
|
194
|
+
onRedirect('ProductDetails', {
|
|
195
|
+
product: product,
|
|
196
|
+
businessSlug: business.slug,
|
|
197
|
+
businessId: business.id || product?.category?.business_id,
|
|
198
|
+
productAddedToCartLength,
|
|
199
|
+
isRedirect: false
|
|
200
|
+
})
|
|
201
|
+
} else {
|
|
202
|
+
showToast(ToastType.Error, t('PRODUCT_NOT_FOUND', 'Product not found'))
|
|
203
|
+
}
|
|
200
204
|
}
|
|
201
205
|
events.emit('product_clicked', product)
|
|
202
206
|
}
|
|
@@ -377,6 +381,14 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
377
381
|
setViewedCategory(_viewedCategory)
|
|
378
382
|
events.emit('product_list_viewed', _viewedCategory)
|
|
379
383
|
}
|
|
384
|
+
} else {
|
|
385
|
+
if (business.categories) {
|
|
386
|
+
const categoryAll: any = {}
|
|
387
|
+
categoryAll.business_id = business.id
|
|
388
|
+
categoryAll.id = null
|
|
389
|
+
categoryAll.name = 'All'
|
|
390
|
+
events.emit('product_list_viewed', categoryAll)
|
|
391
|
+
}
|
|
380
392
|
}
|
|
381
393
|
}, [business?.lazy_load_products_recommended, selectedCategoryId, categorySelected?.id, viewedCategory])
|
|
382
394
|
|
|
@@ -491,8 +503,8 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
491
503
|
{business?.categories?.length > 0 && isOpenFiltProducts && (
|
|
492
504
|
<FiltProductsContainer
|
|
493
505
|
style={{
|
|
494
|
-
height: Dimensions.get('window').height - filtProductsHeight - keyboardHeight - (keyboardHeight > 0 && viewOrderButtonVisible ?
|
|
495
|
-
top: Platform.OS === 'ios' ? (searchBarHeight - 10) + insets.top : searchBarHeight,
|
|
506
|
+
height: Dimensions.get('window').height - filtProductsHeight - keyboardHeight - (keyboardHeight > 0 && viewOrderButtonVisible ? 10 : 0),
|
|
507
|
+
top: Platform.OS === 'ios' ? viewOrderButtonVisible ? (searchBarHeight - 10) + insets.top + 10 : (searchBarHeight - 10) + insets.top : searchBarHeight,
|
|
496
508
|
}}
|
|
497
509
|
contentContainerStyle={{ flexGrow: 1 }}
|
|
498
510
|
>
|
|
@@ -530,7 +542,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
530
542
|
</View>
|
|
531
543
|
</FiltProductsContainer>
|
|
532
544
|
)}
|
|
533
|
-
<
|
|
545
|
+
<ScrollView
|
|
534
546
|
stickyHeaderIndices={[business?.professionals?.length > 0 ? 4 : 3]}
|
|
535
547
|
style={{
|
|
536
548
|
...styles.mainContainer,
|
|
@@ -658,7 +670,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
658
670
|
{isOpenFiltProducts && (
|
|
659
671
|
<BackgroundGray isIos={Platform.OS === 'ios'} />
|
|
660
672
|
)}
|
|
661
|
-
</
|
|
673
|
+
</ScrollView>
|
|
662
674
|
{viewOrderButtonVisible && (
|
|
663
675
|
<View style={{ marginBottom: 0 }}>
|
|
664
676
|
<FloatingButton
|
|
@@ -26,9 +26,9 @@ import { BusinessTypeFilterParams } from '../../types';
|
|
|
26
26
|
const windowWidth = Dimensions.get('window').width;
|
|
27
27
|
|
|
28
28
|
export const BusinessTypeFilterUI = (props: BusinessTypeFilterParams) => {
|
|
29
|
-
const {
|
|
30
|
-
typesState,
|
|
31
|
-
currentTypeSelected,
|
|
29
|
+
const {
|
|
30
|
+
typesState,
|
|
31
|
+
currentTypeSelected,
|
|
32
32
|
handleChangeBusinessType,
|
|
33
33
|
setBusinessTypes,
|
|
34
34
|
isAppoint
|
|
@@ -38,13 +38,13 @@ export const BusinessTypeFilterUI = (props: BusinessTypeFilterParams) => {
|
|
|
38
38
|
|
|
39
39
|
const theme = useTheme();
|
|
40
40
|
const [isOpenAllCategories, setIsOpenAllCategories] = useState(false)
|
|
41
|
-
const defaultImage = (name
|
|
41
|
+
const defaultImage = (name: string) => theme.images?.categories?.[name.toLowerCase().replace(' ', '')]
|
|
42
42
|
|
|
43
43
|
useEffect(() => {
|
|
44
|
-
if(typesState?.types?.length > 0){
|
|
45
|
-
|
|
44
|
+
if (typesState?.types?.length > 0) {
|
|
45
|
+
setBusinessTypes && setBusinessTypes(typesState?.types)
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
}, [typesState])
|
|
48
48
|
|
|
49
49
|
const handleChangeServiceType = (serviceId: any) => {
|
|
50
50
|
if (serviceId === currentTypeSelected) {
|
|
@@ -119,10 +119,11 @@ export const BusinessTypeFilterUI = (props: BusinessTypeFilterParams) => {
|
|
|
119
119
|
<OButton
|
|
120
120
|
key={i}
|
|
121
121
|
bgColor={(currentTypeSelected === businessType?.id) ? theme.colors.primary : theme.colors.backgroundGray200}
|
|
122
|
+
borderColor={(currentTypeSelected === businessType?.id) ? theme.colors.primary : theme.colors.backgroundGray200}
|
|
122
123
|
onClick={() => handleChangeServiceType(businessType?.id)}
|
|
123
124
|
text={`${businessType?.name} ${(currentTypeSelected === businessType?.id) ? ' X' : ''}`}
|
|
124
125
|
style={styles.businessType}
|
|
125
|
-
textStyle={{ fontSize: 10, color: (currentTypeSelected === businessType?.id) ? theme.colors.
|
|
126
|
+
textStyle={{ fontSize: 10, color: (currentTypeSelected === businessType?.id) ? theme.colors.white : theme.colors.textNormal }}
|
|
126
127
|
/>
|
|
127
128
|
))}
|
|
128
129
|
</ServiceWrapper>
|
|
@@ -392,10 +392,11 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
392
392
|
<OButton
|
|
393
393
|
key={i}
|
|
394
394
|
bgColor={(priceLevelSelected === price?.level) ? theme.colors.primary : theme.colors.backgroundGray200}
|
|
395
|
+
borderColor={(priceLevelSelected === price?.level) ? theme.colors.primary : theme.colors.backgroundGray200}
|
|
395
396
|
onClick={() => handleChangePriceLevel(price?.level)}
|
|
396
397
|
text={`${price.content} ${(priceLevelSelected === price?.level) ? ' X' : ''}`}
|
|
397
398
|
style={styles.priceLevel}
|
|
398
|
-
textStyle={{ fontSize: 10, color: (priceLevelSelected === price?.level) ? theme.colors.backgroundLight : theme.colors.
|
|
399
|
+
textStyle={{ fontSize: 10, color: (priceLevelSelected === price?.level) ? theme.colors.backgroundLight : theme.colors.black }}
|
|
399
400
|
/>
|
|
400
401
|
))}
|
|
401
402
|
</ScrollView>
|
|
@@ -168,7 +168,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
168
168
|
setFeaturedBusinesses(ary);
|
|
169
169
|
}
|
|
170
170
|
resetInactivityTimeout()
|
|
171
|
-
}, [businessesList.loading])
|
|
171
|
+
}, [businessesList.loading, businessesList?.businesses])
|
|
172
172
|
|
|
173
173
|
const handleOnRefresh = () => {
|
|
174
174
|
if (!businessesList.loading) {
|
|
@@ -121,7 +121,7 @@ const CartUI = (props: any) => {
|
|
|
121
121
|
const cartsAvailable: any = Object.values(orderState?.carts)
|
|
122
122
|
?.filter((_cart: any) => _cart?.valid && _cart?.status !== 2 && _cart?.products?.length)
|
|
123
123
|
?.filter((_c: any) => !isProductCartParam ? _c.uuid !== individualCart?.uuid : _c)
|
|
124
|
-
if (cartsAvailable.length === 1 || !isMultiCheckout) {
|
|
124
|
+
if (cartsAvailable.length === 1 || !isMultiCheckout || !cart?.business_id) {
|
|
125
125
|
const cart = isMultiCheckout ? cartsAvailable[0] : individualCart
|
|
126
126
|
onNavigationRedirect('CheckoutNavigator', {
|
|
127
127
|
screen: 'CheckoutPage',
|
|
@@ -196,6 +196,18 @@ const CartUI = (props: any) => {
|
|
|
196
196
|
return acc = acc
|
|
197
197
|
}, cart?.subtotal)
|
|
198
198
|
|
|
199
|
+
const handleClickCheckout = () => {
|
|
200
|
+
if (cart?.business_id) {
|
|
201
|
+
setOpenUpselling(true)
|
|
202
|
+
} else {
|
|
203
|
+
onNavigationRedirect('CheckoutNavigator', {
|
|
204
|
+
screen: 'CheckoutPage',
|
|
205
|
+
cartUuid: cart?.uuid,
|
|
206
|
+
cartTotal: cart?.total
|
|
207
|
+
}, true)
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
199
211
|
useEffect(() => {
|
|
200
212
|
const limitDays = parseInt(preorderMaximumDays ?? configs?.max_days_preorder?.value, 10)
|
|
201
213
|
const currentDate = new Date()
|
|
@@ -211,7 +223,7 @@ const CartUI = (props: any) => {
|
|
|
211
223
|
|
|
212
224
|
return (
|
|
213
225
|
<CContainer>
|
|
214
|
-
{openUpselling && (
|
|
226
|
+
{!!openUpselling && (
|
|
215
227
|
<UpsellingProducts
|
|
216
228
|
handleUpsellingPage={handleUpsellingPage}
|
|
217
229
|
openUpselling={openUpselling}
|
|
@@ -232,7 +244,7 @@ const CartUI = (props: any) => {
|
|
|
232
244
|
handleCartOpen={handleCartOpen}
|
|
233
245
|
onNavigationRedirect={props.onNavigationRedirect}
|
|
234
246
|
handleChangeStore={() => setOpenChangeStore(true)}
|
|
235
|
-
handleClickCheckout={() =>
|
|
247
|
+
handleClickCheckout={() => handleClickCheckout()}
|
|
236
248
|
checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
|
|
237
249
|
isMultiCheckout={isMultiCheckout}
|
|
238
250
|
isFromUpselling={isFromUpselling}
|
|
@@ -532,7 +544,7 @@ const CartUI = (props: any) => {
|
|
|
532
544
|
/>
|
|
533
545
|
</View>
|
|
534
546
|
)}
|
|
535
|
-
{!isMultiCheckout && (
|
|
547
|
+
{(!isMultiCheckout || !cart?.business_id) && (
|
|
536
548
|
<>
|
|
537
549
|
{cart?.valid_products ? (
|
|
538
550
|
<CheckoutAction>
|
|
@@ -545,11 +557,11 @@ const CartUI = (props: any) => {
|
|
|
545
557
|
`${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`
|
|
546
558
|
)}
|
|
547
559
|
bgColor={(subtotalWithTaxes < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
|
|
560
|
+
borderColor={(subtotalWithTaxes < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
|
|
548
561
|
isDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
|
|
549
|
-
borderColor={theme.colors.primary}
|
|
550
562
|
imgRightSrc={null}
|
|
551
|
-
textStyle={{
|
|
552
|
-
onClick={() =>
|
|
563
|
+
textStyle={{ textAlign: 'center', flex: 1 }}
|
|
564
|
+
onClick={() => handleClickCheckout()}
|
|
553
565
|
style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
|
|
554
566
|
/>
|
|
555
567
|
</CheckoutAction>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { useLanguage, useConfig, useUtils, useOrder } from 'ordering-components/native';
|
|
4
4
|
import { useTheme } from 'styled-components/native';
|
|
@@ -13,7 +13,8 @@ export const CartContent = (props: any) => {
|
|
|
13
13
|
const {
|
|
14
14
|
onNavigationRedirect,
|
|
15
15
|
singleBusiness,
|
|
16
|
-
businessSlug
|
|
16
|
+
businessSlug,
|
|
17
|
+
navigation
|
|
17
18
|
} = props
|
|
18
19
|
|
|
19
20
|
const theme = useTheme();
|
|
@@ -22,7 +23,7 @@ export const CartContent = (props: any) => {
|
|
|
22
23
|
const [{ parsePrice }] = useUtils();
|
|
23
24
|
const [isCartsLoading, setIsCartsLoading] = useState(false)
|
|
24
25
|
const [cartsOpened, setCartsOpened] = useState([])
|
|
25
|
-
const [{ carts: cartsContext }] = useOrder();
|
|
26
|
+
const [{ carts: cartsContext }, { confirmCart }] = useOrder();
|
|
26
27
|
const cartsList =
|
|
27
28
|
(cartsContext &&
|
|
28
29
|
Object.values(cartsContext).filter((cart: any) => cart.products.length > 0)) ??
|
|
@@ -32,7 +33,7 @@ export const CartContent = (props: any) => {
|
|
|
32
33
|
: cartsList
|
|
33
34
|
const isOrderStateCarts = !!carts
|
|
34
35
|
const isMultiCheckout = configs?.checkout_multi_business_enabled?.value === '1'
|
|
35
|
-
const cartsAvailable: any = Object.values(carts || {})?.filter((cart: any) => cart?.valid && cart?.status !== 2)
|
|
36
|
+
const cartsAvailable: any = Object.values(carts || {})?.filter((cart: any) => cart?.valid && cart?.status !== 2 && cart?.business_id)
|
|
36
37
|
const totalCartsPrice = cartsAvailable?.length && cartsAvailable.reduce((total: any, cart: any) => { return total + cart?.total }, 0)
|
|
37
38
|
const totalCartsFee = cartsAvailable?.length && cartsAvailable
|
|
38
39
|
?.filter((cart: any) => cart?.status !== 1 && cart?.valid && cart?.products?.length)
|
|
@@ -71,7 +72,7 @@ export const CartContent = (props: any) => {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
const changeActiveState = useCallback((isClosed
|
|
75
|
+
const changeActiveState = useCallback((isClosed: boolean, uuid: string) => {
|
|
75
76
|
const isActive = cartsOpened?.includes?.(uuid) || !!singleBusiness
|
|
76
77
|
if (isActive || !isClosed) {
|
|
77
78
|
setCartsOpened(cartsOpened?.filter?.((_uuid) => _uuid !== uuid))
|
|
@@ -83,6 +84,20 @@ export const CartContent = (props: any) => {
|
|
|
83
84
|
}
|
|
84
85
|
}, [cartsOpened])
|
|
85
86
|
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const unsuscribe = navigation.addListener('focus', () => {
|
|
89
|
+
const cartsListBlockedByPaypal = carts?.filter((cart: any) => cart?.status === 2 && cart?.paymethod_data?.gateway === 'paypal')
|
|
90
|
+
if (cartsListBlockedByPaypal?.length > 0) {
|
|
91
|
+
cartsListBlockedByPaypal.map(async (cart: any) => {
|
|
92
|
+
await confirmCart(cart?.uuid)
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
return () => {
|
|
97
|
+
return unsuscribe()
|
|
98
|
+
}
|
|
99
|
+
}, [carts, navigation])
|
|
100
|
+
|
|
86
101
|
return (
|
|
87
102
|
<CCContainer
|
|
88
103
|
style={{ paddingHorizontal: 20 }}
|
|
@@ -120,53 +135,52 @@ export const CartContent = (props: any) => {
|
|
|
120
135
|
{isMultiCheckout && (
|
|
121
136
|
<>
|
|
122
137
|
{!!cartsAvailable.length && (
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
<OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
|
|
127
|
-
{t('TOTAL_DELIVERY_FEE', 'Total delivery fee')}
|
|
128
|
-
</OText>
|
|
129
|
-
<OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
|
|
130
|
-
{parsePrice(totalCartsFee)}
|
|
131
|
-
</OText>
|
|
132
|
-
</View>
|
|
133
|
-
)}
|
|
134
|
-
{cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0) > 0 &&
|
|
135
|
-
configs?.multi_business_checkout_show_combined_driver_tip?.value === '1' && (
|
|
138
|
+
<>
|
|
139
|
+
<ChCartsTotal>
|
|
140
|
+
{!!totalCartsFee && configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' && (
|
|
136
141
|
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
137
142
|
<OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
|
|
138
|
-
{t('
|
|
143
|
+
{t('TOTAL_DELIVERY_FEE', 'Total delivery fee')}
|
|
139
144
|
</OText>
|
|
140
145
|
<OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
|
|
141
|
-
{parsePrice(
|
|
146
|
+
{parsePrice(totalCartsFee)}
|
|
142
147
|
</OText>
|
|
143
148
|
</View>
|
|
144
149
|
)}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
150
|
+
{cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0) > 0 &&
|
|
151
|
+
configs?.multi_business_checkout_show_combined_driver_tip?.value === '1' && (
|
|
152
|
+
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
153
|
+
<OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
|
|
154
|
+
{t('DRIVER_TIP', 'Driver tip')}
|
|
155
|
+
</OText>
|
|
156
|
+
<OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
|
|
157
|
+
{parsePrice(cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0))}
|
|
158
|
+
</OText>
|
|
159
|
+
</View>
|
|
160
|
+
)}
|
|
161
|
+
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
162
|
+
<OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>
|
|
163
|
+
{t('TOTAL_FOR_ALL_CARTS', 'Total for all Carts')}
|
|
164
|
+
</OText>
|
|
165
|
+
<OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>{parsePrice(totalCartsPrice)}</OText>
|
|
166
|
+
</View>
|
|
167
|
+
<View style={{ flexDirection: 'row', justifyContent: 'center', marginVertical: 20 }}>
|
|
168
|
+
<OText size={14} color={theme.colors.textNormal} weight={'300'} style={{ textAlign: 'center' }}>
|
|
169
|
+
{t('CART_GROUP_MESSAGE_ALERT', 'Discounts may be applied at the time of payment for this group.')}
|
|
170
|
+
</OText>
|
|
171
|
+
</View>
|
|
172
|
+
</ChCartsTotal>
|
|
173
|
+
<CheckoutAction style={{ marginTop: 0 }}>
|
|
174
|
+
<OButton
|
|
175
|
+
text={t('CHECKOUT', 'Checkout')}
|
|
176
|
+
isDisabled={!cartsAvailable.length}
|
|
177
|
+
imgRightSrc={null}
|
|
178
|
+
onClick={() => handleCheckoutRedirect()}
|
|
179
|
+
style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
|
|
180
|
+
/>
|
|
181
|
+
</CheckoutAction>
|
|
182
|
+
</>
|
|
157
183
|
)}
|
|
158
|
-
<CheckoutAction style={{ marginTop: 0 }}>
|
|
159
|
-
<OButton
|
|
160
|
-
text={t('CHECKOUT', 'Checkout')}
|
|
161
|
-
bgColor={!cartsAvailable.length ? theme.colors.secundary : theme.colors.primary}
|
|
162
|
-
isDisabled={!cartsAvailable.length}
|
|
163
|
-
borderColor={theme.colors.primary}
|
|
164
|
-
imgRightSrc={null}
|
|
165
|
-
textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
|
|
166
|
-
onClick={() => handleCheckoutRedirect()}
|
|
167
|
-
style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
|
|
168
|
-
/>
|
|
169
|
-
</CheckoutAction>
|
|
170
184
|
</>
|
|
171
185
|
)}
|
|
172
186
|
</>
|