ordering-ui-react-native 0.12.44 → 0.12.45
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/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/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
2
|
import { 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
|
+
import { useTheme } from 'styled-components/native';
|
|
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';
|
|
@@ -21,178 +22,212 @@ import { CouponControl } from '../CouponControl';
|
|
|
21
22
|
import { OModal, OText } from '../shared';
|
|
22
23
|
import { ProductForm } from '../ProductForm';
|
|
23
24
|
import { verifyDecimals } from '../../utils';
|
|
24
|
-
|
|
25
|
+
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
26
|
+
import { TaxInformation } from '../TaxInformation';
|
|
27
|
+
import { TouchableOpacity } from 'react-native';
|
|
25
28
|
|
|
26
29
|
const OrderSummaryUI = (props: any) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
const {
|
|
31
|
+
cart,
|
|
32
|
+
changeQuantity,
|
|
33
|
+
getProductMax,
|
|
34
|
+
offsetDisabled,
|
|
35
|
+
removeProduct,
|
|
36
|
+
isCartPending,
|
|
37
|
+
isFromCheckout
|
|
38
|
+
} = props;
|
|
39
|
+
|
|
40
|
+
const theme = useTheme()
|
|
41
|
+
const [, t] = useLanguage();
|
|
42
|
+
const [{ configs }] = useConfig();
|
|
43
|
+
const [orderState] = useOrder();
|
|
44
|
+
const [{ parsePrice, parseNumber }] = useUtils();
|
|
45
|
+
const [validationFields] = useValidationFields();
|
|
46
|
+
const [openProduct, setModalIsOpen] = useState(false)
|
|
47
|
+
const [curProduct, setCurProduct] = useState<any>(null)
|
|
48
|
+
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
49
|
+
|
|
50
|
+
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
|
|
36
51
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const [{ parsePrice, parseNumber }] = useUtils();
|
|
41
|
-
const [validationFields] = useValidationFields();
|
|
42
|
-
const [openProduct, setModalIsOpen] = useState(false)
|
|
43
|
-
const [curProduct, setCurProduct] = useState<any>(null)
|
|
52
|
+
const handleDeleteClick = (product: any) => {
|
|
53
|
+
removeProduct(product, cart)
|
|
54
|
+
}
|
|
44
55
|
|
|
45
|
-
|
|
56
|
+
const handleEditProduct = (product: any) => {
|
|
57
|
+
setCurProduct(product)
|
|
58
|
+
setModalIsOpen(true)
|
|
59
|
+
}
|
|
46
60
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
const handlerProductAction = (product: any) => {
|
|
62
|
+
if (Object.keys(product).length) {
|
|
63
|
+
setModalIsOpen(false)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
50
66
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
67
|
+
const getIncludedTaxes = () => {
|
|
68
|
+
if (cart?.taxes === null) {
|
|
69
|
+
return cart.business.tax_type === 1 ? cart?.tax : 0
|
|
70
|
+
} else {
|
|
71
|
+
return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
|
|
72
|
+
return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
|
|
73
|
+
}, 0)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
55
76
|
|
|
56
|
-
const handlerProductAction = (product: any) => {
|
|
57
|
-
if (Object.keys(product).length) {
|
|
58
|
-
setModalIsOpen(false)
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
77
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
78
|
+
return (
|
|
79
|
+
<OSContainer>
|
|
80
|
+
{cart?.products?.length > 0 && (
|
|
81
|
+
<>
|
|
82
|
+
<OSProductList>
|
|
83
|
+
{cart?.products.map((product: any) => (
|
|
84
|
+
<ProductItemAccordion
|
|
85
|
+
key={product.code}
|
|
86
|
+
product={product}
|
|
87
|
+
isCartPending={isCartPending}
|
|
88
|
+
isCartProduct
|
|
89
|
+
changeQuantity={changeQuantity}
|
|
90
|
+
getProductMax={getProductMax}
|
|
91
|
+
offsetDisabled={offsetDisabled}
|
|
92
|
+
onDeleteProduct={handleDeleteClick}
|
|
93
|
+
onEditProduct={handleEditProduct}
|
|
94
|
+
isFromCheckout={isFromCheckout}
|
|
95
|
+
/>
|
|
96
|
+
))}
|
|
97
|
+
</OSProductList>
|
|
98
|
+
{cart?.valid && (
|
|
99
|
+
<OSBill>
|
|
100
|
+
<OSTable>
|
|
101
|
+
<OText size={12}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
102
|
+
<OText size={12}>{parsePrice(cart?.subtotal + getIncludedTaxes())}</OText>
|
|
103
|
+
</OSTable>
|
|
104
|
+
{cart?.discount > 0 && cart?.total >= 0 && (
|
|
105
|
+
<OSTable>
|
|
106
|
+
{cart?.discount_type === 1 ? (
|
|
107
|
+
<OText size={12}>
|
|
108
|
+
{t('DISCOUNT', 'Discount')}
|
|
109
|
+
<OText size={12}>{`(${verifyDecimals(cart?.discount_rate, parsePrice)}%)`}</OText>
|
|
110
|
+
</OText>
|
|
111
|
+
) : (
|
|
112
|
+
<OText size={12}>{t('DISCOUNT', 'Discount')}</OText>
|
|
113
|
+
)}
|
|
114
|
+
<OText size={12}>- {parsePrice(cart?.discount || 0)}</OText>
|
|
115
|
+
</OSTable>
|
|
116
|
+
)}
|
|
117
|
+
{
|
|
118
|
+
cart?.taxes?.length > 0 && cart?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
119
|
+
<OSTable key={tax?.id}>
|
|
120
|
+
<OSRow>
|
|
121
|
+
<OText size={12} numberOfLines={1}>
|
|
122
|
+
{tax?.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
123
|
+
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
124
|
+
</OText>
|
|
125
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
|
|
126
|
+
<AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
|
|
127
|
+
</TouchableOpacity>
|
|
128
|
+
</OSRow>
|
|
129
|
+
<OText size={12}>{parsePrice(tax?.summary?.tax || 0)}</OText>
|
|
130
|
+
</OSTable>
|
|
131
|
+
))
|
|
132
|
+
}
|
|
133
|
+
{
|
|
134
|
+
cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
|
|
135
|
+
<OSTable key={fee.id}>
|
|
136
|
+
<OSRow>
|
|
137
|
+
<OText size={12} numberOfLines={1}>
|
|
138
|
+
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
139
|
+
({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
|
|
140
|
+
</OText>
|
|
141
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
|
|
142
|
+
<AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
|
|
143
|
+
</TouchableOpacity>
|
|
144
|
+
</OSRow>
|
|
145
|
+
<OText size={12}>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
|
|
146
|
+
</OSTable>
|
|
147
|
+
))
|
|
148
|
+
}
|
|
149
|
+
{orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
|
|
150
|
+
<OSTable>
|
|
151
|
+
<OText size={12}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
|
|
152
|
+
<OText size={12}>{parsePrice(cart?.delivery_price)}</OText>
|
|
153
|
+
</OSTable>
|
|
154
|
+
)}
|
|
155
|
+
{cart?.driver_tip > 0 && (
|
|
156
|
+
<OSTable>
|
|
157
|
+
<OText size={12}>
|
|
158
|
+
{t('DRIVER_TIP', 'Driver tip')}
|
|
159
|
+
{cart?.driver_tip_rate > 0 &&
|
|
160
|
+
parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
|
|
161
|
+
!parseInt(configs?.driver_tip_use_custom?.value, 10) &&
|
|
162
|
+
(
|
|
163
|
+
`(${verifyDecimals(cart?.driver_tip_rate, parseNumber)}%)`
|
|
164
|
+
)}
|
|
165
|
+
</OText>
|
|
166
|
+
<OText size={12}>{parsePrice(cart?.driver_tip)}</OText>
|
|
167
|
+
</OSTable>
|
|
168
|
+
)}
|
|
169
|
+
{isCouponEnabled && !isCartPending && (
|
|
170
|
+
<View>
|
|
171
|
+
<View style={{ paddingVertical: 5 }}>
|
|
172
|
+
<CouponControl
|
|
173
|
+
businessId={cart.business_id}
|
|
174
|
+
price={cart.total}
|
|
175
|
+
/>
|
|
176
|
+
</View>
|
|
177
|
+
</View>
|
|
178
|
+
)}
|
|
179
|
+
{cart?.total >= 1 && (
|
|
180
|
+
<View style={{ marginTop: 15, borderTopWidth: 1, borderTopColor: '#d9d9d9' }}>
|
|
181
|
+
<OSTable style={{ marginTop: 15 }}>
|
|
182
|
+
<OText size={14} style={{ fontWeight: 'bold' }}>
|
|
183
|
+
{t('TOTAL', 'Total')}
|
|
184
|
+
</OText>
|
|
185
|
+
<OText size={14} style={{ fontWeight: 'bold' }} >
|
|
186
|
+
{parsePrice(cart?.total)}
|
|
187
|
+
</OText>
|
|
188
|
+
</OSTable>
|
|
189
|
+
</View>
|
|
190
|
+
)}
|
|
191
|
+
</OSBill>
|
|
192
|
+
)}
|
|
193
|
+
<OModal
|
|
194
|
+
open={openProduct}
|
|
195
|
+
entireModal
|
|
196
|
+
customClose
|
|
197
|
+
onClose={() => setModalIsOpen(false)}
|
|
198
|
+
>
|
|
199
|
+
<ProductForm
|
|
200
|
+
isCartProduct
|
|
201
|
+
productCart={curProduct}
|
|
202
|
+
businessSlug={cart?.business?.slug}
|
|
203
|
+
businessId={cart?.business_id}
|
|
204
|
+
categoryId={curProduct?.category_id}
|
|
205
|
+
productId={curProduct?.id}
|
|
206
|
+
onSave={handlerProductAction}
|
|
207
|
+
onClose={() => setModalIsOpen(false)}
|
|
208
|
+
isFromCheckout={isFromCheckout}
|
|
209
|
+
/>
|
|
210
|
+
</OModal>
|
|
211
|
+
<OModal
|
|
212
|
+
open={openTaxModal.open}
|
|
213
|
+
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
214
|
+
entireModal
|
|
215
|
+
>
|
|
216
|
+
<TaxInformation data={openTaxModal.data} products={cart.products} />
|
|
217
|
+
</OModal>
|
|
218
|
+
</>
|
|
219
|
+
)}
|
|
220
|
+
</OSContainer>
|
|
221
|
+
)
|
|
187
222
|
}
|
|
188
223
|
|
|
189
224
|
export const OrderSummary = (props: any) => {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
225
|
+
const orderSummaryProps = {
|
|
226
|
+
...props,
|
|
227
|
+
UIComponent: OrderSummaryUI
|
|
228
|
+
}
|
|
194
229
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
230
|
+
return (
|
|
231
|
+
<Cart {...orderSummaryProps} />
|
|
232
|
+
)
|
|
198
233
|
}
|
|
@@ -87,7 +87,7 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
|
|
|
87
87
|
styles.container,
|
|
88
88
|
(isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle,
|
|
89
89
|
]}
|
|
90
|
-
onPress={() => onProductClick(product)}>
|
|
90
|
+
onPress={() => onProductClick?.(product)}>
|
|
91
91
|
<CardInfo>
|
|
92
92
|
<OText
|
|
93
93
|
size={12}
|
|
@@ -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
|
+
}
|
|
@@ -28,7 +28,10 @@ import { UpsellingProducts } from '../UpsellingProducts';
|
|
|
28
28
|
import { verifyDecimals } from '../../utils';
|
|
29
29
|
import { Container } from '../../layouts/Container';
|
|
30
30
|
import { NotFoundSource } from '../NotFoundSource'
|
|
31
|
-
|
|
31
|
+
import { OSRow } from '../OrderSummary/styles';
|
|
32
|
+
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
33
|
+
import { TaxInformation } from '../TaxInformation';
|
|
34
|
+
import { TouchableOpacity } from 'react-native';
|
|
32
35
|
const CartUI = (props: any) => {
|
|
33
36
|
const {
|
|
34
37
|
cart,
|
|
@@ -55,6 +58,7 @@ const CartUI = (props: any) => {
|
|
|
55
58
|
const [openUpselling, setOpenUpselling] = useState(false)
|
|
56
59
|
const [canOpenUpselling, setCanOpenUpselling] = useState(false)
|
|
57
60
|
const [isUpsellingProducts, setIsUpsellingProducts] = useState(false)
|
|
61
|
+
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
58
62
|
|
|
59
63
|
const isCartPending = cart?.status === 2
|
|
60
64
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
|
|
@@ -96,6 +100,16 @@ const CartUI = (props: any) => {
|
|
|
96
100
|
})
|
|
97
101
|
}
|
|
98
102
|
|
|
103
|
+
const getIncludedTaxes = () => {
|
|
104
|
+
if (cart?.taxes === null) {
|
|
105
|
+
return cart.business.tax_type === 1 ? cart?.tax : 0
|
|
106
|
+
} else {
|
|
107
|
+
return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
|
|
108
|
+
return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
|
|
109
|
+
}, 0)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
99
113
|
return (
|
|
100
114
|
cart?.products?.length > 0 ? (
|
|
101
115
|
<ScrollView
|
|
@@ -134,9 +148,7 @@ const CartUI = (props: any) => {
|
|
|
134
148
|
<OSTable>
|
|
135
149
|
<OText size={12} lineHeight={18}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
136
150
|
<OText size={12} lineHeight={18}>
|
|
137
|
-
{cart
|
|
138
|
-
? parsePrice((cart?.subtotal + cart?.tax) || 0)
|
|
139
|
-
: parsePrice(cart?.subtotal || 0)}
|
|
151
|
+
{parsePrice(cart?.subtotal + getIncludedTaxes())}
|
|
140
152
|
</OText>
|
|
141
153
|
</OSTable>
|
|
142
154
|
{cart?.discount > 0 && cart?.total >= 0 && (
|
|
@@ -152,15 +164,38 @@ const CartUI = (props: any) => {
|
|
|
152
164
|
<OText size={12} lineHeight={18}>- {parsePrice(cart?.discount || 0)}</OText>
|
|
153
165
|
</OSTable>
|
|
154
166
|
)}
|
|
155
|
-
{
|
|
156
|
-
|
|
157
|
-
<
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
167
|
+
{
|
|
168
|
+
cart.taxes?.length > 0 && cart.taxes.filter((tax: any) => tax.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
169
|
+
<OSTable key={tax.id}>
|
|
170
|
+
<OSRow>
|
|
171
|
+
<OText size={12} numberOfLines={1} >
|
|
172
|
+
{tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
173
|
+
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
174
|
+
</OText>
|
|
175
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
|
|
176
|
+
<AntIcon name='exclamationcircleo' size={12} color={theme.colors.primary} />
|
|
177
|
+
</TouchableOpacity>
|
|
178
|
+
</OSRow>
|
|
179
|
+
<OText size={12}>{parsePrice(tax?.summary?.tax || 0)}</OText>
|
|
180
|
+
</OSTable>
|
|
181
|
+
))
|
|
182
|
+
}
|
|
183
|
+
{
|
|
184
|
+
cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any) => (
|
|
185
|
+
<OSTable key={fee?.id}>
|
|
186
|
+
<OSRow>
|
|
187
|
+
<OText size={12} numberOfLines={1}>
|
|
188
|
+
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
189
|
+
({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
|
|
190
|
+
</OText>
|
|
191
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
|
|
192
|
+
<AntIcon name='exclamationcircleo' size={12} color={theme.colors.primary} />
|
|
193
|
+
</TouchableOpacity>
|
|
194
|
+
</OSRow>
|
|
195
|
+
<OText size={12}>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
|
|
196
|
+
</OSTable>
|
|
197
|
+
))
|
|
198
|
+
}
|
|
164
199
|
{orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
|
|
165
200
|
<OSTable>
|
|
166
201
|
<OText size={12} lineHeight={18}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
|
|
@@ -181,15 +216,6 @@ const CartUI = (props: any) => {
|
|
|
181
216
|
<OText size={12} lineHeight={18}>{parsePrice(cart?.driver_tip)}</OText>
|
|
182
217
|
</OSTable>
|
|
183
218
|
)}
|
|
184
|
-
{cart?.service_fee > 0 && (
|
|
185
|
-
<OSTable>
|
|
186
|
-
<OText size={12} lineHeight={18}>
|
|
187
|
-
{t('SERVICE_FEE', 'Service Fee')}
|
|
188
|
-
{`(${verifyDecimals(cart?.business?.service_fee, parseNumber)}%)`}
|
|
189
|
-
</OText>
|
|
190
|
-
<OText size={12} lineHeight={18}>{parsePrice(cart?.service_fee)}</OText>
|
|
191
|
-
</OSTable>
|
|
192
|
-
)}
|
|
193
219
|
{isCouponEnabled && !isCartPending && (
|
|
194
220
|
<OSTable>
|
|
195
221
|
<OSCoupon>
|
|
@@ -200,7 +226,7 @@ const CartUI = (props: any) => {
|
|
|
200
226
|
</OSCoupon>
|
|
201
227
|
</OSTable>
|
|
202
228
|
)}
|
|
203
|
-
|
|
229
|
+
|
|
204
230
|
<OSTotal>
|
|
205
231
|
<OSTable style={{ marginTop: 15 }}>
|
|
206
232
|
<OText size={14} lineHeight={21} weight={'600'}>
|
|
@@ -289,7 +315,7 @@ const CartUI = (props: any) => {
|
|
|
289
315
|
onSave={handlerProductAction}
|
|
290
316
|
onClose={() => setModalIsOpen(false)}
|
|
291
317
|
/>
|
|
292
|
-
|
|
318
|
+
|
|
293
319
|
</OModal>
|
|
294
320
|
</ScrollView>
|
|
295
321
|
) : (
|
|
@@ -308,6 +334,13 @@ const CartUI = (props: any) => {
|
|
|
308
334
|
image={theme.images.general.notFound}
|
|
309
335
|
/>
|
|
310
336
|
</View>
|
|
337
|
+
<OModal
|
|
338
|
+
open={openTaxModal.open}
|
|
339
|
+
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
340
|
+
entireModal
|
|
341
|
+
>
|
|
342
|
+
<TaxInformation data={openTaxModal.data} products={cart.products} />
|
|
343
|
+
</OModal>
|
|
311
344
|
</Container>
|
|
312
345
|
)
|
|
313
346
|
)
|