ordering-ui-react-native 0.16.59-release → 0.16.60-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 +1 -1
- package/themes/original/src/components/BusinessProductsListing/index.tsx +29 -41
- package/themes/original/src/components/Cart/index.tsx +28 -65
- 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 +1 -1
- package/themes/original/src/components/MultiCart/index.tsx +41 -54
- 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 -40
- package/themes/original/src/components/StripeCardsList/index.tsx +1 -1
- package/themes/original/src/components/UpsellingProducts/index.tsx +243 -224
- package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
- package/themes/original/src/types/index.tsx +2 -0
package/package.json
CHANGED
|
@@ -187,47 +187,35 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
187
187
|
const handleUpsellingPage = () => {
|
|
188
188
|
setOpenUpselling(false)
|
|
189
189
|
setCanOpenUpselling(false)
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
screen: 'MultiCheckout'
|
|
220
|
-
})
|
|
221
|
-
} else {
|
|
222
|
-
onRedirect('CheckoutNavigator', {
|
|
223
|
-
screen: 'CheckoutPage',
|
|
224
|
-
cartUuid: currentCart?.uuid,
|
|
225
|
-
businessLogo: logo,
|
|
226
|
-
businessName: business?.name,
|
|
227
|
-
cartTotal: currentCart?.total
|
|
228
|
-
})
|
|
229
|
-
}
|
|
230
|
-
setOpenUpselling(false)
|
|
190
|
+
const cartsAvailable: any = Object.values(orderState?.carts)?.filter((cart: any) => cart?.valid && cart?.status !== 2)
|
|
191
|
+
if (cartsAvailable.length === 1) {
|
|
192
|
+
props.onNavigationRedirect('CheckoutNavigator', {
|
|
193
|
+
screen: 'CheckoutPage',
|
|
194
|
+
cartUuid: cartsAvailable[0]?.uuid,
|
|
195
|
+
businessLogo: cartsAvailable[0]?.business?.logo,
|
|
196
|
+
businessName: cartsAvailable[0]?.business?.name,
|
|
197
|
+
cartTotal: cartsAvailable[0]?.total
|
|
198
|
+
})
|
|
199
|
+
} else {
|
|
200
|
+
const groupKeys: any = {}
|
|
201
|
+
cartsAvailable.forEach((_cart: any) => {
|
|
202
|
+
groupKeys[_cart?.group?.uuid]
|
|
203
|
+
? groupKeys[_cart?.group?.uuid] += 1
|
|
204
|
+
: groupKeys[_cart?.group?.uuid ?? 'null'] = 1
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
if (
|
|
208
|
+
(Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
|
|
209
|
+
Object.keys(groupKeys).length > 1
|
|
210
|
+
) {
|
|
211
|
+
props.onNavigationRedirect('CheckoutNavigator', { screen: 'MultiCart' })
|
|
212
|
+
} else {
|
|
213
|
+
props.onNavigationRedirect('CheckoutNavigator', {
|
|
214
|
+
screen: 'MultiCheckout',
|
|
215
|
+
cartUuid: cartsAvailable[0]?.group?.uuid
|
|
216
|
+
})
|
|
217
|
+
}
|
|
218
|
+
}
|
|
231
219
|
}
|
|
232
220
|
|
|
233
221
|
const handleCloseUpsellingPage = () => {
|
|
@@ -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,9 +63,6 @@ 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]
|
|
@@ -107,47 +103,34 @@ const CartUI = (props: any) => {
|
|
|
107
103
|
const handleUpsellingPage = () => {
|
|
108
104
|
setOpenUpselling(false)
|
|
109
105
|
setCanOpenUpselling(false)
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
106
|
+
const cartsAvailable: any = Object.values(orderState?.carts)?.filter((cart: any) => cart?.valid && cart?.status !== 2)
|
|
107
|
+
if (cartsAvailable.length === 1) {
|
|
108
|
+
onNavigationRedirect('CheckoutNavigator', {
|
|
109
|
+
screen: 'CheckoutPage',
|
|
110
|
+
cartUuid: cartsAvailable[0]?.uuid,
|
|
111
|
+
businessLogo: cartsAvailable[0]?.business?.logo,
|
|
112
|
+
businessName: cartsAvailable[0]?.business?.name,
|
|
113
|
+
cartTotal: cartsAvailable[0]?.total
|
|
117
114
|
})
|
|
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
115
|
} else {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
cartUuid: cart.uuid,
|
|
141
|
-
cartGroup: groupForTheCart === 'undefined' ? 'create' : groupForTheCart
|
|
142
|
-
})
|
|
143
|
-
} else {
|
|
144
|
-
props.onNavigationRedirect('CheckoutNavigator', {
|
|
145
|
-
screen: 'CheckoutPage',
|
|
146
|
-
cartUuid: cart?.uuid,
|
|
147
|
-
businessLogo: cart?.business?.logo,
|
|
148
|
-
businessName: cart?.business?.name,
|
|
149
|
-
cartTotal: cart?.total
|
|
116
|
+
const groupKeys: any = {}
|
|
117
|
+
cartsAvailable.forEach((_cart: any) => {
|
|
118
|
+
groupKeys[_cart?.group?.uuid]
|
|
119
|
+
? groupKeys[_cart?.group?.uuid] += 1
|
|
120
|
+
: groupKeys[_cart?.group?.uuid ?? 'null'] = 1
|
|
150
121
|
})
|
|
122
|
+
|
|
123
|
+
if (
|
|
124
|
+
(Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
|
|
125
|
+
Object.keys(groupKeys).length > 1
|
|
126
|
+
) {
|
|
127
|
+
onNavigationRedirect('CheckoutNavigator', { screen: 'MultiCart' })
|
|
128
|
+
} else {
|
|
129
|
+
onNavigationRedirect('CheckoutNavigator', {
|
|
130
|
+
screen: 'MultiCheckout',
|
|
131
|
+
cartUuid: cartsAvailable[0]?.group?.uuid
|
|
132
|
+
})
|
|
133
|
+
}
|
|
151
134
|
}
|
|
152
135
|
}
|
|
153
136
|
|
|
@@ -194,26 +177,6 @@ const CartUI = (props: any) => {
|
|
|
194
177
|
|
|
195
178
|
return (
|
|
196
179
|
<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
180
|
{openUpselling && (
|
|
218
181
|
<UpsellingProducts
|
|
219
182
|
handleUpsellingPage={handleUpsellingPage}
|
|
@@ -434,7 +397,7 @@ const CartUI = (props: any) => {
|
|
|
434
397
|
<DriverTips
|
|
435
398
|
uuid={cart?.uuid}
|
|
436
399
|
businessId={cart?.business_id}
|
|
437
|
-
driverTipsOptions={driverTipsOptions}
|
|
400
|
+
driverTipsOptions={!driverTipsOptions.includes(0) ? [0, ...driverTipsOptions] : driverTipsOptions}
|
|
438
401
|
isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)}
|
|
439
402
|
isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
|
|
440
403
|
driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)
|
|
@@ -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
|
+
`
|
|
@@ -539,7 +539,7 @@ const CheckoutUI = (props: any) => {
|
|
|
539
539
|
<DriverTips
|
|
540
540
|
uuid={cartUuid}
|
|
541
541
|
businessId={cart?.business_id}
|
|
542
|
-
driverTipsOptions={driverTipsOptions}
|
|
542
|
+
driverTipsOptions={!driverTipsOptions.includes(0) ? [0, ...driverTipsOptions] : driverTipsOptions}
|
|
543
543
|
isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)}
|
|
544
544
|
isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
|
|
545
545
|
driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)
|
|
@@ -1,63 +1,50 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { View } from 'react-native'
|
|
3
3
|
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder'
|
|
4
|
-
import { Container } from '../../layouts/Container';
|
|
5
|
-
import { View, StyleSheet } from 'react-native'
|
|
6
4
|
import { useTheme } from 'styled-components/native';
|
|
7
5
|
import { MultiCartCreate } from 'ordering-components/native'
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const styles = StyleSheet.create({
|
|
13
|
-
pagePadding: {
|
|
14
|
-
paddingHorizontal: 40
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<>
|
|
20
|
-
<Container noPadding>
|
|
21
|
-
<ChContainer style={styles.pagePadding}>
|
|
22
|
-
<ChSection>
|
|
23
|
-
<ChUserDetails>
|
|
24
|
-
<Placeholder Animation={Fade}>
|
|
25
|
-
<PlaceholderLine height={20} />
|
|
26
|
-
<PlaceholderLine height={12} />
|
|
27
|
-
<PlaceholderLine height={12} />
|
|
28
|
-
<PlaceholderLine height={12} style={{ marginBottom: 20 }} />
|
|
29
|
-
</Placeholder>
|
|
30
|
-
</ChUserDetails>
|
|
31
|
-
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
32
|
-
</ChSection>
|
|
33
|
-
<DeliveryOptionsContainer>
|
|
34
|
-
<View style={{ height: 110 }}>
|
|
35
|
-
<Placeholder Animation={Fade}>
|
|
36
|
-
<PlaceholderLine height={20} />
|
|
37
|
-
<PlaceholderLine height={40} />
|
|
38
|
-
</Placeholder>
|
|
39
|
-
</View>
|
|
40
|
-
</DeliveryOptionsContainer>
|
|
41
|
-
<ChSection>
|
|
42
|
-
<ChAddress>
|
|
43
|
-
<Placeholder Animation={Fade}>
|
|
44
|
-
<PlaceholderLine height={20} style={{ marginBottom: 50 }} />
|
|
45
|
-
<PlaceholderLine height={100} />
|
|
46
|
-
</Placeholder>
|
|
47
|
-
</ChAddress>
|
|
48
|
-
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
|
|
49
|
-
</ChSection>
|
|
50
|
-
</ChContainer>
|
|
51
|
-
</Container>
|
|
7
|
+
import { Container } from '../../layouts/Container';
|
|
8
|
+
import { ChContainer, ChSection, ChUserDetails } from '../Checkout/styles'
|
|
52
9
|
|
|
53
|
-
|
|
54
|
-
|
|
10
|
+
export const MultiCartUI = () => {
|
|
11
|
+
const theme = useTheme();
|
|
12
|
+
return (
|
|
13
|
+
<Container noPadding>
|
|
14
|
+
<ChContainer style={{ paddingHorizontal: 40 }}>
|
|
15
|
+
<ChSection>
|
|
16
|
+
<ChUserDetails>
|
|
17
|
+
<Placeholder Animation={Fade}>
|
|
18
|
+
<PlaceholderLine height={20} />
|
|
19
|
+
<PlaceholderLine height={20} />
|
|
20
|
+
<PlaceholderLine height={20} />
|
|
21
|
+
<PlaceholderLine height={20} style={{ marginBottom: 20 }} />
|
|
22
|
+
</Placeholder>
|
|
23
|
+
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40, marginBottom: 20 }} />
|
|
24
|
+
<Placeholder Animation={Fade}>
|
|
25
|
+
<PlaceholderLine height={20} />
|
|
26
|
+
<PlaceholderLine height={20} />
|
|
27
|
+
<PlaceholderLine height={20} />
|
|
28
|
+
<PlaceholderLine height={20} style={{ marginBottom: 20 }} />
|
|
29
|
+
</Placeholder>
|
|
30
|
+
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40, marginBottom: 20 }} />
|
|
31
|
+
<Placeholder Animation={Fade}>
|
|
32
|
+
<PlaceholderLine height={20} />
|
|
33
|
+
<PlaceholderLine height={120} style={{ marginBottom: 20, borderRadius: 8 }} />
|
|
34
|
+
<PlaceholderLine height={20} />
|
|
35
|
+
<PlaceholderLine height={20} />
|
|
36
|
+
</Placeholder>
|
|
37
|
+
</ChUserDetails>
|
|
38
|
+
</ChSection>
|
|
39
|
+
</ChContainer>
|
|
40
|
+
</Container>
|
|
41
|
+
)
|
|
55
42
|
}
|
|
56
43
|
|
|
57
|
-
export const MultiCart = (props
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
export const MultiCart = (props: any) => {
|
|
45
|
+
const mulcartProps = {
|
|
46
|
+
...props,
|
|
47
|
+
UIComponent: MultiCartUI
|
|
48
|
+
}
|
|
49
|
+
return <MultiCartCreate {...mulcartProps} />
|
|
63
50
|
}
|
|
@@ -546,7 +546,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
546
546
|
>
|
|
547
547
|
{(String(img).includes('http') || typeof img === 'number') ? (
|
|
548
548
|
<FastImage
|
|
549
|
-
style={{ height: '100%', opacity: isSoldOut ? 0.5 : 1, aspectRatio:
|
|
549
|
+
style={{ height: '100%', opacity: isSoldOut ? 0.5 : 1, aspectRatio: 16 / 9 }}
|
|
550
550
|
source={typeof img !== 'number' ? {
|
|
551
551
|
uri: optimizeImage(img, 'h_1024,c_limit'),
|
|
552
552
|
priority: FastImage.priority.normal,
|
|
@@ -574,7 +574,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
574
574
|
paddingVertical: 15
|
|
575
575
|
}}
|
|
576
576
|
>
|
|
577
|
-
{gallery?.length >
|
|
577
|
+
{gallery?.length > 1 && gallery.map((img, index) => (
|
|
578
578
|
<TouchableOpacity
|
|
579
579
|
key={index}
|
|
580
580
|
onPress={() => handleClickThumb(index)}
|
|
@@ -151,7 +151,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
151
151
|
order: {
|
|
152
152
|
id: order?.id,
|
|
153
153
|
business_id: order?.business_id,
|
|
154
|
-
logo: order?.business?.length > 1 ? order?.business?.map?.((business
|
|
154
|
+
logo: order?.business?.length > 1 ? order?.business?.map?.((business: any) => business?.logo) : order?.business?.logo,
|
|
155
155
|
driver: order?.driver,
|
|
156
156
|
products: order?.products,
|
|
157
157
|
review: order?.review,
|
|
@@ -174,7 +174,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
174
174
|
handleClickOrder(order?.uuid)
|
|
175
175
|
return
|
|
176
176
|
}
|
|
177
|
-
if (order?.cart_group_id){
|
|
177
|
+
if (order?.cart_group_id) {
|
|
178
178
|
onNavigationRedirect?.('MultiOrdersDetails', { orderId: order?.cart_group_id });
|
|
179
179
|
} else {
|
|
180
180
|
onNavigationRedirect?.('OrderDetails', { orderId: order?.uuid });
|
|
@@ -189,6 +189,15 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
189
189
|
setConfirm({ ...confirm, open: false, title: null })
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
const hideBusinessLogo = theme?.orders?.components?.business_logo?.hidden
|
|
193
|
+
const hideDate = theme?.orders?.components?.date?.hidden
|
|
194
|
+
const hideBusinessName = theme?.orders?.components?.business_name?.hidden
|
|
195
|
+
const hideOrderNumber = theme?.orders?.components?.order_number?.hidden
|
|
196
|
+
const hideReviewOrderButton = theme?.orders?.components?.review_order_button?.hidden
|
|
197
|
+
const hideReorderButton = theme?.orders?.components?.reorder_button?.hidden
|
|
198
|
+
const hideFavorite = theme?.orders?.components?.favorite?.hidden
|
|
199
|
+
const hideOrderStatus = theme?.orders?.components?.order_status?.hidden
|
|
200
|
+
|
|
192
201
|
return (
|
|
193
202
|
<>
|
|
194
203
|
<CardAnimation
|
|
@@ -196,28 +205,26 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
196
205
|
style={[styles.container]}
|
|
197
206
|
>
|
|
198
207
|
<InnerContainer>
|
|
199
|
-
{(!!order.business?.logo || theme?.images?.dummies?.businessLogo) && (
|
|
208
|
+
{!hideBusinessLogo && (!!order.business?.logo || theme?.images?.dummies?.businessLogo) && (
|
|
200
209
|
<>
|
|
201
210
|
{order?.business?.length > 1 ? (
|
|
202
211
|
<MultiLogosContainer>
|
|
203
|
-
{order?.business?.map((business: any, i: number) => (
|
|
204
|
-
<
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
style={styles.minilogo}
|
|
216
|
-
/>
|
|
217
|
-
</Logo>
|
|
218
|
-
)}
|
|
219
|
-
</View>
|
|
212
|
+
{order?.business?.map((business: any, i: number) => i < 2 && (
|
|
213
|
+
<Logo
|
|
214
|
+
isMulti
|
|
215
|
+
key={business?.id}
|
|
216
|
+
style={styles.logoWrapper}
|
|
217
|
+
>
|
|
218
|
+
<OIcon
|
|
219
|
+
url={optimizeImage(business?.logo, 'h_300,c_limit')}
|
|
220
|
+
src={optimizeImage(!business?.logo && theme?.images?.dummies?.businessLogo, 'h_300,c_limit')}
|
|
221
|
+
style={styles.minilogo}
|
|
222
|
+
/>
|
|
223
|
+
</Logo>
|
|
220
224
|
))}
|
|
225
|
+
{order?.business?.length > 1 && (order?.business?.length - 2) > 0 && (
|
|
226
|
+
<OText mRight={3}> + {order?.business?.length - 2}</OText>
|
|
227
|
+
)}
|
|
221
228
|
</MultiLogosContainer>
|
|
222
229
|
) : (
|
|
223
230
|
<Logo style={styles.logoWrapper}>
|
|
@@ -232,11 +239,13 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
232
239
|
)}
|
|
233
240
|
<CardInfoWrapper>
|
|
234
241
|
<ContentHeader>
|
|
235
|
-
|
|
236
|
-
<
|
|
237
|
-
{
|
|
238
|
-
|
|
239
|
-
|
|
242
|
+
{(order?.business?.length > 1 && !hideOrderNumber) || (!order?.business?.length && !hideBusinessName) && (
|
|
243
|
+
<View style={{ flex: 1 }}>
|
|
244
|
+
<OText size={12} lineHeight={18} weight={'600'} numberOfLines={1} ellipsizeMode={'tail'}>
|
|
245
|
+
{order?.business?.length > 1 ? `${t('GROUP_ORDER', 'Group Order')} ${t('No', 'No')}. ${order?.cart_group_id}` : order.business?.name}
|
|
246
|
+
</OText>
|
|
247
|
+
</View>
|
|
248
|
+
)}
|
|
240
249
|
{!!!pastOrders && (
|
|
241
250
|
<>
|
|
242
251
|
{isMessageView ? (
|
|
@@ -260,7 +269,8 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
260
269
|
)}
|
|
261
270
|
{!!pastOrders && (
|
|
262
271
|
<ButtonWrapper>
|
|
263
|
-
{
|
|
272
|
+
{!hideReviewOrderButton &&
|
|
273
|
+
allowedOrderStatus.includes(parseInt(order?.status)) &&
|
|
264
274
|
!order.review && (
|
|
265
275
|
<TouchableOpacity
|
|
266
276
|
onPress={() => handleClickOrderReview(order)}
|
|
@@ -270,7 +280,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
270
280
|
</OText>
|
|
271
281
|
</TouchableOpacity>
|
|
272
282
|
)}
|
|
273
|
-
{order.cart && (
|
|
283
|
+
{order.cart && !hideReorderButton && (
|
|
274
284
|
<OButton
|
|
275
285
|
text={t('REORDER', 'Reorder')}
|
|
276
286
|
imgRightSrc={''}
|
|
@@ -290,7 +300,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
290
300
|
<ContentFooter>
|
|
291
301
|
<View style={{ flex: 1 }}>
|
|
292
302
|
<View style={styles.infoText}>
|
|
293
|
-
{(!!!pastOrders || order?.business?.length > 1) && (
|
|
303
|
+
{(!!!pastOrders || order?.business?.length > 1) && !hideOrderNumber && (
|
|
294
304
|
<>
|
|
295
305
|
<OText
|
|
296
306
|
size={10}
|
|
@@ -313,24 +323,32 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
313
323
|
</OText>
|
|
314
324
|
</>
|
|
315
325
|
)}
|
|
326
|
+
{!hideDate && (
|
|
327
|
+
<OText
|
|
328
|
+
size={10}
|
|
329
|
+
lineHeight={15}
|
|
330
|
+
color={theme.colors.textSecondary}
|
|
331
|
+
style={{ marginVertical: 3 }}
|
|
332
|
+
numberOfLines={1}>
|
|
333
|
+
{
|
|
334
|
+
pastOrders
|
|
335
|
+
? order?.delivery_datetime_utc ? parseDate(order?.delivery_datetime_utc) : parseDate(order?.delivery_datetime, { utc: false })
|
|
336
|
+
: order?.eta_time + 'min'
|
|
337
|
+
}
|
|
338
|
+
</OText>
|
|
339
|
+
)}
|
|
340
|
+
</View>
|
|
341
|
+
{!hideOrderStatus && (
|
|
316
342
|
<OText
|
|
343
|
+
color={theme.colors.primary}
|
|
317
344
|
size={10}
|
|
318
345
|
lineHeight={15}
|
|
319
|
-
color={theme.colors.textSecondary}
|
|
320
|
-
style={{ marginVertical: 3 }}
|
|
321
346
|
numberOfLines={1}>
|
|
322
|
-
{
|
|
347
|
+
{getOrderStatus(order.status)?.value}
|
|
323
348
|
</OText>
|
|
324
|
-
|
|
325
|
-
<OText
|
|
326
|
-
color={theme.colors.primary}
|
|
327
|
-
size={10}
|
|
328
|
-
lineHeight={15}
|
|
329
|
-
numberOfLines={1}>
|
|
330
|
-
{getOrderStatus(order.status)?.value}
|
|
331
|
-
</OText>
|
|
349
|
+
)}
|
|
332
350
|
</View>
|
|
333
|
-
{!isMessageView && !order?.business?.length && (
|
|
351
|
+
{!isMessageView && !order?.business?.length && !hideFavorite && (
|
|
334
352
|
<LottieAnimation
|
|
335
353
|
type='favorite'
|
|
336
354
|
onClick={handleChangeFavorite}
|
|
@@ -1,252 +1,271 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react'
|
|
2
2
|
import { Platform, StyleSheet, TouchableOpacity, View } from 'react-native'
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
UpsellingPage as UpsellingPageController,
|
|
5
|
+
useUtils,
|
|
6
|
+
useLanguage,
|
|
7
|
+
useOrder,
|
|
8
|
+
useConfig
|
|
8
9
|
} from 'ordering-components/native'
|
|
9
10
|
import { useTheme } from 'styled-components/native';
|
|
10
11
|
import { OText, OIcon, OBottomPopup, OButton } from '../shared'
|
|
11
12
|
import { UpsellingProductsParams } from '../../types'
|
|
12
13
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
Container,
|
|
15
|
+
UpsellingContainer,
|
|
16
|
+
Item,
|
|
17
|
+
Details,
|
|
18
|
+
AddButton,
|
|
19
|
+
CartList,
|
|
20
|
+
CartDivider
|
|
20
21
|
} from './styles'
|
|
21
22
|
import { OrderSummary } from '../OrderSummary';
|
|
23
|
+
import { Cart } from '../Cart';
|
|
22
24
|
import { ScrollView } from 'react-native-gesture-handler';
|
|
23
25
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
24
|
-
import AntDesignIcon from 'react-native-vector-icons/AntDesign'
|
|
25
26
|
|
|
26
27
|
const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
const {
|
|
29
|
+
isCustomMode,
|
|
30
|
+
upsellingProducts,
|
|
31
|
+
business,
|
|
32
|
+
handleUpsellingPage,
|
|
33
|
+
handleCloseUpsellingPage,
|
|
34
|
+
openUpselling,
|
|
35
|
+
canOpenUpselling,
|
|
36
|
+
setCanOpenUpselling,
|
|
37
|
+
isFromCart,
|
|
38
|
+
onNavigationRedirect,
|
|
39
|
+
onGoBack
|
|
40
|
+
} = props
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
const theme = useTheme();
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
44
|
+
const styles = StyleSheet.create({
|
|
45
|
+
imageStyle: {
|
|
46
|
+
width: 73,
|
|
47
|
+
height: 73,
|
|
48
|
+
resizeMode: 'cover',
|
|
49
|
+
borderRadius: 7.6,
|
|
50
|
+
},
|
|
51
|
+
closeUpsellingButton: {
|
|
52
|
+
borderRadius: 7.6,
|
|
53
|
+
borderColor: theme.colors.primary,
|
|
54
|
+
backgroundColor: theme.colors.primary,
|
|
55
|
+
borderWidth: 1,
|
|
56
|
+
alignSelf: 'center',
|
|
57
|
+
height: 44,
|
|
58
|
+
shadowOpacity: 0,
|
|
59
|
+
width: '80%',
|
|
60
|
+
},
|
|
61
|
+
cancelBtn: {
|
|
62
|
+
paddingHorizontal: 18,
|
|
63
|
+
borderWidth: 1,
|
|
64
|
+
borderRadius: 7.6,
|
|
65
|
+
borderColor: theme.colors.textSecondary,
|
|
66
|
+
height: 38
|
|
67
|
+
},
|
|
68
|
+
headerItem: {
|
|
69
|
+
flexDirection: 'row',
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
marginVertical: 2,
|
|
72
|
+
marginHorizontal: 20,
|
|
73
|
+
},
|
|
74
|
+
btnBackArrow: {
|
|
75
|
+
borderWidth: 0,
|
|
76
|
+
width: 26,
|
|
77
|
+
height: 26,
|
|
78
|
+
backgroundColor: theme.colors.clear,
|
|
79
|
+
borderColor: theme.colors.clear,
|
|
80
|
+
shadowColor: theme.colors.clear,
|
|
81
|
+
paddingLeft: 0,
|
|
82
|
+
paddingRight: 0,
|
|
83
|
+
marginLeft: 20,
|
|
84
|
+
marginBottom: 10
|
|
85
|
+
},
|
|
86
|
+
})
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
const [modalIsOpen, setModalIsOpen] = useState(false)
|
|
89
|
+
const [{ carts }] = useOrder()
|
|
90
|
+
const [{ parsePrice }] = useUtils()
|
|
91
|
+
const [{ configs }] = useConfig()
|
|
92
|
+
const [, t] = useLanguage()
|
|
93
|
+
const { bottom } = useSafeAreaInsets()
|
|
94
|
+
const [isCheckout, setIsCheckout] = useState(false)
|
|
95
|
+
const [isCartsLoading, setIsCartsLoading] = useState(false)
|
|
93
96
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
const isMultiCheckout = configs?.checkout_multi_business_enabled?.value === '1'
|
|
98
|
+
const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
|
|
99
|
+
const showCartList = isChewLayout
|
|
100
|
+
const commentDelayTime = isChewLayout ? 500 : null
|
|
98
101
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
const cart = carts?.[`businessId:${props.businessId}`] ?? {}
|
|
103
|
+
const cartList = (carts && Object.values(carts).filter((_cart: any) => _cart?.products?.length > 0 && _cart.uuid !== cart?.uuid)) || []
|
|
104
|
+
const cartProducts = cart?.products?.length
|
|
105
|
+
? cart?.products.map((product: any) => product.id)
|
|
106
|
+
: []
|
|
104
107
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
} else {
|
|
111
|
-
handleUpsellingPage && handleUpsellingPage()
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}, [upsellingProducts.loading, upsellingProducts?.products.length])
|
|
108
|
+
const productsList = !upsellingProducts.loading && !upsellingProducts.error
|
|
109
|
+
? upsellingProducts?.products?.length
|
|
110
|
+
? upsellingProducts?.products.filter((product: any) => !cartProducts.includes(product.id))
|
|
111
|
+
: (props?.products ?? []).filter((product: any) => !cartProducts.includes(product.id)) ?? []
|
|
112
|
+
: []
|
|
116
113
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (!isCustomMode && !props.products) {
|
|
116
|
+
if (!upsellingProducts.loading) {
|
|
117
|
+
if (upsellingProducts?.products?.length && !isFromCart) {
|
|
118
|
+
setCanOpenUpselling && setCanOpenUpselling(true)
|
|
119
|
+
} else {
|
|
120
|
+
handleUpsellingPage && handleUpsellingPage()
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}, [upsellingProducts.loading, upsellingProducts?.products.length])
|
|
124
125
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
>
|
|
133
|
-
{
|
|
134
|
-
!upsellingProducts.loading && (
|
|
135
|
-
<>
|
|
136
|
-
{
|
|
137
|
-
!upsellingProducts.error ? productsList.map((product: any, i: number) => (
|
|
138
|
-
<Item key={`${product.id}_${i}`}>
|
|
139
|
-
<View style={{ flexBasis: '57%' }}>
|
|
140
|
-
<Details>
|
|
141
|
-
<OText size={12} lineHeight={18} numberOfLines={1} ellipsizeMode='tail'>{product.name}</OText>
|
|
142
|
-
<OText size={12} lineHeight={18} color={theme.colors.textNormal}>{parsePrice(product.price)}</OText>
|
|
143
|
-
</Details>
|
|
144
|
-
<AddButton onPress={() => handleFormProduct(product)}>
|
|
145
|
-
<OText size={10} color={theme.colors.primary}>{t('ADD', 'Add')}</OText>
|
|
146
|
-
</AddButton>
|
|
147
|
-
</View>
|
|
148
|
-
<View>
|
|
149
|
-
<OIcon url={product?.images || theme?.images?.dummies?.product} style={styles.imageStyle} />
|
|
150
|
-
</View>
|
|
151
|
-
</Item>
|
|
152
|
-
)) : (
|
|
153
|
-
<OText>
|
|
154
|
-
{upsellingProducts.message}
|
|
155
|
-
</OText>
|
|
156
|
-
)
|
|
157
|
-
}
|
|
158
|
-
</>
|
|
159
|
-
)
|
|
160
|
-
}
|
|
161
|
-
</UpsellingContainer>
|
|
162
|
-
</Container>
|
|
163
|
-
)
|
|
164
|
-
}
|
|
126
|
+
const handleFormProduct = (product: any) => {
|
|
127
|
+
onNavigationRedirect && onNavigationRedirect('ProductDetails', {
|
|
128
|
+
product: product,
|
|
129
|
+
businessId: product?.api?.businessId,
|
|
130
|
+
businessSlug: business.slug,
|
|
131
|
+
})
|
|
132
|
+
}
|
|
165
133
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
style={{ ...styles.closeUpsellingButton }}
|
|
207
|
-
textStyle={{ color: theme.colors.white, fontSize: 14 }}
|
|
208
|
-
onClick={() => {
|
|
209
|
-
handleUpsellingPage()
|
|
210
|
-
setIsCheckout(true)
|
|
211
|
-
}}
|
|
212
|
-
/>
|
|
213
|
-
</View>
|
|
214
|
-
</>
|
|
215
|
-
)
|
|
216
|
-
}
|
|
134
|
+
const UpsellingLayout = () => {
|
|
135
|
+
return (
|
|
136
|
+
<Container>
|
|
137
|
+
<UpsellingContainer
|
|
138
|
+
horizontal
|
|
139
|
+
showsHorizontalScrollIndicator={false}
|
|
140
|
+
contentContainerStyle={{ paddingHorizontal: Platform.OS === 'ios' ? 40 : 0 }}
|
|
141
|
+
>
|
|
142
|
+
{
|
|
143
|
+
!upsellingProducts.loading && (
|
|
144
|
+
<>
|
|
145
|
+
{
|
|
146
|
+
!upsellingProducts.error ? productsList.map((product: any, i: number) => (
|
|
147
|
+
<Item key={`${product.id}_${i}`}>
|
|
148
|
+
<View style={{ flexBasis: '57%' }}>
|
|
149
|
+
<Details>
|
|
150
|
+
<OText size={12} lineHeight={18} numberOfLines={1} ellipsizeMode='tail'>{product.name}</OText>
|
|
151
|
+
<OText size={12} lineHeight={18} color={theme.colors.textNormal}>{parsePrice(product.price)}</OText>
|
|
152
|
+
</Details>
|
|
153
|
+
<AddButton onPress={() => handleFormProduct(product)}>
|
|
154
|
+
<OText size={10} color={theme.colors.primary}>{t('ADD', 'Add')}</OText>
|
|
155
|
+
</AddButton>
|
|
156
|
+
</View>
|
|
157
|
+
<View>
|
|
158
|
+
<OIcon url={product?.images || theme?.images?.dummies?.product} style={styles.imageStyle} />
|
|
159
|
+
</View>
|
|
160
|
+
</Item>
|
|
161
|
+
)) : (
|
|
162
|
+
<OText>
|
|
163
|
+
{upsellingProducts.message}
|
|
164
|
+
</OText>
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
</>
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
</UpsellingContainer>
|
|
171
|
+
</Container>
|
|
172
|
+
)
|
|
173
|
+
}
|
|
217
174
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
175
|
+
const UpsellingContent = () => {
|
|
176
|
+
return (
|
|
177
|
+
<>
|
|
178
|
+
<View style={{ ...styles.headerItem, flex: 1, marginTop: Platform.OS == 'ios' ? 35 : 14 }}>
|
|
179
|
+
<TouchableOpacity onPress={() => onGoBack()} style={styles.btnBackArrow}>
|
|
180
|
+
<OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
|
|
181
|
+
</TouchableOpacity>
|
|
182
|
+
</View>
|
|
183
|
+
<ScrollView style={{ marginTop: 10, marginBottom: props.isPage ? 40 : bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
|
|
184
|
+
{productsList.length > 0 &&
|
|
185
|
+
<View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
|
|
186
|
+
<OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
|
|
187
|
+
<UpsellingLayout />
|
|
188
|
+
</View>
|
|
189
|
+
}
|
|
190
|
+
<View style={{ paddingHorizontal: 40 }}>
|
|
191
|
+
<OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
|
|
192
|
+
<OrderSummary
|
|
193
|
+
cart={cart}
|
|
194
|
+
commentDelayTime={commentDelayTime}
|
|
195
|
+
isCartPending={cart?.status === 2}
|
|
196
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
197
|
+
/>
|
|
198
|
+
</View>
|
|
199
|
+
{showCartList && cartList.map((cart: any, i: number) => (
|
|
200
|
+
<CartList key={i}>
|
|
201
|
+
<Cart
|
|
202
|
+
cart={cart}
|
|
203
|
+
cartuuid={cart.uuid}
|
|
204
|
+
hideUpselling
|
|
205
|
+
singleBusiness={props.singleBusiness}
|
|
206
|
+
isFranchiseApp={props.isFranchiseApp}
|
|
207
|
+
isCartsLoading={isCartsLoading}
|
|
208
|
+
setIsCartsLoading={setIsCartsLoading}
|
|
209
|
+
isMultiCheckout={isMultiCheckout}
|
|
210
|
+
onNavigationRedirect={props.onNavigationRedirect}
|
|
211
|
+
/>
|
|
212
|
+
<CartDivider />
|
|
213
|
+
</CartList>
|
|
214
|
+
))}
|
|
215
|
+
</ScrollView>
|
|
216
|
+
<View
|
|
217
|
+
style={{
|
|
218
|
+
alignItems: 'center',
|
|
219
|
+
bottom: props.isPage ? Platform.OS === 'ios' ? 0 : 20 : Platform.OS === 'ios' ? bottom + 59 : bottom + 125
|
|
220
|
+
}}
|
|
221
|
+
>
|
|
222
|
+
<OButton
|
|
223
|
+
imgRightSrc=''
|
|
224
|
+
text={t('CHECKOUT', 'Checkout')}
|
|
225
|
+
style={{ ...styles.closeUpsellingButton }}
|
|
226
|
+
textStyle={{ color: theme.colors.white, fontSize: 14 }}
|
|
227
|
+
onClick={() => {
|
|
228
|
+
handleUpsellingPage()
|
|
229
|
+
setIsCheckout(true)
|
|
230
|
+
}}
|
|
231
|
+
/>
|
|
232
|
+
</View>
|
|
233
|
+
</>
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return (
|
|
238
|
+
<>
|
|
239
|
+
{isCustomMode ? (
|
|
240
|
+
<UpsellingLayout />
|
|
241
|
+
) : (
|
|
242
|
+
<>
|
|
243
|
+
{props.isPage ? (
|
|
244
|
+
<UpsellingContent />
|
|
245
|
+
) : (
|
|
246
|
+
canOpenUpselling && !modalIsOpen && (
|
|
247
|
+
<OBottomPopup
|
|
248
|
+
title={''}
|
|
249
|
+
open={openUpselling}
|
|
250
|
+
onClose={() => handleUpsellingPage()}
|
|
251
|
+
isStatusBar
|
|
252
|
+
>
|
|
253
|
+
<UpsellingContent />
|
|
254
|
+
</OBottomPopup>
|
|
255
|
+
)
|
|
256
|
+
)}
|
|
257
|
+
</>
|
|
258
|
+
)}
|
|
259
|
+
</>
|
|
260
|
+
)
|
|
242
261
|
}
|
|
243
262
|
|
|
244
263
|
export const UpsellingProducts = (props: UpsellingProductsParams) => {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
264
|
+
const upsellingProductsProps = {
|
|
265
|
+
...props,
|
|
266
|
+
UIComponent: UpsellingProductsUI
|
|
267
|
+
}
|
|
268
|
+
return (
|
|
269
|
+
<UpsellingPageController {...upsellingProductsProps} />
|
|
270
|
+
)
|
|
252
271
|
}
|
|
@@ -47,4 +47,15 @@ export const TopBar = styled.View`
|
|
|
47
47
|
export const TopActions = styled.TouchableOpacity`
|
|
48
48
|
height: 44px;
|
|
49
49
|
justify-content: center;
|
|
50
|
-
`;
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
export const CartList = styled.ScrollView`
|
|
53
|
+
padding: 10px 40px;
|
|
54
|
+
overflow: visible;
|
|
55
|
+
`
|
|
56
|
+
|
|
57
|
+
export const CartDivider = styled.View`
|
|
58
|
+
height: 8px;
|
|
59
|
+
background-color: ${(props: any) => props.theme.colors.backgroundGray100};
|
|
60
|
+
margin: 20px -40px 0;
|
|
61
|
+
`
|