ordering-ui-react-native 0.12.44 → 0.12.48
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/src/components/Cart/index.tsx +56 -23
- package/src/components/OrderDetails/index.tsx +90 -35
- package/src/components/OrderSummary/index.tsx +59 -27
- package/src/components/OrderSummary/styles.tsx +6 -0
- package/src/components/ProductForm/index.tsx +1 -1
- package/src/components/SingleProductCard/index.tsx +1 -1
- package/src/components/TaxInformation/index.tsx +51 -0
- package/src/components/TaxInformation/styles.tsx +9 -0
- package/src/types/index.tsx +1 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +14 -9
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
- package/themes/business/src/components/OrderDetails/Business.tsx +54 -102
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +31 -3
- package/themes/business/src/components/OrderDetails/styles.tsx +3 -4
- package/themes/business/src/types/index.tsx +3 -3
- package/themes/doordash/src/components/Cart/index.tsx +55 -22
- package/themes/doordash/src/components/OrderDetails/index.tsx +444 -386
- package/themes/doordash/src/components/OrderSummary/index.tsx +252 -221
- package/themes/doordash/src/components/OrderSummary/styles.tsx +6 -0
- package/themes/doordash/src/components/SingleProductCard/index.tsx +1 -1
- package/themes/doordash/src/components/TaxInformation/index.tsx +51 -0
- package/themes/doordash/src/components/TaxInformation/styles.tsx +9 -0
- package/themes/franchises/src/components/Cart/index.tsx +55 -23
- package/themes/franchises/src/components/OrderDetails/index.tsx +77 -23
- package/themes/franchises/src/components/OrderSummary/index.tsx +58 -24
- package/themes/franchises/src/components/OrderSummary/styles.tsx +6 -0
- package/themes/franchises/src/components/SingleProductCard/index.tsx +1 -1
- package/themes/franchises/src/components/TaxInformation/index.tsx +51 -0
- package/themes/franchises/src/components/TaxInformation/styles.tsx +9 -0
- package/themes/instacart/src/components/Cart/index.tsx +57 -17
- package/themes/instacart/src/components/OrderDetails/index.tsx +490 -433
- package/themes/instacart/src/components/OrderSummary/index.tsx +236 -194
- package/themes/instacart/src/components/OrderSummary/styles.tsx +6 -0
- package/themes/instacart/src/components/SingleProductCard/index.tsx +2 -2
- package/themes/instacart/src/components/TaxInformation/index.tsx +51 -0
- package/themes/instacart/src/components/TaxInformation/styles.tsx +9 -0
- package/themes/original/src/components/Cart/index.tsx +55 -13
- package/themes/original/src/components/OrderDetails/index.tsx +76 -23
- package/themes/original/src/components/OrderSummary/index.tsx +208 -173
- package/themes/original/src/components/OrderSummary/styles.tsx +6 -0
- package/themes/original/src/components/SingleProductCard/index.tsx +1 -1
- package/themes/original/src/components/TaxInformation/index.tsx +51 -0
- package/themes/original/src/components/TaxInformation/styles.tsx +9 -0
- package/themes/single-business/src/components/Cart/index.tsx +57 -24
- package/themes/single-business/src/components/OrderDetails/index.tsx +77 -23
- package/themes/single-business/src/components/OrderSummary/index.tsx +58 -24
- package/themes/single-business/src/components/OrderSummary/styles.tsx +6 -0
- package/themes/single-business/src/components/SingleProductCard/index.tsx +1 -1
- package/themes/single-business/src/components/TaxInformation/index.tsx +51 -0
- package/themes/single-business/src/components/TaxInformation/styles.tsx +9 -0
- package/themes/uber-eats/src/components/Cart/index.tsx +56 -14
- package/themes/uber-eats/src/components/OrderDetails/index.tsx +81 -22
- package/themes/uber-eats/src/components/OrderSummary/index.tsx +56 -23
- package/themes/uber-eats/src/components/OrderSummary/styles.tsx +6 -0
- package/themes/uber-eats/src/components/SingleProductCard/index.tsx +1 -1
- package/themes/uber-eats/src/components/TaxInformation/index.tsx +51 -0
- package/themes/uber-eats/src/components/TaxInformation/styles.tsx +9 -0
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { TextStyle, View } from 'react-native'
|
|
2
|
+
import { TextStyle, TouchableOpacity, View } from 'react-native'
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
Cart,
|
|
5
|
+
useOrder,
|
|
6
|
+
useLanguage,
|
|
7
|
+
useUtils,
|
|
8
|
+
useConfig,
|
|
9
|
+
useValidationFields,
|
|
10
10
|
} from 'ordering-components/native';
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
OSContainer,
|
|
14
|
+
OSProductList,
|
|
15
|
+
OSBill,
|
|
16
|
+
OSTable,
|
|
17
|
+
OSRow
|
|
17
18
|
} from './styles';
|
|
18
19
|
|
|
19
20
|
import { ProductItemAccordion } from '../ProductItemAccordion';
|
|
@@ -23,229 +24,259 @@ import { useTheme } from 'styled-components/native';
|
|
|
23
24
|
import { ProductForm } from '../ProductForm';
|
|
24
25
|
import { verifyDecimals } from '../../utils';
|
|
25
26
|
import { UpsellingProducts } from '../UpsellingProducts';
|
|
26
|
-
|
|
27
|
+
import { TaxInformation } from '../TaxInformation';
|
|
28
|
+
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
27
29
|
|
|
28
30
|
const OrderSummaryUI = (props: any) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
const {
|
|
32
|
+
cart,
|
|
33
|
+
changeQuantity,
|
|
34
|
+
getProductMax,
|
|
35
|
+
offsetDisabled,
|
|
36
|
+
removeProduct,
|
|
37
|
+
isCartPending,
|
|
38
|
+
isFromCheckout,
|
|
39
|
+
hasUpSelling,
|
|
40
|
+
title,
|
|
41
|
+
paddingH,
|
|
42
|
+
isMini,
|
|
43
|
+
} = props;
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
const theme = useTheme();
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
const [, t] = useLanguage();
|
|
48
|
+
const [{ configs }] = useConfig();
|
|
49
|
+
const [orderState] = useOrder();
|
|
50
|
+
const [{ parsePrice, parseNumber }] = useUtils();
|
|
51
|
+
const [validationFields] = useValidationFields();
|
|
52
|
+
const [openProduct, setModalIsOpen] = useState(false)
|
|
53
|
+
const [curProduct, setCurProduct] = useState<any>(null)
|
|
54
|
+
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
52
55
|
|
|
53
|
-
|
|
56
|
+
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
|
|
54
57
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
const handleDeleteClick = (product: any) => {
|
|
59
|
+
removeProduct(product, cart)
|
|
60
|
+
}
|
|
58
61
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
const handleEditProduct = (product: any) => {
|
|
63
|
+
setCurProduct(product)
|
|
64
|
+
setModalIsOpen(true)
|
|
65
|
+
}
|
|
63
66
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
const handlerProductAction = (product: any) => {
|
|
68
|
+
if (Object.keys(product).length) {
|
|
69
|
+
setModalIsOpen(false)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
69
72
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
product={product}
|
|
80
|
-
isCartPending={isCartPending}
|
|
81
|
-
isCartProduct
|
|
82
|
-
changeQuantity={changeQuantity}
|
|
83
|
-
getProductMax={getProductMax}
|
|
84
|
-
offsetDisabled={offsetDisabled}
|
|
85
|
-
onDeleteProduct={handleDeleteClick}
|
|
86
|
-
onEditProduct={handleEditProduct}
|
|
87
|
-
isFromCheckout={isFromCheckout}
|
|
88
|
-
isMini={isMini}
|
|
89
|
-
/>
|
|
90
|
-
))}
|
|
91
|
-
</OSProductList>
|
|
92
|
-
{hasUpSelling && (
|
|
93
|
-
<View style={{ marginVertical: 28, paddingBottom: 36, borderBottomWidth: 8, borderBottomColor: theme.colors.inputDisabled }}>
|
|
94
|
-
<UpsellingProducts
|
|
95
|
-
businessId={cart?.business_id}
|
|
96
|
-
business={cart?.business}
|
|
97
|
-
cartProducts={cart?.products}
|
|
98
|
-
handleUpsellingPage={() => { }}
|
|
99
|
-
openUpselling={true}
|
|
100
|
-
canOpenUpselling={true}
|
|
101
|
-
isCustomMode
|
|
102
|
-
scrollContainerStyle={{ paddingHorizontal: paddingH }}
|
|
103
|
-
/>
|
|
104
|
-
</View>
|
|
105
|
-
)}
|
|
106
|
-
{cart?.valid && (
|
|
107
|
-
<OSBill style={{ paddingHorizontal: paddingH }}>
|
|
108
|
-
{!isMini ? (
|
|
109
|
-
<View>
|
|
110
|
-
{cart?.total >= 1 && (
|
|
111
|
-
<View style={{ borderBottomWidth: 1, borderBottomColor: theme.colors.border, paddingBottom: 12, marginBottom: 4 }}>
|
|
112
|
-
<OSTable>
|
|
113
|
-
<OText style={theme.labels.middle as TextStyle}>
|
|
114
|
-
{t('TOTAL', 'Total')}
|
|
115
|
-
</OText>
|
|
116
|
-
<OText style={theme.labels.middle as TextStyle}>
|
|
117
|
-
{parsePrice(cart?.total)}
|
|
118
|
-
</OText>
|
|
119
|
-
</OSTable>
|
|
120
|
-
</View>
|
|
121
|
-
)}
|
|
122
|
-
{isCouponEnabled && !isCartPending && (
|
|
123
|
-
<View style={{ paddingVertical: 5, marginBottom: 7 }}>
|
|
124
|
-
<CouponControl
|
|
125
|
-
businessId={cart.business_id}
|
|
126
|
-
price={cart.total}
|
|
127
|
-
/>
|
|
128
|
-
</View>
|
|
129
|
-
)}
|
|
130
|
-
</View>
|
|
131
|
-
) : null}
|
|
132
|
-
<OSTable>
|
|
133
|
-
<OText style={theme.labels.normal as TextStyle}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
134
|
-
<OText style={theme.labels.normal as TextStyle}>{cart.business.tax_type === 1
|
|
135
|
-
? parsePrice((cart?.subtotal + cart?.tax) || 0)
|
|
136
|
-
: parsePrice(cart?.subtotal || 0)}</OText>
|
|
137
|
-
</OSTable>
|
|
138
|
-
{cart?.discount > 0 && cart?.total >= 0 && (
|
|
139
|
-
<OSTable>
|
|
140
|
-
{cart?.discount_type === 1 ? (
|
|
141
|
-
<OText style={theme.labels.normal as TextStyle}>
|
|
142
|
-
{t('DISCOUNT', 'Discount')}
|
|
143
|
-
<OText style={theme.labels.normal as TextStyle}>{`(${verifyDecimals(cart?.discount_rate, parsePrice)}%)`}</OText>
|
|
144
|
-
</OText>
|
|
145
|
-
) : (
|
|
146
|
-
<OText style={theme.labels.normal as TextStyle}>{t('DISCOUNT', 'Discount')}</OText>
|
|
147
|
-
)}
|
|
148
|
-
<OText style={theme.labels.normal as TextStyle}>- {parsePrice(cart?.discount || 0)}</OText>
|
|
149
|
-
</OSTable>
|
|
150
|
-
)}
|
|
151
|
-
{cart.business.tax_type !== 1 && (
|
|
152
|
-
<OSTable>
|
|
153
|
-
<OText style={theme.labels.normal as TextStyle}>
|
|
154
|
-
{t('TAX', 'Tax')}
|
|
155
|
-
{`(${verifyDecimals(cart?.business?.tax, parseNumber)}%)`}
|
|
156
|
-
</OText>
|
|
157
|
-
<OText style={theme.labels.normal as TextStyle}>{parsePrice(cart?.tax || 0)}</OText>
|
|
158
|
-
</OSTable>
|
|
159
|
-
)}
|
|
160
|
-
{orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
|
|
161
|
-
<OSTable>
|
|
162
|
-
<OText style={theme.labels.normal as TextStyle}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
|
|
163
|
-
<OText style={theme.labels.normal as TextStyle}>{parsePrice(cart?.delivery_price)}</OText>
|
|
164
|
-
</OSTable>
|
|
165
|
-
)}
|
|
166
|
-
{cart?.driver_tip > 0 && (
|
|
167
|
-
<OSTable>
|
|
168
|
-
<OText style={theme.labels.normal as TextStyle}>
|
|
169
|
-
{t('DRIVER_TIP', 'Driver tip')}
|
|
170
|
-
{cart?.driver_tip_rate > 0 &&
|
|
171
|
-
parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
|
|
172
|
-
!parseInt(configs?.driver_tip_use_custom?.value, 10) &&
|
|
173
|
-
(
|
|
174
|
-
`(${verifyDecimals(cart?.driver_tip_rate, parseNumber)}%)`
|
|
175
|
-
)}
|
|
176
|
-
</OText>
|
|
177
|
-
<OText style={theme.labels.normal as TextStyle}>{parsePrice(cart?.driver_tip)}</OText>
|
|
178
|
-
</OSTable>
|
|
179
|
-
)}
|
|
180
|
-
{cart?.service_fee > 0 && (
|
|
181
|
-
<OSTable>
|
|
182
|
-
<OText style={theme.labels.normal as TextStyle}>
|
|
183
|
-
{t('SERVICE_FEE', 'Service Fee')}
|
|
184
|
-
{`(${verifyDecimals(cart?.business?.service_fee, parseNumber)}%)`}
|
|
185
|
-
</OText>
|
|
186
|
-
<OText style={theme.labels.normal as TextStyle}>{parsePrice(cart?.service_fee)}</OText>
|
|
187
|
-
</OSTable>
|
|
188
|
-
)}
|
|
73
|
+
const getIncludedTaxes = () => {
|
|
74
|
+
if (cart?.taxes === null) {
|
|
75
|
+
return cart.business.tax_type === 1 ? cart?.tax : 0
|
|
76
|
+
} else {
|
|
77
|
+
return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
|
|
78
|
+
return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
|
|
79
|
+
}, 0)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
189
82
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
83
|
+
return (
|
|
84
|
+
<OSContainer>
|
|
85
|
+
{cart?.products?.length > 0 && (
|
|
86
|
+
<>
|
|
87
|
+
<OSProductList style={{ paddingHorizontal: paddingH }}>
|
|
88
|
+
{title && <OText style={{ ...theme.labels.middle, marginVertical: 12 } as TextStyle}>{title}</OText>}
|
|
89
|
+
{cart?.products.map((product: any) => (
|
|
90
|
+
<ProductItemAccordion
|
|
91
|
+
key={product.code}
|
|
92
|
+
product={product}
|
|
93
|
+
isCartPending={isCartPending}
|
|
94
|
+
isCartProduct
|
|
95
|
+
changeQuantity={changeQuantity}
|
|
96
|
+
getProductMax={getProductMax}
|
|
97
|
+
offsetDisabled={offsetDisabled}
|
|
98
|
+
onDeleteProduct={handleDeleteClick}
|
|
99
|
+
onEditProduct={handleEditProduct}
|
|
100
|
+
isFromCheckout={isFromCheckout}
|
|
101
|
+
isMini={isMini}
|
|
102
|
+
/>
|
|
103
|
+
))}
|
|
104
|
+
</OSProductList>
|
|
105
|
+
{hasUpSelling && (
|
|
106
|
+
<View style={{ marginVertical: 28, paddingBottom: 36, borderBottomWidth: 8, borderBottomColor: theme.colors.inputDisabled }}>
|
|
107
|
+
<UpsellingProducts
|
|
108
|
+
businessId={cart?.business_id}
|
|
109
|
+
business={cart?.business}
|
|
110
|
+
cartProducts={cart?.products}
|
|
111
|
+
handleUpsellingPage={() => { }}
|
|
112
|
+
openUpselling={true}
|
|
113
|
+
canOpenUpselling={true}
|
|
114
|
+
isCustomMode
|
|
115
|
+
scrollContainerStyle={{ paddingHorizontal: paddingH }}
|
|
116
|
+
/>
|
|
117
|
+
</View>
|
|
118
|
+
)}
|
|
119
|
+
{cart?.valid && (
|
|
120
|
+
<OSBill style={{ paddingHorizontal: paddingH }}>
|
|
121
|
+
{!isMini ? (
|
|
122
|
+
<View>
|
|
123
|
+
{cart?.total >= 1 && (
|
|
124
|
+
<View style={{ borderBottomWidth: 1, borderBottomColor: theme.colors.border, paddingBottom: 12, marginBottom: 4 }}>
|
|
125
|
+
<OSTable>
|
|
126
|
+
<OText style={theme.labels.middle as TextStyle}>
|
|
127
|
+
{t('TOTAL', 'Total')}
|
|
128
|
+
</OText>
|
|
129
|
+
<OText style={theme.labels.middle as TextStyle}>
|
|
130
|
+
{parsePrice(cart?.total)}
|
|
131
|
+
</OText>
|
|
132
|
+
</OSTable>
|
|
133
|
+
</View>
|
|
134
|
+
)}
|
|
135
|
+
{isCouponEnabled && !isCartPending && (
|
|
136
|
+
<View style={{ paddingVertical: 5, marginBottom: 7 }}>
|
|
137
|
+
<CouponControl
|
|
138
|
+
businessId={cart.business_id}
|
|
139
|
+
price={cart.total}
|
|
140
|
+
/>
|
|
141
|
+
</View>
|
|
142
|
+
)}
|
|
143
|
+
</View>
|
|
144
|
+
) : null}
|
|
145
|
+
<OSTable>
|
|
146
|
+
<OText style={theme.labels.normal as TextStyle}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
147
|
+
<OText style={theme.labels.normal as TextStyle}>{parsePrice(cart?.subtotal + getIncludedTaxes())}</OText>
|
|
148
|
+
</OSTable>
|
|
149
|
+
{cart?.discount > 0 && cart?.total >= 0 && (
|
|
150
|
+
<OSTable>
|
|
151
|
+
{cart?.discount_type === 1 ? (
|
|
152
|
+
<OText style={theme.labels.normal as TextStyle}>
|
|
153
|
+
{t('DISCOUNT', 'Discount')}
|
|
154
|
+
<OText style={theme.labels.normal as TextStyle}>{`(${verifyDecimals(cart?.discount_rate, parsePrice)}%)`}</OText>
|
|
155
|
+
</OText>
|
|
156
|
+
) : (
|
|
157
|
+
<OText style={theme.labels.normal as TextStyle}>{t('DISCOUNT', 'Discount')}</OText>
|
|
158
|
+
)}
|
|
159
|
+
<OText style={theme.labels.normal as TextStyle}>- {parsePrice(cart?.discount || 0)}</OText>
|
|
160
|
+
</OSTable>
|
|
161
|
+
)}
|
|
162
|
+
{
|
|
163
|
+
cart?.taxes?.length > 0 && cart?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
164
|
+
<OSTable key={tax?.id}>
|
|
165
|
+
<OSRow>
|
|
166
|
+
<OText numberOfLines={1}>
|
|
167
|
+
{tax?.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
168
|
+
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
169
|
+
</OText>
|
|
170
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
|
|
171
|
+
<AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
|
|
172
|
+
</TouchableOpacity>
|
|
173
|
+
</OSRow>
|
|
174
|
+
<OText>{parsePrice(tax?.summary?.tax || 0)}</OText>
|
|
175
|
+
</OSTable>
|
|
176
|
+
))
|
|
177
|
+
}
|
|
178
|
+
{
|
|
179
|
+
cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
|
|
180
|
+
<OSTable key={fee.id}>
|
|
181
|
+
<OSRow>
|
|
182
|
+
<OText numberOfLines={1}>
|
|
183
|
+
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
184
|
+
({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
|
|
185
|
+
</OText>
|
|
186
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
|
|
187
|
+
<AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
|
|
188
|
+
</TouchableOpacity>
|
|
189
|
+
</OSRow>
|
|
190
|
+
<OText>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
|
|
191
|
+
</OSTable>
|
|
192
|
+
))
|
|
193
|
+
}
|
|
194
|
+
{orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
|
|
195
|
+
<OSTable>
|
|
196
|
+
<OText style={theme.labels.normal as TextStyle}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
|
|
197
|
+
<OText style={theme.labels.normal as TextStyle}>{parsePrice(cart?.delivery_price)}</OText>
|
|
198
|
+
</OSTable>
|
|
199
|
+
)}
|
|
200
|
+
{cart?.driver_tip > 0 && (
|
|
201
|
+
<OSTable>
|
|
202
|
+
<OText style={theme.labels.normal as TextStyle}>
|
|
203
|
+
{t('DRIVER_TIP', 'Driver tip')}
|
|
204
|
+
{cart?.driver_tip_rate > 0 &&
|
|
205
|
+
parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
|
|
206
|
+
!parseInt(configs?.driver_tip_use_custom?.value, 10) &&
|
|
207
|
+
(
|
|
208
|
+
`(${verifyDecimals(cart?.driver_tip_rate, parseNumber)}%)`
|
|
209
|
+
)}
|
|
210
|
+
</OText>
|
|
211
|
+
<OText style={theme.labels.normal as TextStyle}>{parsePrice(cart?.driver_tip)}</OText>
|
|
212
|
+
</OSTable>
|
|
213
|
+
)}
|
|
214
|
+
{isMini ? (
|
|
215
|
+
<View style={{ marginTop: 10 }}>
|
|
216
|
+
{cart?.total >= 1 && (
|
|
217
|
+
<View style={{ borderTopWidth: 1, borderTopColor: theme.colors.border, paddingTop: 12, marginBottom: 4 }}>
|
|
218
|
+
<OSTable>
|
|
219
|
+
<OText style={theme.labels.middle as TextStyle}>
|
|
220
|
+
{t('TOTAL', 'Total')}
|
|
221
|
+
</OText>
|
|
222
|
+
<OText style={theme.labels.middle as TextStyle}>
|
|
223
|
+
{parsePrice(cart?.total)}
|
|
224
|
+
</OText>
|
|
225
|
+
</OSTable>
|
|
226
|
+
</View>
|
|
227
|
+
)}
|
|
228
|
+
{isCouponEnabled && !isCartPending && (
|
|
229
|
+
<View style={{ paddingVertical: 5, marginBottom: 7 }}>
|
|
230
|
+
<CouponControl
|
|
231
|
+
businessId={cart.business_id}
|
|
232
|
+
price={cart.total}
|
|
233
|
+
/>
|
|
234
|
+
</View>
|
|
235
|
+
)}
|
|
236
|
+
</View>
|
|
237
|
+
) : null}
|
|
214
238
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
239
|
+
</OSBill>
|
|
240
|
+
)}
|
|
241
|
+
<OModal
|
|
242
|
+
open={openProduct}
|
|
243
|
+
entireModal
|
|
244
|
+
customClose
|
|
245
|
+
onClose={() => setModalIsOpen(false)}
|
|
246
|
+
overScreen
|
|
247
|
+
>
|
|
248
|
+
<ProductForm
|
|
249
|
+
isCartProduct
|
|
250
|
+
productCart={curProduct}
|
|
251
|
+
businessSlug={cart?.business?.slug}
|
|
252
|
+
businessId={cart?.business_id}
|
|
253
|
+
categoryId={curProduct?.category_id}
|
|
254
|
+
productId={curProduct?.id}
|
|
255
|
+
onSave={handlerProductAction}
|
|
256
|
+
onClose={() => setModalIsOpen(false)}
|
|
257
|
+
isFromCheckout={isFromCheckout}
|
|
258
|
+
/>
|
|
259
|
+
</OModal>
|
|
260
|
+
<OModal
|
|
261
|
+
open={openTaxModal.open}
|
|
262
|
+
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
263
|
+
entireModal
|
|
264
|
+
>
|
|
265
|
+
<TaxInformation data={openTaxModal.data} products={cart.products} />
|
|
266
|
+
</OModal>
|
|
267
|
+
</>
|
|
268
|
+
)}
|
|
269
|
+
</OSContainer>
|
|
270
|
+
)
|
|
240
271
|
}
|
|
241
272
|
|
|
242
273
|
export const OrderSummary = (props: any) => {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
274
|
+
const orderSummaryProps = {
|
|
275
|
+
...props,
|
|
276
|
+
UIComponent: OrderSummaryUI
|
|
277
|
+
}
|
|
247
278
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
279
|
+
return (
|
|
280
|
+
<Cart {...orderSummaryProps} />
|
|
281
|
+
)
|
|
251
282
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { useLanguage, useUtils } from 'ordering-components/native'
|
|
3
|
+
import { SingleProductCard } from '../SingleProductCard'
|
|
4
|
+
import { TaxInformationContainer, ProductContainer } from './styles'
|
|
5
|
+
import { OText } from '../shared'
|
|
6
|
+
|
|
7
|
+
interface taxInformationParams {
|
|
8
|
+
data: { name: string, description?: string, rate: string | number, type: number, fixed?: number, percentage?: number, id: number },
|
|
9
|
+
products: Array<any>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const TaxInformation = (props: taxInformationParams) => {
|
|
13
|
+
const {
|
|
14
|
+
data,
|
|
15
|
+
products
|
|
16
|
+
} = props
|
|
17
|
+
|
|
18
|
+
const [, t] = useLanguage()
|
|
19
|
+
const [{ parsePrice }] = useUtils()
|
|
20
|
+
|
|
21
|
+
const isTax = typeof data?.rate === 'number'
|
|
22
|
+
const TaxFeeString = isTax ? 'tax' : 'fee'
|
|
23
|
+
const includedOnPriceString = data?.type === 1 ? `(${t('INCLUDED_ON_PRICE', 'Included on price')})` : `(${t('NOT_INCLUDED_ON_PRICE', 'Not included on price')})`
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<TaxInformationContainer>
|
|
27
|
+
<OText size={24} style={{ alignSelf: 'center', textAlign: 'center' }} mBottom={10}>
|
|
28
|
+
{`${data?.name ||
|
|
29
|
+
t('INHERIT_FROM_BUSINESS', 'Inherit from business')} (${typeof data?.rate === 'number' ? `${data?.rate}%` : `${parsePrice(data?.fixed ?? 0)} + ${data?.percentage}%`})`}
|
|
30
|
+
</OText>
|
|
31
|
+
{data?.description && (
|
|
32
|
+
<OText mBottom={10} size={18} style={{ alignSelf: 'center', textAlign: 'center' }}>
|
|
33
|
+
{t('DESCRIPTION', 'Description')}: {data?.description} {data?.type && includedOnPriceString}
|
|
34
|
+
</OText>
|
|
35
|
+
)}
|
|
36
|
+
<OText>{t(`OTHER_PRODUCTS_WITH_THIS_${TaxFeeString.toUpperCase()}`, `Other products with this ${TaxFeeString}`)}:</OText>
|
|
37
|
+
<ProductContainer>
|
|
38
|
+
{
|
|
39
|
+
products.filter((product: any) => isTax ? (product.tax?.id ? product.tax?.id === data?.id : product.tax?.id === null && data?.id === null) : (product.fee?.id ? product.fee?.id === data?.id : (product.fee?.id === null && data?.id === null))).map(product => (
|
|
40
|
+
<SingleProductCard
|
|
41
|
+
key={product.id}
|
|
42
|
+
product={product}
|
|
43
|
+
isSoldOut={false}
|
|
44
|
+
businessId={product?.business_id}
|
|
45
|
+
/>
|
|
46
|
+
))
|
|
47
|
+
}
|
|
48
|
+
</ProductContainer>
|
|
49
|
+
</TaxInformationContainer>
|
|
50
|
+
)
|
|
51
|
+
}
|