ordering-ui-react-native 0.14.46 → 0.14.49
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/kiosk/src/components/Intro/index.tsx +78 -76
- package/themes/kiosk/src/components/shared/OButton.tsx +18 -5
- 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/OrderDetails/index.tsx +114 -42
- package/themes/original/src/components/OrderDetails/styles.tsx +8 -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/TaxInformation/index.tsx +59 -27
|
@@ -14,7 +14,8 @@ import {
|
|
|
14
14
|
OSProductList,
|
|
15
15
|
OSBill,
|
|
16
16
|
OSTable,
|
|
17
|
-
OSRow
|
|
17
|
+
OSRow,
|
|
18
|
+
Divider
|
|
18
19
|
} from './styles';
|
|
19
20
|
|
|
20
21
|
import { ProductItemAccordion } from '../ProductItemAccordion';
|
|
@@ -24,6 +25,7 @@ import { verifyDecimals } from '../../utils';
|
|
|
24
25
|
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
25
26
|
import { TaxInformation } from '../TaxInformation';
|
|
26
27
|
import { TouchableOpacity } from 'react-native';
|
|
28
|
+
import { OAlert } from '../../../../../src/components/shared'
|
|
27
29
|
|
|
28
30
|
const OrderSummaryUI = (props: any) => {
|
|
29
31
|
const {
|
|
@@ -35,7 +37,8 @@ const OrderSummaryUI = (props: any) => {
|
|
|
35
37
|
isFromCheckout,
|
|
36
38
|
commentState,
|
|
37
39
|
handleChangeComment,
|
|
38
|
-
onNavigationRedirect
|
|
40
|
+
onNavigationRedirect,
|
|
41
|
+
handleRemoveOfferClick
|
|
39
42
|
} = props;
|
|
40
43
|
|
|
41
44
|
const theme = useTheme()
|
|
@@ -44,8 +47,8 @@ const OrderSummaryUI = (props: any) => {
|
|
|
44
47
|
const [orderState] = useOrder();
|
|
45
48
|
const [{ parsePrice, parseNumber }] = useUtils();
|
|
46
49
|
const [validationFields] = useValidationFields();
|
|
47
|
-
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
48
|
-
|
|
50
|
+
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null, type: '' })
|
|
51
|
+
const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
|
|
49
52
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
|
|
50
53
|
|
|
51
54
|
const handleDeleteClick = (product: any) => {
|
|
@@ -61,7 +64,7 @@ const OrderSummaryUI = (props: any) => {
|
|
|
61
64
|
categoryId: product?.category_id,
|
|
62
65
|
productId: product?.id,
|
|
63
66
|
isFromCheckout: isFromCheckout,
|
|
64
|
-
|
|
67
|
+
})
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
const getIncludedTaxes = () => {
|
|
@@ -74,6 +77,22 @@ const OrderSummaryUI = (props: any) => {
|
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
79
|
|
|
80
|
+
const getIncludedTaxesDiscounts = () => {
|
|
81
|
+
return cart?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const onRemoveOffer = (id: number) => {
|
|
85
|
+
setConfirm({
|
|
86
|
+
open: true,
|
|
87
|
+
content: [t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')],
|
|
88
|
+
title: t('OFFER', 'Offer'),
|
|
89
|
+
handleOnAccept: () => {
|
|
90
|
+
setConfirm({ ...confirm, open: false })
|
|
91
|
+
handleRemoveOfferClick(id)
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
77
96
|
const cart = orderState?.carts?.[`businessId:${props.cart.business_id}`]
|
|
78
97
|
|
|
79
98
|
const walletName: any = {
|
|
@@ -109,9 +128,11 @@ const OrderSummaryUI = (props: any) => {
|
|
|
109
128
|
<OSBill>
|
|
110
129
|
<OSTable>
|
|
111
130
|
<OText size={12}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
112
|
-
<OText size={12}>
|
|
131
|
+
<OText size={12}>
|
|
132
|
+
{parsePrice(cart?.subtotal + getIncludedTaxes())}
|
|
133
|
+
</OText>
|
|
113
134
|
</OSTable>
|
|
114
|
-
{cart?.discount > 0 && cart?.total >= 0 && (
|
|
135
|
+
{cart?.discount > 0 && cart?.total >= 0 && cart?.offers?.length === 0 && (
|
|
115
136
|
<OSTable>
|
|
116
137
|
{cart?.discount_type === 1 ? (
|
|
117
138
|
<OText size={12}>
|
|
@@ -125,34 +146,87 @@ const OrderSummaryUI = (props: any) => {
|
|
|
125
146
|
</OSTable>
|
|
126
147
|
)}
|
|
127
148
|
{
|
|
128
|
-
cart?.
|
|
129
|
-
<OSTable key={
|
|
149
|
+
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
|
|
150
|
+
<OSTable key={offer.id}>
|
|
130
151
|
<OSRow>
|
|
131
|
-
<OText size={12}
|
|
132
|
-
|
|
152
|
+
<OText size={12}>{offer.name}</OText>
|
|
153
|
+
{offer.rate_type === 1 && (
|
|
154
|
+
<OText size={12}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
155
|
+
)}
|
|
156
|
+
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
|
|
157
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
158
|
+
</TouchableOpacity>
|
|
159
|
+
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
|
|
160
|
+
<AntIcon name='closecircle' size={18} color={theme.colors.primary} />
|
|
161
|
+
</TouchableOpacity>
|
|
162
|
+
</OSRow>
|
|
163
|
+
<OText size={12}>
|
|
164
|
+
- {parsePrice(offer?.summary?.discount)}
|
|
165
|
+
</OText>
|
|
166
|
+
</OSTable>
|
|
167
|
+
))
|
|
168
|
+
}
|
|
169
|
+
<Divider />
|
|
170
|
+
{cart?.subtotal_with_discount > 0 && cart?.discount > 0 && cart?.total >= 0 && (
|
|
171
|
+
<OSTable>
|
|
172
|
+
<OText size={12} numberOfLines={1}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
|
|
173
|
+
{cart?.business?.tax_type === 1 ? (
|
|
174
|
+
<OText size={12}>{parsePrice(cart?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0)}</OText>
|
|
175
|
+
) : (
|
|
176
|
+
<OText size={12}>{parsePrice(cart?.subtotal_with_discount ?? 0)}</OText>
|
|
177
|
+
)}
|
|
178
|
+
</OSTable>
|
|
179
|
+
)}
|
|
180
|
+
{
|
|
181
|
+
cart.taxes?.length > 0 && cart.taxes.filter((tax: any) => tax.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
182
|
+
<OSTable key={tax.id}>
|
|
183
|
+
<OSRow>
|
|
184
|
+
<OText size={12} numberOfLines={1} >
|
|
185
|
+
{tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
133
186
|
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
134
187
|
</OText>
|
|
135
|
-
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
|
|
136
|
-
<AntIcon name='exclamationcircleo' size={
|
|
188
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax, type: 'tax' })} >
|
|
189
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
137
190
|
</TouchableOpacity>
|
|
138
191
|
</OSRow>
|
|
139
|
-
<OText size={12}>{parsePrice(tax?.summary?.tax
|
|
192
|
+
<OText size={12}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
|
|
140
193
|
</OSTable>
|
|
141
194
|
))
|
|
142
195
|
}
|
|
143
196
|
{
|
|
144
|
-
cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))
|
|
145
|
-
<OSTable key={fee
|
|
197
|
+
cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any) => (
|
|
198
|
+
<OSTable key={fee?.id}>
|
|
146
199
|
<OSRow>
|
|
147
200
|
<OText size={12} numberOfLines={1}>
|
|
148
201
|
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
149
|
-
({parsePrice(fee?.fixed)} + {fee
|
|
202
|
+
({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
|
|
150
203
|
</OText>
|
|
151
|
-
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
|
|
152
|
-
<AntIcon name='exclamationcircleo' size={
|
|
204
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
|
|
205
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
153
206
|
</TouchableOpacity>
|
|
154
207
|
</OSRow>
|
|
155
|
-
<OText size={12}>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage
|
|
208
|
+
<OText size={12}>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
|
|
209
|
+
</OSTable>
|
|
210
|
+
))
|
|
211
|
+
}
|
|
212
|
+
{
|
|
213
|
+
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
|
|
214
|
+
<OSTable key={offer.id}>
|
|
215
|
+
<OSRow>
|
|
216
|
+
<OText size={12}>{offer.name}</OText>
|
|
217
|
+
{offer.rate_type === 1 && (
|
|
218
|
+
<OText size={12}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
219
|
+
)}
|
|
220
|
+
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
|
|
221
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
222
|
+
</TouchableOpacity>
|
|
223
|
+
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
|
|
224
|
+
<AntIcon name='closecircle' size={18} color={theme.colors.primary} />
|
|
225
|
+
</TouchableOpacity>
|
|
226
|
+
</OSRow>
|
|
227
|
+
<OText size={12}>
|
|
228
|
+
- {parsePrice(offer?.summary?.discount)}
|
|
229
|
+
</OText>
|
|
156
230
|
</OSTable>
|
|
157
231
|
))
|
|
158
232
|
}
|
|
@@ -162,6 +236,27 @@ const OrderSummaryUI = (props: any) => {
|
|
|
162
236
|
<OText size={12}>{parsePrice(cart?.delivery_price)}</OText>
|
|
163
237
|
</OSTable>
|
|
164
238
|
)}
|
|
239
|
+
{
|
|
240
|
+
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
|
|
241
|
+
<OSTable key={offer.id}>
|
|
242
|
+
<OSRow>
|
|
243
|
+
<OText size={12}>{offer.name}</OText>
|
|
244
|
+
{offer.rate_type === 1 && (
|
|
245
|
+
<OText size={12}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
246
|
+
)}
|
|
247
|
+
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
|
|
248
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
249
|
+
</TouchableOpacity>
|
|
250
|
+
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
|
|
251
|
+
<AntIcon name='closecircle' size={18} color={theme.colors.primary} />
|
|
252
|
+
</TouchableOpacity>
|
|
253
|
+
</OSRow>
|
|
254
|
+
<OText size={12}>
|
|
255
|
+
- {parsePrice(offer?.summary?.discount)}
|
|
256
|
+
</OText>
|
|
257
|
+
</OSTable>
|
|
258
|
+
))
|
|
259
|
+
}
|
|
165
260
|
{cart?.driver_tip > 0 && (
|
|
166
261
|
<OSTable>
|
|
167
262
|
<OText size={12}>
|
|
@@ -201,7 +296,7 @@ const OrderSummaryUI = (props: any) => {
|
|
|
201
296
|
{t('TOTAL', 'Total')}
|
|
202
297
|
</OText>
|
|
203
298
|
<OText size={14} style={{ fontWeight: 'bold' }} >
|
|
204
|
-
{parsePrice(cart?.
|
|
299
|
+
{parsePrice(cart?.total >= 0 ? cart?.total : 0)}
|
|
205
300
|
</OText>
|
|
206
301
|
</OSTable>
|
|
207
302
|
</View>
|
|
@@ -243,11 +338,25 @@ const OrderSummaryUI = (props: any) => {
|
|
|
243
338
|
)}
|
|
244
339
|
<OModal
|
|
245
340
|
open={openTaxModal.open}
|
|
246
|
-
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
341
|
+
onClose={() => setOpenTaxModal({ open: false, data: null, type: '' })}
|
|
247
342
|
entireModal
|
|
343
|
+
title={`${openTaxModal.data?.name ||
|
|
344
|
+
t('INHERIT_FROM_BUSINESS', 'Inherit from business')} ${openTaxModal.data?.rate_type !== 2 ? `(${typeof openTaxModal.data?.rate === 'number' ? `${openTaxModal.data?.rate}%` : `${parsePrice(openTaxModal.data?.fixed ?? 0)} + ${openTaxModal.data?.percentage}%`})` : ''} `}
|
|
248
345
|
>
|
|
249
|
-
<TaxInformation
|
|
346
|
+
<TaxInformation
|
|
347
|
+
type={openTaxModal.type}
|
|
348
|
+
data={openTaxModal.data}
|
|
349
|
+
products={cart?.products}
|
|
350
|
+
/>
|
|
250
351
|
</OModal>
|
|
352
|
+
<OAlert
|
|
353
|
+
open={confirm.open}
|
|
354
|
+
title={confirm.title}
|
|
355
|
+
content={confirm.content}
|
|
356
|
+
onAccept={confirm.handleOnAccept}
|
|
357
|
+
onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
|
|
358
|
+
onClose={() => setConfirm({ ...confirm, open: false, title: null })}
|
|
359
|
+
/>
|
|
251
360
|
</>
|
|
252
361
|
)}
|
|
253
362
|
</OSContainer>
|
|
@@ -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))
|
|
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
|
}
|