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
|
@@ -44,6 +44,9 @@ import { USER_TYPE } from '../../config/constants';
|
|
|
44
44
|
import { GoogleMap } from '../GoogleMap';
|
|
45
45
|
import { verifyDecimals } from '../../utils';
|
|
46
46
|
import NavBar from '../NavBar';
|
|
47
|
+
import { OSRow } from '../OrderSummary/styles';
|
|
48
|
+
import { TaxInformation } from '../TaxInformation';
|
|
49
|
+
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
47
50
|
|
|
48
51
|
export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
49
52
|
const {
|
|
@@ -99,6 +102,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
99
102
|
business: false,
|
|
100
103
|
driver: false,
|
|
101
104
|
});
|
|
105
|
+
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
106
|
+
|
|
102
107
|
const { order, businessData } = props.order;
|
|
103
108
|
|
|
104
109
|
const getOrderStatus = (s: string) => {
|
|
@@ -327,6 +332,17 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
327
332
|
navigation.navigate('BottomTab');
|
|
328
333
|
};
|
|
329
334
|
|
|
335
|
+
const getIncludedTaxes = () => {
|
|
336
|
+
if (order?.taxes?.length === 0) {
|
|
337
|
+
return order.tax_type === 1 ? order?.summary?.tax ?? 0 : 0
|
|
338
|
+
} else {
|
|
339
|
+
return order?.taxes.reduce((taxIncluded: number, tax: any) => {
|
|
340
|
+
return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
|
|
341
|
+
}, 0)
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
|
|
330
346
|
useEffect(() => {
|
|
331
347
|
BackHandler.addEventListener('hardwareBackPress', handleArrowBack);
|
|
332
348
|
return () => {
|
|
@@ -678,7 +694,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
678
694
|
<Table>
|
|
679
695
|
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
680
696
|
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
|
|
681
|
-
|
|
697
|
+
{parsePrice(((order?.summary?.subtotal || order?.subtotal) + getIncludedTaxes()))}
|
|
682
698
|
</OText>
|
|
683
699
|
</Table>
|
|
684
700
|
{(order?.summary?.discount > 0 || order?.discount > 0) && (
|
|
@@ -699,17 +715,59 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
699
715
|
</OText>
|
|
700
716
|
</Table>
|
|
701
717
|
)}
|
|
702
|
-
{
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
718
|
+
{
|
|
719
|
+
order?.taxes?.length === 0 && order?.tax_type === 2 && (
|
|
720
|
+
<Table>
|
|
721
|
+
<OText size={12}>
|
|
722
|
+
{t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
|
|
723
|
+
</OText>
|
|
724
|
+
<OText size={12}>{parsePrice(order?.summary?.tax || 0)}</OText>
|
|
725
|
+
</Table>
|
|
726
|
+
)
|
|
727
|
+
}
|
|
728
|
+
{
|
|
729
|
+
order?.fees?.length === 0 && (
|
|
730
|
+
<Table>
|
|
731
|
+
<OText size={12}>
|
|
732
|
+
{t('SERVICE_FEE', 'Service fee')}
|
|
733
|
+
{`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
|
|
734
|
+
</OText>
|
|
735
|
+
<OText size={12}>{parsePrice(order?.summary?.service_fee || 0)}</OText>
|
|
736
|
+
</Table>
|
|
737
|
+
)
|
|
738
|
+
}
|
|
739
|
+
{
|
|
740
|
+
order?.taxes?.length > 0 && order?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
741
|
+
<Table key={tax.id}>
|
|
742
|
+
<OSRow>
|
|
743
|
+
<OText size={12} numberOfLines={1}>
|
|
744
|
+
{tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
745
|
+
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
746
|
+
</OText>
|
|
747
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })}>
|
|
748
|
+
<AntIcon name='exclamationcircleo' size={14} color={theme.colors.primary} />
|
|
749
|
+
</TouchableOpacity>
|
|
750
|
+
</OSRow>
|
|
751
|
+
<OText size={12}>{parsePrice(tax?.summary?.tax || 0)}</OText>
|
|
752
|
+
</Table>
|
|
753
|
+
))
|
|
754
|
+
}
|
|
755
|
+
{
|
|
756
|
+
order?.fees?.length > 0 && order?.fees?.filter((fee : any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
|
|
757
|
+
<Table key={fee.id}>
|
|
758
|
+
<OSRow>
|
|
759
|
+
<OText size={12} numberOfLines={1}>
|
|
760
|
+
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
761
|
+
({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
|
|
762
|
+
</OText>
|
|
763
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })}>
|
|
764
|
+
<AntIcon name='exclamationcircleo' size={14} color={theme.colors.primary} />
|
|
765
|
+
</TouchableOpacity>
|
|
766
|
+
</OSRow>
|
|
767
|
+
<OText size={12}>{parsePrice(fee?.fixed + fee?.summary?.percentage || 0)}</OText>
|
|
768
|
+
</Table>
|
|
769
|
+
))
|
|
770
|
+
}
|
|
713
771
|
{(order?.summary?.delivery_price > 0 ||
|
|
714
772
|
order?.deliveryFee > 0) && (
|
|
715
773
|
<Table>
|
|
@@ -735,17 +793,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
735
793
|
)}
|
|
736
794
|
</OText>
|
|
737
795
|
</Table>
|
|
738
|
-
<Table>
|
|
739
|
-
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
|
|
740
|
-
{t('SERVICE_FEE', 'Service Fee')}
|
|
741
|
-
{`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
|
|
742
|
-
</OText>
|
|
743
|
-
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
|
|
744
|
-
{parsePrice(
|
|
745
|
-
order?.summary?.service_fee || order?.serviceFee || 0,
|
|
746
|
-
)}
|
|
747
|
-
</OText>
|
|
748
|
-
</Table>
|
|
749
796
|
<Total>
|
|
750
797
|
<Table>
|
|
751
798
|
<OText size={20} lineHeight={30} weight={'600'} color={theme.colors.textNormal}>{t('TOTAL', 'Total')}</OText>
|
|
@@ -772,6 +819,13 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
772
819
|
onClose={() => handleCloseModal()}
|
|
773
820
|
/>
|
|
774
821
|
</OModal>
|
|
822
|
+
<OModal
|
|
823
|
+
open={openTaxModal.open}
|
|
824
|
+
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
825
|
+
entireModal
|
|
826
|
+
>
|
|
827
|
+
<TaxInformation data={openTaxModal.data} products={order?.products} />
|
|
828
|
+
</OModal>
|
|
775
829
|
</OrderDetailsContainer>
|
|
776
830
|
);
|
|
777
831
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { View } from 'react-native'
|
|
2
|
+
import { TouchableOpacity, View } from 'react-native'
|
|
3
3
|
import {
|
|
4
4
|
Cart,
|
|
5
5
|
useOrder,
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
OSContainer,
|
|
14
14
|
OSProductList,
|
|
15
15
|
OSBill,
|
|
16
|
-
OSTable
|
|
16
|
+
OSTable,
|
|
17
|
+
OSRow
|
|
17
18
|
} from './styles';
|
|
18
19
|
|
|
19
20
|
import { ProductItemAccordion } from '../ProductItemAccordion';
|
|
@@ -21,7 +22,9 @@ 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 { useTheme } from 'styled-components/native';
|
|
26
|
+
import { TaxInformation } from '../TaxInformation';
|
|
27
|
+
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
25
28
|
|
|
26
29
|
const OrderSummaryUI = (props: any) => {
|
|
27
30
|
const {
|
|
@@ -34,6 +37,7 @@ const OrderSummaryUI = (props: any) => {
|
|
|
34
37
|
isFromCheckout
|
|
35
38
|
} = props;
|
|
36
39
|
|
|
40
|
+
const theme = useTheme()
|
|
37
41
|
const [, t] = useLanguage();
|
|
38
42
|
const [{ configs }] = useConfig();
|
|
39
43
|
const [orderState] = useOrder();
|
|
@@ -41,6 +45,7 @@ const OrderSummaryUI = (props: any) => {
|
|
|
41
45
|
const [validationFields] = useValidationFields();
|
|
42
46
|
const [openProduct, setModalIsOpen] = useState(false)
|
|
43
47
|
const [curProduct, setCurProduct] = useState<any>(null)
|
|
48
|
+
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
44
49
|
|
|
45
50
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
|
|
46
51
|
|
|
@@ -59,6 +64,16 @@ const OrderSummaryUI = (props: any) => {
|
|
|
59
64
|
}
|
|
60
65
|
}
|
|
61
66
|
|
|
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
|
+
}
|
|
76
|
+
|
|
62
77
|
return (
|
|
63
78
|
<OSContainer>
|
|
64
79
|
{cart?.products?.length > 0 && (
|
|
@@ -83,9 +98,7 @@ const OrderSummaryUI = (props: any) => {
|
|
|
83
98
|
<OSBill>
|
|
84
99
|
<OSTable>
|
|
85
100
|
<OText size={12}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
86
|
-
<OText size={12}>{cart
|
|
87
|
-
? parsePrice((cart?.subtotal + cart?.tax) || 0)
|
|
88
|
-
: parsePrice(cart?.subtotal || 0)}</OText>
|
|
101
|
+
<OText size={12}>{parsePrice(cart?.subtotal + getIncludedTaxes())}</OText>
|
|
89
102
|
</OSTable>
|
|
90
103
|
{cart?.discount > 0 && cart?.total >= 0 && (
|
|
91
104
|
<OSTable>
|
|
@@ -100,15 +113,38 @@ const OrderSummaryUI = (props: any) => {
|
|
|
100
113
|
<OText size={12}>- {parsePrice(cart?.discount || 0)}</OText>
|
|
101
114
|
</OSTable>
|
|
102
115
|
)}
|
|
103
|
-
{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
116
|
+
{
|
|
117
|
+
cart?.taxes?.length > 0 && cart?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
118
|
+
<OSTable key={tax?.id}>
|
|
119
|
+
<OSRow>
|
|
120
|
+
<OText size={12} numberOfLines={1}>
|
|
121
|
+
{tax?.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
122
|
+
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
123
|
+
</OText>
|
|
124
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
|
|
125
|
+
<AntIcon name='exclamationcircleo' size={14} color={theme.colors.primary} />
|
|
126
|
+
</TouchableOpacity>
|
|
127
|
+
</OSRow>
|
|
128
|
+
<OText size={12}>{parsePrice(tax?.summary?.tax || 0)}</OText>
|
|
129
|
+
</OSTable>
|
|
130
|
+
))
|
|
131
|
+
}
|
|
132
|
+
{
|
|
133
|
+
cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
|
|
134
|
+
<OSTable key={fee.id}>
|
|
135
|
+
<OSRow>
|
|
136
|
+
<OText size={12} numberOfLines={1}>
|
|
137
|
+
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
138
|
+
({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
|
|
139
|
+
</OText>
|
|
140
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
|
|
141
|
+
<AntIcon name='exclamationcircleo' size={14} color={theme.colors.primary} />
|
|
142
|
+
</TouchableOpacity>
|
|
143
|
+
</OSRow>
|
|
144
|
+
<OText size={12}>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
|
|
145
|
+
</OSTable>
|
|
146
|
+
))
|
|
147
|
+
}
|
|
112
148
|
{orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
|
|
113
149
|
<OSTable>
|
|
114
150
|
<OText size={12}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
|
|
@@ -129,15 +165,6 @@ const OrderSummaryUI = (props: any) => {
|
|
|
129
165
|
<OText size={12}>{parsePrice(cart?.driver_tip)}</OText>
|
|
130
166
|
</OSTable>
|
|
131
167
|
)}
|
|
132
|
-
{cart?.service_fee > 0 && (
|
|
133
|
-
<OSTable>
|
|
134
|
-
<OText size={12}>
|
|
135
|
-
{t('SERVICE_FEE', 'Service Fee')}
|
|
136
|
-
{`(${verifyDecimals(cart?.business?.service_fee, parseNumber)}%)`}
|
|
137
|
-
</OText>
|
|
138
|
-
<OText size={12}>{parsePrice(cart?.service_fee)}</OText>
|
|
139
|
-
</OSTable>
|
|
140
|
-
)}
|
|
141
168
|
{isCouponEnabled && !isCartPending && (
|
|
142
169
|
<View>
|
|
143
170
|
<View style={{ paddingVertical: 5 }}>
|
|
@@ -180,6 +207,13 @@ const OrderSummaryUI = (props: any) => {
|
|
|
180
207
|
isFromCheckout={isFromCheckout}
|
|
181
208
|
/>
|
|
182
209
|
</OModal>
|
|
210
|
+
<OModal
|
|
211
|
+
open={openTaxModal.open}
|
|
212
|
+
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
213
|
+
entireModal
|
|
214
|
+
>
|
|
215
|
+
<TaxInformation data={openTaxModal.data} products={cart.products} />
|
|
216
|
+
</OModal>
|
|
183
217
|
</>
|
|
184
218
|
)}
|
|
185
219
|
</OSContainer>
|
|
@@ -86,7 +86,7 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
|
|
|
86
86
|
styles.container,
|
|
87
87
|
(isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle,
|
|
88
88
|
]}
|
|
89
|
-
onPress={() => onProductClick(product)}>
|
|
89
|
+
onPress={() => onProductClick?.(product)}>
|
|
90
90
|
<CardInfo>
|
|
91
91
|
<OText
|
|
92
92
|
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
|
+
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import { CContainer, CartContent, CheckoutAction } from './styles';
|
|
12
12
|
|
|
13
|
-
import { OSBill, OSTable, OSCoupon, OSTotal } from '../OrderSummary/styles';
|
|
13
|
+
import { OSBill, OSTable, OSCoupon, OSTotal, OSRow } from '../OrderSummary/styles';
|
|
14
14
|
|
|
15
15
|
import { ProductItemAccordion } from '../ProductItemAccordion';
|
|
16
16
|
import { BusinessItemAccordion } from '../BusinessItemAccordion';
|
|
@@ -21,6 +21,9 @@ import { ProductForm } from '../ProductForm';
|
|
|
21
21
|
import { UpsellingProducts } from '../UpsellingProducts';
|
|
22
22
|
import { verifyDecimals } from '../../utils';
|
|
23
23
|
import { useTheme } from 'styled-components/native';
|
|
24
|
+
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
25
|
+
import { TaxInformation } from '../TaxInformation';
|
|
26
|
+
import { TouchableOpacity } from 'react-native';
|
|
24
27
|
|
|
25
28
|
const CartUI = (props: any) => {
|
|
26
29
|
const {
|
|
@@ -47,6 +50,7 @@ const CartUI = (props: any) => {
|
|
|
47
50
|
const [curProduct, setCurProduct] = useState<any>(null)
|
|
48
51
|
const [openUpselling, setOpenUpselling] = useState(false)
|
|
49
52
|
const [canOpenUpselling, setCanOpenUpselling] = useState(false)
|
|
53
|
+
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
50
54
|
|
|
51
55
|
const isCartPending = cart?.status === 2
|
|
52
56
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
|
|
@@ -93,6 +97,16 @@ const CartUI = (props: any) => {
|
|
|
93
97
|
})
|
|
94
98
|
}
|
|
95
99
|
|
|
100
|
+
const getIncludedTaxes = () => {
|
|
101
|
+
if (cart?.taxes === null) {
|
|
102
|
+
return cart.business.tax_type === 1 ? cart?.tax : 0
|
|
103
|
+
} else {
|
|
104
|
+
return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
|
|
105
|
+
return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
|
|
106
|
+
}, 0)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
96
110
|
return (
|
|
97
111
|
<CContainer>
|
|
98
112
|
<BusinessItemAccordion
|
|
@@ -124,9 +138,7 @@ const CartUI = (props: any) => {
|
|
|
124
138
|
<OSTable>
|
|
125
139
|
<OText>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
126
140
|
<OText>
|
|
127
|
-
{cart
|
|
128
|
-
? parsePrice((cart?.subtotal + cart?.tax) || 0)
|
|
129
|
-
: parsePrice(cart?.subtotal || 0)}
|
|
141
|
+
{parsePrice(cart?.subtotal + getIncludedTaxes())}
|
|
130
142
|
</OText>
|
|
131
143
|
</OSTable>
|
|
132
144
|
{cart?.discount > 0 && cart?.total >= 0 && (
|
|
@@ -142,15 +154,38 @@ const CartUI = (props: any) => {
|
|
|
142
154
|
<OText>- {parsePrice(cart?.discount || 0)}</OText>
|
|
143
155
|
</OSTable>
|
|
144
156
|
)}
|
|
145
|
-
{
|
|
146
|
-
|
|
147
|
-
<
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
157
|
+
{
|
|
158
|
+
cart.taxes?.length > 0 && cart.taxes.filter((tax: any) => tax.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
159
|
+
<OSTable key={tax.id}>
|
|
160
|
+
<OSRow>
|
|
161
|
+
<OText numberOfLines={1} >
|
|
162
|
+
{tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
163
|
+
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
164
|
+
</OText>
|
|
165
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
|
|
166
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
167
|
+
</TouchableOpacity>
|
|
168
|
+
</OSRow>
|
|
169
|
+
<OText>{parsePrice(tax?.summary?.tax || 0)}</OText>
|
|
170
|
+
</OSTable>
|
|
171
|
+
))
|
|
172
|
+
}
|
|
173
|
+
{
|
|
174
|
+
cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any) => (
|
|
175
|
+
<OSTable key={fee?.id}>
|
|
176
|
+
<OSRow>
|
|
177
|
+
<OText numberOfLines={1}>
|
|
178
|
+
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
179
|
+
({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
|
|
180
|
+
</OText>
|
|
181
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
|
|
182
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
183
|
+
</TouchableOpacity>
|
|
184
|
+
</OSRow>
|
|
185
|
+
<OText>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
|
|
186
|
+
</OSTable>
|
|
187
|
+
))
|
|
188
|
+
}
|
|
154
189
|
{orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
|
|
155
190
|
<OSTable>
|
|
156
191
|
<OText>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
|
|
@@ -202,7 +237,7 @@ const CartUI = (props: any) => {
|
|
|
202
237
|
</OSTotal>
|
|
203
238
|
</OSBill>
|
|
204
239
|
)}
|
|
205
|
-
</CartContent>
|
|
240
|
+
</CartContent>
|
|
206
241
|
{cart?.valid_products && (
|
|
207
242
|
<CheckoutAction>
|
|
208
243
|
<OButton
|
|
@@ -254,6 +289,13 @@ const CartUI = (props: any) => {
|
|
|
254
289
|
setCanOpenUpselling={setCanOpenUpselling}
|
|
255
290
|
/>
|
|
256
291
|
)}
|
|
292
|
+
<OModal
|
|
293
|
+
open={openTaxModal.open}
|
|
294
|
+
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
295
|
+
entireModal
|
|
296
|
+
>
|
|
297
|
+
<TaxInformation data={openTaxModal.data} products={cart.products} />
|
|
298
|
+
</OModal>
|
|
257
299
|
</CContainer>
|
|
258
300
|
)
|
|
259
301
|
}
|
|
@@ -45,6 +45,9 @@ import { GoogleMap } from '../GoogleMap'
|
|
|
45
45
|
import { verifyDecimals } from '../../utils'
|
|
46
46
|
import { useTheme } from 'styled-components/native'
|
|
47
47
|
import MaterialComIcon from 'react-native-vector-icons/MaterialCommunityIcons'
|
|
48
|
+
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
49
|
+
import { OSRow } from '../OrderSummary/styles';
|
|
50
|
+
import { TaxInformation } from '../TaxInformation';
|
|
48
51
|
|
|
49
52
|
export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
50
53
|
const {
|
|
@@ -63,7 +66,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
63
66
|
|
|
64
67
|
const styles = StyleSheet.create({
|
|
65
68
|
statusBar: {
|
|
66
|
-
transform: [{scaleX: I18nManager.isRTL ? -1 : 1}],
|
|
69
|
+
transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
|
|
67
70
|
height: 10,
|
|
68
71
|
},
|
|
69
72
|
logo: {
|
|
@@ -85,9 +88,11 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
85
88
|
const [{ user }] = useSession()
|
|
86
89
|
const [{ configs }] = useConfig()
|
|
87
90
|
const [, { refreshOrderOptions }] = useOrder()
|
|
88
|
-
const [openModalForBusiness,setOpenModalForBusiness] = useState(false)
|
|
89
|
-
const [openModalForDriver,setOpenModalForDriver] = useState(false)
|
|
91
|
+
const [openModalForBusiness, setOpenModalForBusiness] = useState(false)
|
|
92
|
+
const [openModalForDriver, setOpenModalForDriver] = useState(false)
|
|
90
93
|
const [unreadAlert, setUnreadAlert] = useState({ business: false, driver: false })
|
|
94
|
+
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
95
|
+
|
|
91
96
|
const { order, businessData } = props.order
|
|
92
97
|
|
|
93
98
|
const getOrderStatus = (s: string) => {
|
|
@@ -152,12 +157,22 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
152
157
|
navigation?.canGoBack() && navigation.goBack();
|
|
153
158
|
return
|
|
154
159
|
}
|
|
155
|
-
if(goToBusinessList){
|
|
160
|
+
if (goToBusinessList) {
|
|
156
161
|
refreshOrderOptions()
|
|
157
162
|
}
|
|
158
163
|
navigation.navigate('BottomTab');
|
|
159
164
|
}
|
|
160
165
|
|
|
166
|
+
const getIncludedTaxes = () => {
|
|
167
|
+
if (order?.taxes?.length === 0) {
|
|
168
|
+
return order.tax_type === 1 ? order?.summary?.tax ?? 0 : 0
|
|
169
|
+
} else {
|
|
170
|
+
return order?.taxes.reduce((taxIncluded: number, tax: any) => {
|
|
171
|
+
return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
|
|
172
|
+
}, 0)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
161
176
|
useEffect(() => {
|
|
162
177
|
BackHandler.addEventListener('hardwareBackPress', handleArrowBack);
|
|
163
178
|
return () => {
|
|
@@ -202,7 +217,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
202
217
|
</Header>
|
|
203
218
|
<Spinner visible={!order || Object.keys(order).length === 0} />
|
|
204
219
|
{order && Object.keys(order).length > 0 && (
|
|
205
|
-
<>
|
|
220
|
+
<>
|
|
206
221
|
<OrderContent>
|
|
207
222
|
<OrderBusiness>
|
|
208
223
|
<View
|
|
@@ -303,7 +318,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
303
318
|
<OrderBill>
|
|
304
319
|
<Table>
|
|
305
320
|
<OText>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
306
|
-
<OText>{parsePrice(order?.summary?.subtotal || order?.subtotal)}</OText>
|
|
321
|
+
<OText>{parsePrice(((order?.summary?.subtotal || order?.subtotal) + getIncludedTaxes()))}</OText>
|
|
307
322
|
</Table>
|
|
308
323
|
{(order?.summary?.discount > 0 || order?.discount > 0) && (
|
|
309
324
|
<Table>
|
|
@@ -318,15 +333,59 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
318
333
|
<OText>- {parsePrice(order?.summary?.discount || order?.discount)}</OText>
|
|
319
334
|
</Table>
|
|
320
335
|
)}
|
|
321
|
-
{
|
|
322
|
-
|
|
323
|
-
<
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
336
|
+
{
|
|
337
|
+
order?.taxes?.length === 0 && order?.tax_type === 2 && (
|
|
338
|
+
<Table>
|
|
339
|
+
<OText>
|
|
340
|
+
{t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
|
|
341
|
+
</OText>
|
|
342
|
+
<OText>{parsePrice(order?.summary?.tax || 0)}</OText>
|
|
343
|
+
</Table>
|
|
344
|
+
)
|
|
345
|
+
}
|
|
346
|
+
{
|
|
347
|
+
order?.fees?.length === 0 && (
|
|
348
|
+
<Table>
|
|
349
|
+
<OText>
|
|
350
|
+
{t('SERVICE_FEE', 'Service fee')}
|
|
351
|
+
{`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
|
|
352
|
+
</OText>
|
|
353
|
+
<OText>{parsePrice(order?.summary?.service_fee || 0)}</OText>
|
|
354
|
+
</Table>
|
|
355
|
+
)
|
|
356
|
+
}
|
|
357
|
+
{
|
|
358
|
+
order?.taxes?.length > 0 && order?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
359
|
+
<Table key={tax.id}>
|
|
360
|
+
<OSRow>
|
|
361
|
+
<OText numberOfLines={1}>
|
|
362
|
+
{tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
363
|
+
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
364
|
+
</OText>
|
|
365
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })}>
|
|
366
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
367
|
+
</TouchableOpacity>
|
|
368
|
+
</OSRow>
|
|
369
|
+
<OText>{parsePrice(tax?.summary?.tax || 0)}</OText>
|
|
370
|
+
</Table>
|
|
371
|
+
))
|
|
372
|
+
}
|
|
373
|
+
{
|
|
374
|
+
order?.fees?.length > 0 && order?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
|
|
375
|
+
<Table key={fee.id}>
|
|
376
|
+
<OSRow>
|
|
377
|
+
<OText numberOfLines={1}>
|
|
378
|
+
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
379
|
+
({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
|
|
380
|
+
</OText>
|
|
381
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })}>
|
|
382
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
383
|
+
</TouchableOpacity>
|
|
384
|
+
</OSRow>
|
|
385
|
+
<OText>{parsePrice(fee?.fixed + fee?.summary?.percentage || 0)}</OText>
|
|
386
|
+
</Table>
|
|
387
|
+
))
|
|
388
|
+
}
|
|
330
389
|
{(order?.summary?.delivery_price > 0 || order?.deliveryFee > 0) && (
|
|
331
390
|
<Table>
|
|
332
391
|
<OText>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
|
|
@@ -345,13 +404,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
345
404
|
</OText>
|
|
346
405
|
<OText>{parsePrice(order?.summary?.driver_tip || order?.totalDriverTip)}</OText>
|
|
347
406
|
</Table>
|
|
348
|
-
<Table>
|
|
349
|
-
<OText>
|
|
350
|
-
{t('SERVICE_FEE', 'Service Fee')}
|
|
351
|
-
{`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
|
|
352
|
-
</OText>
|
|
353
|
-
<OText>{parsePrice(order?.summary?.service_fee || order?.serviceFee || 0)}</OText>
|
|
354
|
-
</Table>
|
|
355
407
|
<Total>
|
|
356
408
|
<Table>
|
|
357
409
|
<OText style={styles.textBold}>{t('TOTAL', 'Total')}</OText>
|
|
@@ -428,6 +480,13 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
428
480
|
setMessages={setMessages}
|
|
429
481
|
/>
|
|
430
482
|
</OModal>
|
|
483
|
+
<OModal
|
|
484
|
+
open={openTaxModal.open}
|
|
485
|
+
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
486
|
+
entireModal
|
|
487
|
+
>
|
|
488
|
+
<TaxInformation data={openTaxModal.data} products={order?.products} />
|
|
489
|
+
</OModal>
|
|
431
490
|
</OrderDetailsContainer>
|
|
432
491
|
)
|
|
433
492
|
}
|