ordering-ui-react-native 0.14.38 → 0.14.40-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 +2 -2
- package/src/components/BusinessItemAccordion/index.tsx +2 -2
- package/src/components/BusinessProductsListing/index.tsx +10 -26
- package/src/components/Cart/index.tsx +136 -62
- package/src/components/Cart/styles.tsx +7 -0
- package/src/components/Checkout/index.tsx +32 -168
- package/src/components/OrderDetails/index.tsx +102 -34
- package/src/components/OrderDetails/styles.tsx +7 -0
- package/src/components/OrderSummary/index.tsx +142 -58
- package/src/components/OrderSummary/styles.tsx +10 -2
- package/src/components/PaymentOptions/index.tsx +3 -1
- package/src/components/PaymentOptionsWebView/index.tsx +150 -0
- package/src/components/ProductForm/index.tsx +7 -9
- package/src/components/SingleProductCard/index.tsx +1 -1
- package/src/components/StripeElementsForm/index.tsx +28 -13
- package/src/components/TaxInformation/index.tsx +58 -26
- package/src/components/UpsellingProducts/index.tsx +13 -31
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OIcon.tsx +4 -1
- package/src/index.tsx +2 -0
- package/src/navigators/HomeNavigator.tsx +6 -0
- package/src/pages/ProductDetails.tsx +55 -0
- package/src/types/index.tsx +2 -0
- package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
- package/themes/kiosk/src/components/Cart/index.tsx +14 -21
- package/themes/kiosk/src/components/CartItem/index.tsx +9 -7
- package/themes/kiosk/src/components/CustomerName/index.tsx +2 -1
- package/themes/kiosk/src/components/Intro/index.tsx +4 -4
- package/themes/kiosk/src/components/OptionCard/index.tsx +11 -6
- package/themes/kiosk/src/components/PaymentOptions/index.tsx +46 -44
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -9
- package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -2
- package/themes/original/src/components/BusinessProductsListing/index.tsx +8 -4
- package/themes/original/src/components/BusinessesListing/index.tsx +100 -75
- package/themes/original/src/components/Cart/index.tsx +122 -24
- package/themes/original/src/components/Cart/styles.tsx +8 -1
- package/themes/original/src/components/Checkout/index.tsx +38 -3
- package/themes/original/src/components/Help/index.tsx +1 -1
- package/themes/original/src/components/Home/index.tsx +5 -3
- package/themes/original/src/components/MessageListing/index.tsx +4 -2
- package/themes/original/src/components/OrderDetails/index.tsx +114 -42
- package/themes/original/src/components/OrderDetails/styles.tsx +8 -1
- package/themes/original/src/components/OrderProgress/index.tsx +2 -1
- package/themes/original/src/components/OrderSummary/index.tsx +132 -23
- package/themes/original/src/components/OrderSummary/styles.tsx +7 -0
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
- package/themes/original/src/components/PaymentOptions/index.tsx +8 -2
- package/themes/original/src/components/ProductForm/index.tsx +63 -65
- package/themes/original/src/components/ProductForm/styles.tsx +6 -0
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +3 -2
- package/themes/original/src/components/SingleProductCard/index.tsx +21 -11
- package/themes/original/src/components/SingleProductCard/styles.tsx +4 -0
- package/themes/original/src/components/StripeElementsForm/index.tsx +28 -13
- package/themes/original/src/components/TaxInformation/index.tsx +59 -27
- package/themes/original/src/components/UpsellingProducts/index.tsx +26 -18
- package/themes/original/src/types/index.tsx +2 -0
|
@@ -32,7 +32,8 @@ import {
|
|
|
32
32
|
ProductActions,
|
|
33
33
|
ExtraOptionWrap,
|
|
34
34
|
WeightUnitSwitch,
|
|
35
|
-
WeightUnitItem
|
|
35
|
+
WeightUnitItem,
|
|
36
|
+
TopActions
|
|
36
37
|
} from './styles';
|
|
37
38
|
import { OButton, OIcon, OInput, OText } from '../shared';
|
|
38
39
|
import { ScrollView } from 'react-native-gesture-handler';
|
|
@@ -211,7 +212,9 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
211
212
|
}
|
|
212
213
|
|
|
213
214
|
const handleRedirectLogin = () => {
|
|
214
|
-
navigation.navigate('Login'
|
|
215
|
+
navigation.navigate('Login', {
|
|
216
|
+
store_slug: props.businessSlug
|
|
217
|
+
});
|
|
215
218
|
};
|
|
216
219
|
|
|
217
220
|
const handleSwitchQtyUnit = (val: string) => {
|
|
@@ -288,20 +291,16 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
288
291
|
</>
|
|
289
292
|
);
|
|
290
293
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
+
const handleGoBack = navigation?.canGoBack()
|
|
295
|
+
? () => navigation.goBack()
|
|
296
|
+
: () => navigation.navigate('Business', { store: props.businessSlug })
|
|
294
297
|
|
|
295
298
|
return (
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
style={styles.btnBackArrow}
|
|
302
|
-
onClick={() => handleGoBack()}
|
|
303
|
-
imgLeftStyle={{ tintColor: theme.colors.textNormal, width: 16 }}
|
|
304
|
-
/>
|
|
299
|
+
<SafeAreaView style={{ flex: 1 }}>
|
|
300
|
+
<TopHeader>
|
|
301
|
+
<TopActions onPress={() => handleGoBack()}>
|
|
302
|
+
<OIcon src={theme.images.general.arrow_left} width={15} />
|
|
303
|
+
</TopActions>
|
|
305
304
|
</TopHeader>
|
|
306
305
|
<ScrollView>
|
|
307
306
|
{!error && (
|
|
@@ -352,15 +351,13 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
352
351
|
style={styles.slide1}
|
|
353
352
|
key={i}
|
|
354
353
|
>
|
|
355
|
-
<
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
/>
|
|
363
|
-
</Grayscale>
|
|
354
|
+
<FastImage
|
|
355
|
+
style={{ height: '100%', opacity: isSoldOut ? 0.5 : 1 }}
|
|
356
|
+
source={{
|
|
357
|
+
uri: optimizeImage(img, 'h_258,c_limit'),
|
|
358
|
+
priority: FastImage.priority.normal,
|
|
359
|
+
}}
|
|
360
|
+
/>
|
|
364
361
|
</View>
|
|
365
362
|
))}
|
|
366
363
|
</Swiper>
|
|
@@ -384,19 +381,18 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
384
381
|
opacity: index === thumbsSwiper ? 1 : 0.8
|
|
385
382
|
}}
|
|
386
383
|
>
|
|
387
|
-
<
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
</Grayscale>
|
|
384
|
+
<OIcon
|
|
385
|
+
url={img}
|
|
386
|
+
style={{
|
|
387
|
+
borderColor: theme.colors.lightGray,
|
|
388
|
+
borderRadius: 8,
|
|
389
|
+
minHeight: '100%',
|
|
390
|
+
opacity: isSoldOut ? 0.5 : 1
|
|
391
|
+
}}
|
|
392
|
+
width={56}
|
|
393
|
+
height={56}
|
|
394
|
+
cover
|
|
395
|
+
/>
|
|
400
396
|
</View>
|
|
401
397
|
</TouchableOpacity>
|
|
402
398
|
|
|
@@ -428,12 +424,12 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
428
424
|
style={{ flex: 1, marginBottom: 10 }}>
|
|
429
425
|
{product?.name || productCart.name}
|
|
430
426
|
</OText>
|
|
431
|
-
{product?.calories && (
|
|
427
|
+
{!!product?.calories && (
|
|
432
428
|
<OText size={16} style={{ color: '#808080' }}>{product?.calories} cal
|
|
433
429
|
</OText>
|
|
434
430
|
)}
|
|
435
431
|
</View>
|
|
436
|
-
{((product?.sku && product?.sku !== '-1' && product?.sku !== '1') || (product?.estimated_person)) && (
|
|
432
|
+
{((!!product?.sku && product?.sku !== '-1' && product?.sku !== '1') || (!!product?.estimated_person)) && (
|
|
437
433
|
<OText size={14} style={{ flex: I18nManager.isRTL ? 1 : 0 }} color={'#909BA9'} mBottom={7}>
|
|
438
434
|
{
|
|
439
435
|
((product?.sku && product?.sku !== '-1' && product?.sku !== '1') || (productCart?.sku && productCart?.sku !== '-1' && productCart?.sku !== '1'))
|
|
@@ -452,14 +448,14 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
452
448
|
) : (
|
|
453
449
|
<View style={{ flexDirection: 'row', marginBottom: 10 }}>
|
|
454
450
|
<OText size={16} style={{ flex: I18nManager.isRTL ? 1 : 0 }} color={theme.colors.primary}>{productCart.price ? parsePrice(productCart.price) : ''}</OText>
|
|
455
|
-
{product?.offer_price && (
|
|
451
|
+
{product?.offer_price !== null && product?.in_offer && (
|
|
456
452
|
<OText style={{
|
|
457
453
|
fontSize: 14,
|
|
458
454
|
color: '#808080',
|
|
459
455
|
textDecorationLine: 'line-through',
|
|
460
456
|
marginLeft: 7,
|
|
461
457
|
marginRight: 7
|
|
462
|
-
}}>{parsePrice(product?.offer_price)}</OText>
|
|
458
|
+
}}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
|
|
463
459
|
)}
|
|
464
460
|
</View>
|
|
465
461
|
)}
|
|
@@ -481,7 +477,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
481
477
|
key={tag.id}
|
|
482
478
|
style={styles.productTagWrapper}
|
|
483
479
|
>
|
|
484
|
-
{tag?.image ? (
|
|
480
|
+
{!!tag?.image ? (
|
|
485
481
|
<OIcon
|
|
486
482
|
url={optimizeImage(tag?.image, 'h_40,c_limit')}
|
|
487
483
|
style={styles.productTagImageStyle}
|
|
@@ -764,7 +760,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
764
760
|
</WrapContent>
|
|
765
761
|
</View>
|
|
766
762
|
)}
|
|
767
|
-
{error && error.length > 0 && (
|
|
763
|
+
{!!error && error.length > 0 && (
|
|
768
764
|
<NotFoundSource content={error[0]?.message || error[0]} />
|
|
769
765
|
)}
|
|
770
766
|
</ScrollView>
|
|
@@ -791,7 +787,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
791
787
|
<OText
|
|
792
788
|
size={12}
|
|
793
789
|
lineHeight={18}
|
|
794
|
-
style={{ minWidth:
|
|
790
|
+
style={{ minWidth: 40, textAlign: 'center' }}
|
|
795
791
|
>
|
|
796
792
|
{qtyBy?.pieces && productCart.quantity}
|
|
797
793
|
{qtyBy?.weight_unit && productCart.quantity * product?.weight}
|
|
@@ -815,36 +811,38 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
815
811
|
}
|
|
816
812
|
/>
|
|
817
813
|
</TouchableOpacity>
|
|
818
|
-
|
|
819
|
-
<
|
|
820
|
-
onPress={() => handleSwitchQtyUnit('pieces')}
|
|
821
|
-
>
|
|
822
|
-
<WeightUnitItem active={qtyBy?.pieces}>
|
|
823
|
-
<OText
|
|
824
|
-
size={12}
|
|
825
|
-
lineHeight={18}
|
|
826
|
-
color={qtyBy?.pieces ? theme.colors.primary : theme.colors.textNormal}
|
|
827
|
-
>
|
|
828
|
-
{t('PIECES', 'pieces')}
|
|
829
|
-
</OText>
|
|
830
|
-
</WeightUnitItem>
|
|
831
|
-
</TouchableOpacity>
|
|
832
|
-
<View style={{ alignItems: 'flex-start' }}>
|
|
814
|
+
{isHaveWeight && (
|
|
815
|
+
<WeightUnitSwitch>
|
|
833
816
|
<TouchableOpacity
|
|
834
|
-
onPress={() => handleSwitchQtyUnit('
|
|
817
|
+
onPress={() => handleSwitchQtyUnit('pieces')}
|
|
835
818
|
>
|
|
836
|
-
<WeightUnitItem active={qtyBy?.
|
|
819
|
+
<WeightUnitItem active={qtyBy?.pieces}>
|
|
837
820
|
<OText
|
|
838
821
|
size={12}
|
|
839
822
|
lineHeight={18}
|
|
840
|
-
color={qtyBy?.
|
|
823
|
+
color={qtyBy?.pieces ? theme.colors.primary : theme.colors.textNormal}
|
|
841
824
|
>
|
|
842
|
-
{
|
|
825
|
+
{t('PIECES', 'pcs')}
|
|
843
826
|
</OText>
|
|
844
827
|
</WeightUnitItem>
|
|
845
828
|
</TouchableOpacity>
|
|
846
|
-
|
|
847
|
-
|
|
829
|
+
<View style={{ alignItems: 'flex-start' }}>
|
|
830
|
+
<TouchableOpacity
|
|
831
|
+
onPress={() => handleSwitchQtyUnit('weight_unit')}
|
|
832
|
+
>
|
|
833
|
+
<WeightUnitItem active={qtyBy?.weight_unit}>
|
|
834
|
+
<OText
|
|
835
|
+
size={12}
|
|
836
|
+
lineHeight={18}
|
|
837
|
+
color={qtyBy?.weight_unit ? theme.colors.primary : theme.colors.textNormal}
|
|
838
|
+
>
|
|
839
|
+
{product?.weight_unit}
|
|
840
|
+
</OText>
|
|
841
|
+
</WeightUnitItem>
|
|
842
|
+
</TouchableOpacity>
|
|
843
|
+
</View>
|
|
844
|
+
</WeightUnitSwitch>
|
|
845
|
+
)}
|
|
848
846
|
</View>
|
|
849
847
|
)}
|
|
850
848
|
<View
|
|
@@ -913,7 +911,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
913
911
|
</View>
|
|
914
912
|
</ProductActions>
|
|
915
913
|
)}
|
|
916
|
-
|
|
914
|
+
</SafeAreaView>
|
|
917
915
|
);
|
|
918
916
|
};
|
|
919
917
|
|
|
@@ -5,6 +5,12 @@ export const WrapHeader = styled.View`
|
|
|
5
5
|
z-index: 1;
|
|
6
6
|
`
|
|
7
7
|
|
|
8
|
+
export const TopActions = styled.TouchableOpacity`
|
|
9
|
+
height: 44px;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
padding-horizontal: 30px;
|
|
12
|
+
`;
|
|
13
|
+
|
|
8
14
|
export const TopHeader = styled.View`
|
|
9
15
|
width: 100%;
|
|
10
16
|
flex-direction: row;
|
|
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'
|
|
|
2
2
|
import {
|
|
3
3
|
useUtils,
|
|
4
4
|
useLanguage,
|
|
5
|
-
ProductOptionSuboption as ProductSubOptionController
|
|
5
|
+
ProductOptionSuboption as ProductSubOptionController
|
|
6
6
|
} from 'ordering-components/native'
|
|
7
7
|
import { useTheme } from 'styled-components/native';
|
|
8
8
|
import { StyleSheet } from 'react-native'
|
|
@@ -137,7 +137,8 @@ const styles = StyleSheet.create({
|
|
|
137
137
|
export const ProductOptionSubOption = (props: any) => {
|
|
138
138
|
const productOptionSubOptionProps = {
|
|
139
139
|
...props,
|
|
140
|
-
UIComponent: ProductOptionSubOptionUI
|
|
140
|
+
UIComponent: ProductOptionSubOptionUI,
|
|
141
|
+
isOrigin: true
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
return (
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from 'ordering-components/native';
|
|
8
8
|
import { useTheme } from 'styled-components/native';
|
|
9
9
|
import { SingleProductCardParams } from '../../types';
|
|
10
|
-
import { CardContainer, CardInfo, SoldOut, QuantityContainer } from './styles';
|
|
10
|
+
import { CardContainer, CardInfo, SoldOut, QuantityContainer, PricesContainer } from './styles';
|
|
11
11
|
import { StyleSheet } from 'react-native';
|
|
12
12
|
import { OText, OIcon } from '../shared';
|
|
13
13
|
import FastImage from 'react-native-fast-image'
|
|
@@ -51,6 +51,13 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
|
|
|
51
51
|
textAlign: 'center',
|
|
52
52
|
borderRadius: 25,
|
|
53
53
|
alignItems: 'center'
|
|
54
|
+
},
|
|
55
|
+
regularPriceStyle: {
|
|
56
|
+
fontSize: 12,
|
|
57
|
+
color: '#808080',
|
|
58
|
+
textDecorationLine: 'line-through',
|
|
59
|
+
marginLeft: 7,
|
|
60
|
+
marginRight: 7
|
|
54
61
|
}
|
|
55
62
|
});
|
|
56
63
|
|
|
@@ -97,13 +104,13 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
|
|
|
97
104
|
(isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle,
|
|
98
105
|
]}
|
|
99
106
|
onPress={() => onProductClick?.(product)}>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
{productAddedToCartLength > 0 && (
|
|
108
|
+
<QuantityContainer style={[styles.quantityContainer, {
|
|
109
|
+
transform: [{ translateX: 10 }, { translateY: -10 }],
|
|
110
|
+
}]}>
|
|
111
|
+
<OText size={12} color={theme.colors.white}>{productAddedToCartLength.toString()}</OText>
|
|
112
|
+
</QuantityContainer>
|
|
113
|
+
)}
|
|
107
114
|
<CardInfo>
|
|
108
115
|
<OText
|
|
109
116
|
size={12}
|
|
@@ -113,9 +120,12 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
|
|
|
113
120
|
style={styles.line18}>
|
|
114
121
|
{product?.name}
|
|
115
122
|
</OText>
|
|
116
|
-
<
|
|
117
|
-
{parsePrice(product?.price)}
|
|
118
|
-
|
|
123
|
+
<PricesContainer>
|
|
124
|
+
<OText color={theme.colors.primary}>{product?.price ? parsePrice(product?.price) : ''}</OText>
|
|
125
|
+
{product?.offer_price !== null && product?.in_offer && (
|
|
126
|
+
<OText style={styles.regularPriceStyle}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
|
|
127
|
+
)}
|
|
128
|
+
</PricesContainer>
|
|
119
129
|
<OText
|
|
120
130
|
size={10}
|
|
121
131
|
numberOfLines={2}
|
|
@@ -37,19 +37,33 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
37
37
|
const { top, bottom } = useSafeAreaInsets();
|
|
38
38
|
const [isKeyboardShow, setIsKeyboardShow] = useState(false);
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
let billingDetails: any = {}
|
|
41
|
+
|
|
42
|
+
if (user?.name || user?.lastname) {
|
|
43
|
+
if (user?.name) {
|
|
44
|
+
billingDetails.name = user?.name
|
|
45
|
+
}
|
|
46
|
+
if (user?.lastname) {
|
|
47
|
+
billingDetails.name = `${billingDetails?.name} ${user?.lastname}`
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (user?.email) {
|
|
52
|
+
billingDetails.email = user?.email
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (user?.address) {
|
|
56
|
+
billingDetails.addressLine1 = user?.address
|
|
57
|
+
}
|
|
45
58
|
|
|
46
59
|
const createPayMethod = async () => {
|
|
60
|
+
const params: any = { type: 'Card' }
|
|
61
|
+
if (Object.keys(billingDetails).length > 0) {
|
|
62
|
+
params.billingDetails = billingDetails
|
|
63
|
+
}
|
|
47
64
|
try {
|
|
48
65
|
setCreatePmLoading(true)
|
|
49
|
-
const { paymentMethod } = await createPaymentMethod(
|
|
50
|
-
type: 'Card',
|
|
51
|
-
billingDetails,
|
|
52
|
-
});
|
|
66
|
+
const { paymentMethod } = await createPaymentMethod(params);
|
|
53
67
|
|
|
54
68
|
setCreatePmLoading(false)
|
|
55
69
|
handleSource && handleSource({
|
|
@@ -79,11 +93,12 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
79
93
|
createPayMethod();
|
|
80
94
|
return
|
|
81
95
|
}
|
|
96
|
+
const params: any = { type: 'Card' }
|
|
97
|
+
if (Object.keys(billingDetails).length > 0) {
|
|
98
|
+
params.billingDetails = billingDetails
|
|
99
|
+
}
|
|
82
100
|
try {
|
|
83
|
-
const { setupIntent, error } = await confirmSetupIntent(requirements,
|
|
84
|
-
type: 'Card',
|
|
85
|
-
billingDetails,
|
|
86
|
-
});
|
|
101
|
+
const { setupIntent, error } = await confirmSetupIntent(requirements, params);
|
|
87
102
|
|
|
88
103
|
if (setupIntent?.status === 'Succeeded') {
|
|
89
104
|
stripeTokenHandler(setupIntent?.paymentMethodId, user, businessId);
|
|
@@ -1,51 +1,83 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { useLanguage
|
|
1
|
+
import React, { Mixin } from 'react'
|
|
2
|
+
import { useLanguage } from 'ordering-components/native'
|
|
3
3
|
import { SingleProductCard } from '../SingleProductCard'
|
|
4
4
|
import { TaxInformationContainer, ProductContainer } from './styles'
|
|
5
5
|
import { OText } from '../shared'
|
|
6
6
|
|
|
7
7
|
interface taxInformationParams {
|
|
8
|
-
data: {
|
|
9
|
-
|
|
8
|
+
data: {
|
|
9
|
+
name: string,
|
|
10
|
+
description?: string,
|
|
11
|
+
rate: string | number,
|
|
12
|
+
type: number,
|
|
13
|
+
fixed?: number,
|
|
14
|
+
percentage?: number,
|
|
15
|
+
id: number,
|
|
16
|
+
discounts?: any
|
|
17
|
+
} | null,
|
|
18
|
+
products: Array<any>,
|
|
19
|
+
type: string
|
|
10
20
|
}
|
|
11
21
|
|
|
12
22
|
export const TaxInformation = (props: taxInformationParams) => {
|
|
13
23
|
const {
|
|
14
24
|
data,
|
|
15
|
-
products
|
|
25
|
+
products,
|
|
26
|
+
type
|
|
16
27
|
} = props
|
|
17
28
|
|
|
18
29
|
const [, t] = useLanguage()
|
|
19
|
-
const [{ parsePrice }] = useUtils()
|
|
20
30
|
|
|
21
|
-
const isTax = typeof data?.rate === 'number'
|
|
22
|
-
const TaxFeeString = isTax ? 'tax' : 'fee'
|
|
23
31
|
const includedOnPriceString = data?.type === 1 ? `(${t('INCLUDED_ON_PRICE', 'Included on price')})` : `(${t('NOT_INCLUDED_ON_PRICE', 'Not included on price')})`
|
|
24
32
|
|
|
33
|
+
const getFilterValidation = (product: any) => {
|
|
34
|
+
return (
|
|
35
|
+
type === 'tax'
|
|
36
|
+
? (product.tax?.id ? product.tax?.id === data?.id : product.tax?.id === null && data?.id === null)
|
|
37
|
+
: type === 'fee'
|
|
38
|
+
? (product.fee?.id ? product.fee?.id === data?.id : (product.fee?.id === null && data?.id === null))
|
|
39
|
+
: Object.keys(data?.discounts ?? {}).map(code => code.includes(product?.code)) && product?.offers?.find((offer : any) => offer?.name === data?.name)
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const getTypeString = () => {
|
|
44
|
+
return (
|
|
45
|
+
type === 'offer_target_1'
|
|
46
|
+
? t('PRODUCT_DISCOUNT', 'Product discount')
|
|
47
|
+
: type === 'tax'
|
|
48
|
+
? t('TAX', 'Tax')
|
|
49
|
+
: t('Fee', 'Fee')
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
25
53
|
return (
|
|
26
54
|
<TaxInformationContainer>
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
t('
|
|
30
|
-
|
|
31
|
-
|
|
55
|
+
{!!data?.description ? (
|
|
56
|
+
<OText size={24} style={{ alignSelf: 'center', textAlign: 'center' }} mBottom={10}>
|
|
57
|
+
{t('DESCRIPTION', 'Description')}: {data?.description} {data?.type && !type?.includes('offer') && includedOnPriceString}
|
|
58
|
+
</OText>
|
|
59
|
+
) : (
|
|
32
60
|
<OText mBottom={10} size={18} style={{ alignSelf: 'center', textAlign: 'center' }}>
|
|
33
|
-
{t('
|
|
61
|
+
{t('WITHOUT_DESCRIPTION', 'Without description')}
|
|
34
62
|
</OText>
|
|
35
63
|
)}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
64
|
+
{!(type === 'offer_target_2' || type === 'offer_target_3') && (
|
|
65
|
+
<>
|
|
66
|
+
<OText>{t('OTHER_PRODUCTS_WITH_THIS', 'Other products with this')} {getTypeString()}:</OText>
|
|
67
|
+
<ProductContainer>
|
|
68
|
+
{
|
|
69
|
+
products.filter((product: any) => getFilterValidation(product)).map(product => (
|
|
70
|
+
<SingleProductCard
|
|
71
|
+
key={product.id}
|
|
72
|
+
product={product}
|
|
73
|
+
isSoldOut={false}
|
|
74
|
+
businessId={product?.business_id}
|
|
75
|
+
/>
|
|
76
|
+
))
|
|
77
|
+
}
|
|
78
|
+
</ProductContainer>
|
|
79
|
+
</>
|
|
80
|
+
)}
|
|
49
81
|
</TaxInformationContainer>
|
|
50
82
|
)
|
|
51
83
|
}
|
|
@@ -33,8 +33,8 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
33
33
|
canOpenUpselling,
|
|
34
34
|
setCanOpenUpselling,
|
|
35
35
|
isFromCart,
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
onNavigationRedirect,
|
|
37
|
+
onGoBack
|
|
38
38
|
} = props
|
|
39
39
|
|
|
40
40
|
const theme = useTheme();
|
|
@@ -70,17 +70,18 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
70
70
|
const [{ parsePrice }] = useUtils()
|
|
71
71
|
const [, t] = useLanguage()
|
|
72
72
|
const { bottom } = useSafeAreaInsets()
|
|
73
|
+
const [isCheckout, setIsCheckout] = useState(false)
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
const cart = carts?.[`businessId:${props.businessId}`] ?? {}
|
|
76
|
+
const cartProducts = cart?.products?.length
|
|
77
|
+
? cart?.products.map((product: any) => product.id)
|
|
78
|
+
: []
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
const productsList = !upsellingProducts.loading && !upsellingProducts.error
|
|
81
|
+
? upsellingProducts?.products?.length
|
|
82
|
+
? upsellingProducts?.products.filter((product: any) => !cartProducts.includes(product.id))
|
|
83
|
+
: (props?.products ?? []).filter((product: any) => !cartProducts.includes(product.id)) ?? []
|
|
84
|
+
: []
|
|
84
85
|
|
|
85
86
|
useEffect(() => {
|
|
86
87
|
if (!isCustomMode && !props.products) {
|
|
@@ -94,6 +95,10 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
94
95
|
}
|
|
95
96
|
}, [upsellingProducts.loading, upsellingProducts?.products.length])
|
|
96
97
|
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
isCheckout && Object.keys(cart).length === 0 && onNavigationRedirect && onNavigationRedirect('MyOrders')
|
|
100
|
+
}, [cart, isCheckout])
|
|
101
|
+
|
|
97
102
|
const handleFormProduct = (product: any) => {
|
|
98
103
|
onNavigationRedirect && onNavigationRedirect('ProductDetails', {
|
|
99
104
|
product: product,
|
|
@@ -155,12 +160,6 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
155
160
|
</TopActions>
|
|
156
161
|
</TopBar>
|
|
157
162
|
<ScrollView style={{ marginBottom: props.isPage ? 40 : bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
|
|
158
|
-
{productsList.length > 0 &&
|
|
159
|
-
<View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
|
|
160
|
-
<OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
|
|
161
|
-
<UpsellingLayout />
|
|
162
|
-
</View>
|
|
163
|
-
}
|
|
164
163
|
<View style={{ paddingHorizontal: 40 }}>
|
|
165
164
|
<OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
|
|
166
165
|
<OrderSummary
|
|
@@ -169,6 +168,12 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
169
168
|
onNavigationRedirect={onNavigationRedirect}
|
|
170
169
|
/>
|
|
171
170
|
</View>
|
|
171
|
+
{productsList.length > 0 &&
|
|
172
|
+
<View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
|
|
173
|
+
<OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
|
|
174
|
+
<UpsellingLayout />
|
|
175
|
+
</View>
|
|
176
|
+
}
|
|
172
177
|
</ScrollView>
|
|
173
178
|
<View
|
|
174
179
|
style={{
|
|
@@ -181,7 +186,10 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
181
186
|
text={t('CHECKOUT', 'Checkout')}
|
|
182
187
|
style={{...styles.closeUpsellingButton}}
|
|
183
188
|
textStyle={{ color: theme.colors.white, fontSize: 14 }}
|
|
184
|
-
onClick={() =>
|
|
189
|
+
onClick={() => {
|
|
190
|
+
handleUpsellingPage()
|
|
191
|
+
setIsCheckout(true)
|
|
192
|
+
}}
|
|
185
193
|
/>
|
|
186
194
|
</View>
|
|
187
195
|
</>
|
|
@@ -253,6 +253,7 @@ export interface NotFoundSourceParams {
|
|
|
253
253
|
}
|
|
254
254
|
export interface OrdersOptionParams {
|
|
255
255
|
orderList?: any,
|
|
256
|
+
franchiseId?: any,
|
|
256
257
|
activeOrders?: boolean,
|
|
257
258
|
pagination?: any,
|
|
258
259
|
titleContent?: string,
|
|
@@ -482,4 +483,5 @@ export interface HelpAccountAndPaymentParams {
|
|
|
482
483
|
|
|
483
484
|
export interface MessageListingParams {
|
|
484
485
|
navigation: any;
|
|
486
|
+
franchiseId?: any;
|
|
485
487
|
}
|