ordering-ui-react-native 0.17.85 → 0.17.87
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 +1 -1
- package/themes/business/src/components/MapView/index.tsx +2 -2
- package/themes/business/src/components/ProductItemAccordion/index.tsx +21 -3
- package/themes/original/src/components/AddressForm/index.tsx +26 -22
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +91 -70
- package/themes/original/src/components/BusinessController/index.tsx +71 -49
- package/themes/original/src/components/BusinessProductsListing/index.tsx +32 -44
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +48 -30
- package/themes/original/src/components/Cart/index.tsx +36 -71
- package/themes/original/src/components/CartContent/index.tsx +47 -2
- package/themes/original/src/components/CartContent/styles.tsx +10 -0
- package/themes/original/src/components/Checkout/index.tsx +40 -32
- package/themes/original/src/components/Messages/index.tsx +8 -7
- package/themes/original/src/components/MultiCart/index.tsx +41 -54
- package/themes/original/src/components/MultiCheckout/index.tsx +2 -7
- package/themes/original/src/components/MyOrders/index.tsx +9 -7
- package/themes/original/src/components/OrderDetails/index.tsx +99 -73
- package/themes/original/src/components/OrderTypeSelector/index.tsx +6 -4
- package/themes/original/src/components/PageBanner/index.tsx +60 -33
- package/themes/original/src/components/PageBanner/styles.tsx +0 -7
- package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
- package/themes/original/src/components/ProductForm/index.tsx +2 -2
- package/themes/original/src/components/SingleOrderCard/index.tsx +58 -44
- package/themes/original/src/components/SingleProductCard/index.tsx +51 -21
- package/themes/original/src/components/SingleProductCard/styles.tsx +11 -1
- package/themes/original/src/components/StripeCardsList/index.tsx +1 -1
- package/themes/original/src/components/UpsellingProducts/index.tsx +243 -216
- package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
- package/themes/original/src/components/UserProfile/index.tsx +82 -53
- package/themes/original/src/components/shared/OButton.tsx +5 -1
- package/themes/original/src/components/shared/OInput.tsx +8 -2
- package/themes/original/src/types/index.tsx +3 -0
- package/themes/original/src/utils/index.tsx +11 -0
|
@@ -18,8 +18,7 @@ import {
|
|
|
18
18
|
useSession,
|
|
19
19
|
useOrder,
|
|
20
20
|
useConfig,
|
|
21
|
-
useUtils
|
|
22
|
-
useOrderingTheme
|
|
21
|
+
useUtils
|
|
23
22
|
} from 'ordering-components/native';
|
|
24
23
|
import { useTheme } from 'styled-components/native';
|
|
25
24
|
import Ionicons from 'react-native-vector-icons/Ionicons'
|
|
@@ -74,13 +73,25 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
74
73
|
logosLayout
|
|
75
74
|
} = props;
|
|
76
75
|
const theme = useTheme();
|
|
77
|
-
const [orderingTheme] = useOrderingTheme()
|
|
78
76
|
const isFocused = useIsFocused();
|
|
77
|
+
|
|
78
|
+
const [, t] = useLanguage();
|
|
79
|
+
const [{ user, auth }] = useSession();
|
|
80
|
+
const [orderState, { changeCityFilter }] = useOrder();
|
|
81
|
+
const [{ configs }] = useConfig();
|
|
82
|
+
const [{ parseDate }] = useUtils();
|
|
83
|
+
|
|
79
84
|
const appState = useRef(AppState.currentState)
|
|
80
85
|
const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
|
|
81
|
-
const hideCities = theme?.business_listing_view?.components?.cities?.hidden ?? true
|
|
82
86
|
const [refreshing] = useState(false);
|
|
83
|
-
const
|
|
87
|
+
const hideCities = (theme?.business_listing_view?.components?.cities?.hidden || orderState?.options?.type !== 2) ?? true
|
|
88
|
+
const hideHero = theme?.business_listing_view?.components?.business_hero?.hidden
|
|
89
|
+
const hidePreviousOrders = theme?.business_listing_view?.components?.previous_orders_block?.hidden
|
|
90
|
+
const hideHighestBusiness = theme?.business_listing_view?.components?.highest_rated_business_block?.hidden
|
|
91
|
+
const isAllCategoriesHidden = theme?.business_listing_view?.components?.categories?.hidden
|
|
92
|
+
const bgHeader = theme?.business_listing_view?.components?.business_hero?.components?.image
|
|
93
|
+
const bgHeaderHeight = theme?.business_listing_view?.components?.business_hero?.components?.style?.height
|
|
94
|
+
|
|
84
95
|
const styles = StyleSheet.create({
|
|
85
96
|
container: {
|
|
86
97
|
marginBottom: 0,
|
|
@@ -144,13 +155,6 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
144
155
|
},
|
|
145
156
|
});
|
|
146
157
|
|
|
147
|
-
|
|
148
|
-
const [, t] = useLanguage();
|
|
149
|
-
const [{ user, auth }] = useSession();
|
|
150
|
-
const [orderState, { changeCityFilter }] = useOrder();
|
|
151
|
-
const [{ configs }] = useConfig();
|
|
152
|
-
const [{ parseDate }] = useUtils();
|
|
153
|
-
|
|
154
158
|
const { top } = useSafeAreaInsets();
|
|
155
159
|
|
|
156
160
|
const [featuredBusiness, setFeaturedBusinesses] = useState(Array);
|
|
@@ -466,18 +470,30 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
466
470
|
)}
|
|
467
471
|
</View>
|
|
468
472
|
{!isChewLayout ? (
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
473
|
+
<>
|
|
474
|
+
{!hideHero ? (
|
|
475
|
+
<HeaderWrapper
|
|
476
|
+
source={bgHeader ? { uri: bgHeader } : theme.images.backgrounds.business_list_header}
|
|
477
|
+
style={{ paddingTop: top + 20 }}
|
|
478
|
+
resizeMode='cover'
|
|
479
|
+
bgHeaderHeight={bgHeaderHeight}
|
|
480
|
+
>
|
|
481
|
+
{!auth && (
|
|
482
|
+
<TouchableOpacity onPress={() => navigation?.canGoBack() && navigation.goBack()} style={{ position: 'absolute', marginStart: 40, paddingVertical: 20 }}>
|
|
483
|
+
<OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
|
|
484
|
+
</TouchableOpacity>
|
|
485
|
+
)}
|
|
486
|
+
</HeaderWrapper>
|
|
487
|
+
) : (
|
|
488
|
+
<>
|
|
489
|
+
{!auth && (
|
|
490
|
+
<TouchableOpacity onPress={() => navigation?.canGoBack() && navigation.goBack()} style={{ position: 'absolute', marginStart: 40, paddingVertical: 20 }}>
|
|
491
|
+
<OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
|
|
492
|
+
</TouchableOpacity>
|
|
493
|
+
)}
|
|
494
|
+
</>
|
|
479
495
|
)}
|
|
480
|
-
|
|
496
|
+
</>
|
|
481
497
|
) : (
|
|
482
498
|
<OrderTypesContainer>
|
|
483
499
|
<OrderTypeSelector
|
|
@@ -502,10 +518,12 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
502
518
|
</TouchableOpacity>
|
|
503
519
|
</View>
|
|
504
520
|
)}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
521
|
+
{!hidePreviousOrders && (
|
|
522
|
+
<OrderProgress
|
|
523
|
+
{...props}
|
|
524
|
+
isFocused={isFocused}
|
|
525
|
+
/>
|
|
526
|
+
)}
|
|
509
527
|
{
|
|
510
528
|
!businessId && !props.franchiseId && featuredBusiness && featuredBusiness.length > 0 && (
|
|
511
529
|
<FeaturedWrapper>
|
|
@@ -538,7 +556,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
538
556
|
</FeaturedWrapper>
|
|
539
557
|
)
|
|
540
558
|
}
|
|
541
|
-
{!isChewLayout && (
|
|
559
|
+
{!isChewLayout && !hideHighestBusiness && (
|
|
542
560
|
<>
|
|
543
561
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
|
|
544
562
|
{
|
|
@@ -554,11 +572,11 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
554
572
|
</>
|
|
555
573
|
)}
|
|
556
574
|
|
|
557
|
-
<PageBanner position='app_business_listing' />
|
|
575
|
+
<PageBanner position='app_business_listing' navigation={navigation} />
|
|
558
576
|
|
|
559
577
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
|
|
560
578
|
<ListWrapper style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}>
|
|
561
|
-
{!businessId && (
|
|
579
|
+
{!businessId && !isAllCategoriesHidden && (
|
|
562
580
|
<BusinessTypeFilter
|
|
563
581
|
images={props.images}
|
|
564
582
|
businessTypes={props.businessTypes}
|
|
@@ -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,
|
|
11
|
+
import { CContainer, CheckoutAction, DriverTipsContainer } from './styles';
|
|
12
12
|
|
|
13
13
|
import { OSBill, OSTable, OSCoupon, OSTotal, OSRow } from '../OrderSummary/styles';
|
|
14
14
|
|
|
@@ -43,8 +43,7 @@ const CartUI = (props: any) => {
|
|
|
43
43
|
handleRemoveOfferClick,
|
|
44
44
|
isMultiCheckout,
|
|
45
45
|
hideDeliveryFee,
|
|
46
|
-
hideDriverTip
|
|
47
|
-
showGeneralBtn
|
|
46
|
+
hideDriverTip
|
|
48
47
|
} = props
|
|
49
48
|
|
|
50
49
|
const theme = useTheme();
|
|
@@ -64,13 +63,11 @@ const CartUI = (props: any) => {
|
|
|
64
63
|
|
|
65
64
|
const isCartPending = cart?.status === 2
|
|
66
65
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
|
|
67
|
-
const isCheckoutMultiBusinessEnabled: Boolean = configs?.checkout_multi_business_enabled?.value === '1'
|
|
68
|
-
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) || []
|
|
69
|
-
|
|
70
66
|
const business: any = (orderState?.carts && Object.values(orderState.carts).find((_cart: any) => _cart?.uuid === props.cartuuid)) ?? {}
|
|
71
67
|
const businessId = business?.business_id ?? null
|
|
72
68
|
const placeSpotTypes = [4]
|
|
73
|
-
|
|
69
|
+
const hideCartComments = theme?.business_view?.components?.cart?.components?.comments?.hidden
|
|
70
|
+
const hideCartDiscount = theme?.business_view?.components?.cart?.components?.discount?.hidden
|
|
74
71
|
const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
|
|
75
72
|
? JSON.parse(configs?.driver_tip_options?.value) || []
|
|
76
73
|
: configs?.driver_tip_options?.value || []
|
|
@@ -107,47 +104,34 @@ const CartUI = (props: any) => {
|
|
|
107
104
|
const handleUpsellingPage = () => {
|
|
108
105
|
setOpenUpselling(false)
|
|
109
106
|
setCanOpenUpselling(false)
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return
|
|
119
|
-
}
|
|
120
|
-
const cartGroupsCount : any = {}
|
|
121
|
-
Object.values(orderState.carts).filter(_cart => cartFilterValidation(_cart))?.forEach((_cart : any) => {
|
|
122
|
-
if (cartGroupsCount[_cart?.group?.uuid]) {
|
|
123
|
-
cartGroupsCount[_cart?.group?.uuid] += 1
|
|
124
|
-
} else {
|
|
125
|
-
cartGroupsCount[_cart?.group?.uuid] = 1
|
|
126
|
-
}
|
|
127
|
-
})
|
|
128
|
-
let groupForTheCart
|
|
129
|
-
const groupForAddCartArray = Object.keys(cartGroupsCount).filter(cartGroupUuid => cartGroupsCount[cartGroupUuid] > 0 && cartGroupsCount[cartGroupUuid] < 5)
|
|
130
|
-
const max = Math.max(...groupForAddCartArray.map(uuid => cartGroupsCount[uuid]))
|
|
131
|
-
const indexes = groupForAddCartArray.filter(uuid => cartGroupsCount[uuid] === max)
|
|
132
|
-
if (indexes?.length > 1) {
|
|
133
|
-
groupForTheCart = indexes.find(uuid => uuid !== 'undefined')
|
|
134
|
-
} else {
|
|
135
|
-
groupForTheCart = indexes[0]
|
|
136
|
-
}
|
|
137
|
-
if (isCheckoutMultiBusinessEnabled && openCarts.length > 1 && groupForTheCart) {
|
|
138
|
-
props.onNavigationRedirect('CheckoutNavigator', {
|
|
139
|
-
screen: 'MultiCart',
|
|
140
|
-
cartUuid: cart.uuid,
|
|
141
|
-
cartGroup: groupForTheCart === 'undefined' ? 'create' : groupForTheCart
|
|
107
|
+
const cartsAvailable: any = Object.values(orderState?.carts)?.filter((cart: any) => cart?.valid && cart?.status !== 2)
|
|
108
|
+
if (cartsAvailable.length === 1) {
|
|
109
|
+
onNavigationRedirect('CheckoutNavigator', {
|
|
110
|
+
screen: 'CheckoutPage',
|
|
111
|
+
cartUuid: cartsAvailable[0]?.uuid,
|
|
112
|
+
businessLogo: cartsAvailable[0]?.business?.logo,
|
|
113
|
+
businessName: cartsAvailable[0]?.business?.name,
|
|
114
|
+
cartTotal: cartsAvailable[0]?.total
|
|
142
115
|
})
|
|
143
116
|
} else {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
cartTotal: cart?.total
|
|
117
|
+
const groupKeys: any = {}
|
|
118
|
+
cartsAvailable.forEach((_cart: any) => {
|
|
119
|
+
groupKeys[_cart?.group?.uuid]
|
|
120
|
+
? groupKeys[_cart?.group?.uuid] += 1
|
|
121
|
+
: groupKeys[_cart?.group?.uuid ?? 'null'] = 1
|
|
150
122
|
})
|
|
123
|
+
|
|
124
|
+
if (
|
|
125
|
+
(Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
|
|
126
|
+
Object.keys(groupKeys).length > 1
|
|
127
|
+
) {
|
|
128
|
+
onNavigationRedirect('CheckoutNavigator', { screen: 'MultiCart' })
|
|
129
|
+
} else {
|
|
130
|
+
onNavigationRedirect('CheckoutNavigator', {
|
|
131
|
+
screen: 'MultiCheckout',
|
|
132
|
+
cartUuid: cartsAvailable[0]?.group?.uuid
|
|
133
|
+
})
|
|
134
|
+
}
|
|
151
135
|
}
|
|
152
136
|
}
|
|
153
137
|
|
|
@@ -194,26 +178,6 @@ const CartUI = (props: any) => {
|
|
|
194
178
|
|
|
195
179
|
return (
|
|
196
180
|
<CContainer>
|
|
197
|
-
{showGeneralBtn && cart?.valid_products &&(
|
|
198
|
-
<CheckoutAction style={{ marginTop: 0 }}>
|
|
199
|
-
<OButton
|
|
200
|
-
text={(subtotalWithTaxes >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
|
|
201
|
-
!openUpselling !== canOpenUpselling ? t('CHECKOUT', 'Checkout') : t('LOADING', 'Loading')
|
|
202
|
-
) : !cart?.valid_address ? (
|
|
203
|
-
`${t('OUT_OF_COVERAGE', 'Out of Coverage')}`
|
|
204
|
-
) : (
|
|
205
|
-
`${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`
|
|
206
|
-
)}
|
|
207
|
-
bgColor={(subtotalWithTaxes < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
|
|
208
|
-
isDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
|
|
209
|
-
borderColor={theme.colors.primary}
|
|
210
|
-
imgRightSrc={null}
|
|
211
|
-
textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
|
|
212
|
-
onClick={() => handleUpsellingPage()}
|
|
213
|
-
style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
|
|
214
|
-
/>
|
|
215
|
-
</CheckoutAction>
|
|
216
|
-
)}
|
|
217
181
|
{openUpselling && (
|
|
218
182
|
<UpsellingProducts
|
|
219
183
|
handleUpsellingPage={handleUpsellingPage}
|
|
@@ -251,6 +215,7 @@ const CartUI = (props: any) => {
|
|
|
251
215
|
offsetDisabled={offsetDisabled}
|
|
252
216
|
onDeleteProduct={handleDeleteClick}
|
|
253
217
|
onEditProduct={handleEditProduct}
|
|
218
|
+
viewString='business_view'
|
|
254
219
|
/>
|
|
255
220
|
))}
|
|
256
221
|
|
|
@@ -262,7 +227,7 @@ const CartUI = (props: any) => {
|
|
|
262
227
|
{parsePrice(cart?.subtotal + getIncludedTaxes())}
|
|
263
228
|
</OText>
|
|
264
229
|
</OSTable>
|
|
265
|
-
{cart?.discount > 0 && cart?.total >= 0 && cart?.offers?.length === 0 && (
|
|
230
|
+
{!hideCartDiscount && cart?.discount > 0 && cart?.total >= 0 && cart?.offers?.length === 0 && (
|
|
266
231
|
<OSTable>
|
|
267
232
|
{cart?.discount_type === 1 ? (
|
|
268
233
|
<OText size={12} lineHeight={18}>
|
|
@@ -276,7 +241,7 @@ const CartUI = (props: any) => {
|
|
|
276
241
|
</OSTable>
|
|
277
242
|
)}
|
|
278
243
|
{
|
|
279
|
-
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any, i: number) => (
|
|
244
|
+
!hideCartDiscount && cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any, i: number) => (
|
|
280
245
|
<OSTable key={`${offer.id}_${i}`}>
|
|
281
246
|
<OSRow>
|
|
282
247
|
<OText size={12} lineHeight={18}>{offer.name}</OText>
|
|
@@ -297,7 +262,7 @@ const CartUI = (props: any) => {
|
|
|
297
262
|
))
|
|
298
263
|
}
|
|
299
264
|
{/* <Divider /> */}
|
|
300
|
-
{cart?.subtotal_with_discount > 0 && cart?.discount > 0 && cart?.total >= 0 && (
|
|
265
|
+
{!hideCartDiscount && cart?.subtotal_with_discount > 0 && cart?.discount > 0 && cart?.total >= 0 && (
|
|
301
266
|
<OSTable>
|
|
302
267
|
<OText size={12} lineHeight={18} numberOfLines={1}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
|
|
303
268
|
{cart?.business?.tax_type === 1 ? (
|
|
@@ -363,7 +328,7 @@ const CartUI = (props: any) => {
|
|
|
363
328
|
{orderState?.options?.type === 1 && cart?.delivery_price > 0 && !hideDeliveryFee && (
|
|
364
329
|
<OSTable>
|
|
365
330
|
<OText size={12} lineHeight={18}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
|
|
366
|
-
<OText size={12} lineHeight={18}>{parsePrice(cart?.
|
|
331
|
+
<OText size={12} lineHeight={18}>{parsePrice(cart?.delivery_price)}</OText>
|
|
367
332
|
</OSTable>
|
|
368
333
|
)}
|
|
369
334
|
{
|
|
@@ -435,7 +400,7 @@ const CartUI = (props: any) => {
|
|
|
435
400
|
<DriverTips
|
|
436
401
|
uuid={cart?.uuid}
|
|
437
402
|
businessId={cart?.business_id}
|
|
438
|
-
driverTipsOptions={driverTipsOptions}
|
|
403
|
+
driverTipsOptions={!driverTipsOptions.includes(0) ? [0, ...driverTipsOptions] : driverTipsOptions}
|
|
439
404
|
isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)}
|
|
440
405
|
isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
|
|
441
406
|
driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)
|
|
@@ -474,7 +439,7 @@ const CartUI = (props: any) => {
|
|
|
474
439
|
</TouchableOpacity>
|
|
475
440
|
</OSTable>
|
|
476
441
|
)}
|
|
477
|
-
{cart?.status !== 2 && (
|
|
442
|
+
{cart?.status !== 2 && !hideCartComments && (
|
|
478
443
|
<OSTable>
|
|
479
444
|
<View style={{ width: '100%', marginTop: 20 }}>
|
|
480
445
|
<OText size={16} lineHeight={18}>{t('COMMENTS', 'Comments')}</OText>
|
|
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { useLanguage, useConfig } from 'ordering-components/native';
|
|
4
4
|
import { useTheme } from 'styled-components/native';
|
|
5
|
-
import { CCContainer, CCNotCarts, CCList } from './styles';
|
|
5
|
+
import { CCContainer, CCNotCarts, CCList, CheckoutAction } from './styles';
|
|
6
6
|
|
|
7
7
|
import { Cart } from '../Cart';
|
|
8
8
|
import { OButton, OText } from '../shared';
|
|
@@ -22,6 +22,38 @@ export const CartContent = (props: any) => {
|
|
|
22
22
|
|
|
23
23
|
const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
|
|
24
24
|
const isMultiCheckout = configs?.checkout_multi_business_enabled?.value === '1'
|
|
25
|
+
const cartsAvailable: any = Object.values(carts)?.filter((cart: any) => cart?.valid && cart?.status !== 2)
|
|
26
|
+
|
|
27
|
+
const handleCheckoutRedirect = () => {
|
|
28
|
+
if (cartsAvailable.length === 1) {
|
|
29
|
+
onNavigationRedirect('CheckoutNavigator', {
|
|
30
|
+
screen: 'CheckoutPage',
|
|
31
|
+
cartUuid: cartsAvailable[0]?.uuid,
|
|
32
|
+
businessLogo: cartsAvailable[0]?.business?.logo,
|
|
33
|
+
businessName: cartsAvailable[0]?.business?.name,
|
|
34
|
+
cartTotal: cartsAvailable[0]?.total
|
|
35
|
+
})
|
|
36
|
+
} else {
|
|
37
|
+
const groupKeys: any = {}
|
|
38
|
+
cartsAvailable.forEach((_cart: any) => {
|
|
39
|
+
groupKeys[_cart?.group?.uuid]
|
|
40
|
+
? groupKeys[_cart?.group?.uuid] += 1
|
|
41
|
+
: groupKeys[_cart?.group?.uuid ?? 'null'] = 1
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
if (
|
|
45
|
+
(Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
|
|
46
|
+
Object.keys(groupKeys).length > 1
|
|
47
|
+
) {
|
|
48
|
+
onNavigationRedirect('CheckoutNavigator', { screen: 'MultiCart' })
|
|
49
|
+
} else {
|
|
50
|
+
onNavigationRedirect('CheckoutNavigator', {
|
|
51
|
+
screen: 'MultiCheckout',
|
|
52
|
+
cartUuid: cartsAvailable[0]?.group?.uuid
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
25
57
|
|
|
26
58
|
return (
|
|
27
59
|
<CCContainer
|
|
@@ -34,7 +66,6 @@ export const CartContent = (props: any) => {
|
|
|
34
66
|
{cart.products.length > 0 && (
|
|
35
67
|
<>
|
|
36
68
|
<Cart
|
|
37
|
-
showGeneralBtn={i === 0 && isMultiCheckout}
|
|
38
69
|
singleBusiness={props.singleBusiness}
|
|
39
70
|
isFranchiseApp={props.isFranchiseApp}
|
|
40
71
|
cart={cart}
|
|
@@ -50,6 +81,20 @@ export const CartContent = (props: any) => {
|
|
|
50
81
|
)}
|
|
51
82
|
</CCList>
|
|
52
83
|
))}
|
|
84
|
+
{isMultiCheckout && (
|
|
85
|
+
<CheckoutAction style={{ marginTop: 0 }}>
|
|
86
|
+
<OButton
|
|
87
|
+
text={t('CHECKOUT', 'Checkout')}
|
|
88
|
+
bgColor={!cartsAvailable.length ? theme.colors.secundary : theme.colors.primary}
|
|
89
|
+
isDisabled={!cartsAvailable.length}
|
|
90
|
+
borderColor={theme.colors.primary}
|
|
91
|
+
imgRightSrc={null}
|
|
92
|
+
textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
|
|
93
|
+
onClick={() => handleCheckoutRedirect()}
|
|
94
|
+
style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
|
|
95
|
+
/>
|
|
96
|
+
</CheckoutAction>
|
|
97
|
+
)}
|
|
53
98
|
</>
|
|
54
99
|
)}
|
|
55
100
|
{(!carts || carts?.length === 0) && (
|
|
@@ -17,3 +17,13 @@ export const CCNotCarts = styled.View`
|
|
|
17
17
|
export const CCList = styled.ScrollView`
|
|
18
18
|
padding: 10px 0px;
|
|
19
19
|
`
|
|
20
|
+
|
|
21
|
+
export const CheckoutAction = styled.View`
|
|
22
|
+
width: 100%;
|
|
23
|
+
display: flex;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
align-items: center;
|
|
27
|
+
margin-top: 10px;
|
|
28
|
+
margin-bottom: 10px;
|
|
29
|
+
`
|
|
@@ -155,6 +155,10 @@ const CheckoutUI = (props: any) => {
|
|
|
155
155
|
const isWalletEnabled = configs?.cash_wallet?.value && configs?.wallet_enabled?.value === '1' && (isWalletCashEnabled || isWalletCreditPointsEnabled)
|
|
156
156
|
const isBusinessChangeEnabled = configs?.cart_change_business_validation?.value === '1'
|
|
157
157
|
const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
|
|
158
|
+
const hideBusinessAddress = theme?.checkout?.components?.business?.components?.address?.hidden
|
|
159
|
+
const hideBusinessDetails = theme?.checkout?.components?.business?.hidden
|
|
160
|
+
const hideBusinessMap = theme?.checkout?.components?.business?.components?.map?.hidden
|
|
161
|
+
const hideCustomerDetails = theme?.checkout?.components?.customer?.hidden
|
|
158
162
|
|
|
159
163
|
const isPreOrder = configs?.preorder_status_enabled?.value === '1'
|
|
160
164
|
const subtotalWithTaxes = cart?.taxes?.reduce((acc: any, item: any) => {
|
|
@@ -353,7 +357,7 @@ const CheckoutUI = (props: any) => {
|
|
|
353
357
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 18, marginHorizontal: -40 }} />
|
|
354
358
|
</ChSection>
|
|
355
359
|
|
|
356
|
-
{!isGiftCardCart && (
|
|
360
|
+
{!isGiftCardCart && !hideBusinessDetails && (
|
|
357
361
|
<ChSection>
|
|
358
362
|
<ChBusinessDetails>
|
|
359
363
|
{
|
|
@@ -384,9 +388,11 @@ const CheckoutUI = (props: any) => {
|
|
|
384
388
|
<OText size={12} lineHeight={18} weight={'400'}>
|
|
385
389
|
{businessDetails?.business?.cellphone}
|
|
386
390
|
</OText>
|
|
387
|
-
|
|
388
|
-
{
|
|
389
|
-
|
|
391
|
+
{!hideBusinessAddress && (
|
|
392
|
+
<OText size={12} lineHeight={18} weight={'400'}>
|
|
393
|
+
{businessDetails?.business?.address}
|
|
394
|
+
</OText>
|
|
395
|
+
)}
|
|
390
396
|
</View>
|
|
391
397
|
</>
|
|
392
398
|
)}
|
|
@@ -402,33 +408,35 @@ const CheckoutUI = (props: any) => {
|
|
|
402
408
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
403
409
|
</ChSection>
|
|
404
410
|
)}
|
|
411
|
+
{!hideCustomerDetails && (
|
|
405
412
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
413
|
+
<ChSection>
|
|
414
|
+
<ChUserDetails>
|
|
415
|
+
{cartState.loading ? (
|
|
416
|
+
<Placeholder Animation={Fade}>
|
|
417
|
+
<PlaceholderLine height={20} />
|
|
418
|
+
<PlaceholderLine height={12} />
|
|
419
|
+
<PlaceholderLine height={12} />
|
|
420
|
+
<PlaceholderLine height={12} style={{ marginBottom: 20 }} />
|
|
421
|
+
</Placeholder>
|
|
422
|
+
) : (
|
|
423
|
+
<UserDetails
|
|
424
|
+
isUserDetailsEdit={isUserDetailsEdit}
|
|
425
|
+
HeaderTitle={<HeaderTitle text={t('CUSTOMER_DETAILS', 'Customer Details')} mb={0} />}
|
|
426
|
+
cartStatus={cart?.status}
|
|
427
|
+
businessId={cart?.business_id}
|
|
428
|
+
useValidationFields
|
|
429
|
+
useDefualtSessionManager
|
|
430
|
+
useSessionUser
|
|
431
|
+
isCheckout
|
|
432
|
+
phoneUpdate={phoneUpdate}
|
|
433
|
+
togglePhoneUpdate={togglePhoneUpdate}
|
|
434
|
+
/>
|
|
435
|
+
)}
|
|
436
|
+
</ChUserDetails>
|
|
437
|
+
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
438
|
+
</ChSection>
|
|
439
|
+
)}
|
|
432
440
|
|
|
433
441
|
{options?.type === 1 && !isGiftCardCart && (
|
|
434
442
|
<DeliveryOptionsContainer>
|
|
@@ -509,7 +517,7 @@ const CheckoutUI = (props: any) => {
|
|
|
509
517
|
</ChSection>
|
|
510
518
|
)}
|
|
511
519
|
|
|
512
|
-
{!isGiftCardCart && (
|
|
520
|
+
{!isGiftCardCart && !hideBusinessMap && (
|
|
513
521
|
<ChSection>
|
|
514
522
|
<ChAddress>
|
|
515
523
|
{(businessDetails?.loading || cartState.loading) ? (
|
|
@@ -549,7 +557,7 @@ const CheckoutUI = (props: any) => {
|
|
|
549
557
|
<DriverTips
|
|
550
558
|
uuid={cartUuid}
|
|
551
559
|
businessId={cart?.business_id}
|
|
552
|
-
driverTipsOptions={driverTipsOptions}
|
|
560
|
+
driverTipsOptions={!driverTipsOptions.includes(0) ? [0, ...driverTipsOptions] : driverTipsOptions}
|
|
553
561
|
isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)}
|
|
554
562
|
isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
|
|
555
563
|
driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)
|
|
@@ -13,6 +13,7 @@ import { Header, TitleHeader, Wrapper, QuickMessageContainer, ProfileMessageHead
|
|
|
13
13
|
import { MessagesParams } from '../../types'
|
|
14
14
|
import { useWindowDimensions } from 'react-native'
|
|
15
15
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
16
|
+
import { getLogisticTag } from '../../utils'
|
|
16
17
|
|
|
17
18
|
const ORDER_STATUS: any = {
|
|
18
19
|
0: 'ORDER_STATUS_PENDING',
|
|
@@ -127,7 +128,7 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
127
128
|
?
|
|
128
129
|
`${t('ORDER', 'Order')} ${t(message.change.attribute.toUpperCase(), message.change.attribute.replace('_', ' '))} ${t('CHANGED_FROM', 'Changed from')} ${filterSpecialStatus.includes(message.change.attribute) ?
|
|
129
130
|
`${message.change.old === null ? '0' : message.change.old} ${t('TO', 'to')} ${message.change.new} ${t('MINUTES', 'Minutes')}` :
|
|
130
|
-
`${message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])} ${t('TO', 'to')} ${t(ORDER_STATUS[parseInt(message.change.new, 10)])}`
|
|
131
|
+
`${message.change?.attribute !== 'logistic_status' ? message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)]) : message.change.old !== null && getLogisticTag(message.change.old)} ${t('TO', 'to')} ${message.change?.attribute !== 'logistic_status' ? t(ORDER_STATUS[parseInt(message.change.new, 10)]) : getLogisticTag(message.change.new)}`
|
|
131
132
|
}`
|
|
132
133
|
: message.change.new
|
|
133
134
|
?
|
|
@@ -155,9 +156,9 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
155
156
|
image: message.source,
|
|
156
157
|
system: message.type === 1,
|
|
157
158
|
user: {
|
|
158
|
-
_id: message.author.id,
|
|
159
|
-
name: message.author.name,
|
|
160
|
-
avatar: message.author.id !== user.id && type === USER_TYPE.DRIVER ? order?.driver?.photo : order?.business?.logo
|
|
159
|
+
_id: message.author && message.author.id,
|
|
160
|
+
name: message.author && message.author.name,
|
|
161
|
+
avatar: message.author && (message.author.id !== user.id && type === USER_TYPE.DRIVER ? order?.driver?.photo : order?.business?.logo)
|
|
161
162
|
}
|
|
162
163
|
});
|
|
163
164
|
}
|
|
@@ -170,9 +171,9 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
170
171
|
image: message.source,
|
|
171
172
|
system: message.type === 1,
|
|
172
173
|
user: {
|
|
173
|
-
_id: message.author.id,
|
|
174
|
-
name: message.author.name,
|
|
175
|
-
avatar: message.author.id !== user.id && type === USER_TYPE.DRIVER ? order?.driver?.photo : order?.business?.logo
|
|
174
|
+
_id: message.author && message.author.id ,
|
|
175
|
+
name: message.author && message.author.name,
|
|
176
|
+
avatar: message.author && (message.author.id !== user.id && type === USER_TYPE.DRIVER ? order?.driver?.photo : order?.business?.logo)
|
|
176
177
|
}
|
|
177
178
|
});
|
|
178
179
|
}
|