ordering-ui-react-native 0.12.43 → 0.12.47
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/AppleLogin/index.tsx +145 -0
- package/src/components/AppleLogin/styles.tsx +22 -0
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Cart/index.tsx +56 -23
- package/src/components/LoginForm/index.tsx +34 -17
- 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/SignupForm/index.tsx +52 -35
- 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/components/UserFormDetails/index.tsx +0 -2
- package/src/navigators/BottomNavigator.tsx +1 -1
- package/src/types/index.tsx +7 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +12 -7
- 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
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { useTheme } from 'styled-components/native';
|
|
11
11
|
import { CContainer, 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';
|
|
@@ -20,6 +20,9 @@ import { OButton, OModal, OText } from '../shared';
|
|
|
20
20
|
import { ProductForm } from '../ProductForm';
|
|
21
21
|
import { UpsellingProducts } from '../UpsellingProducts';
|
|
22
22
|
import { verifyDecimals } from '../../utils';
|
|
23
|
+
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
24
|
+
import { TaxInformation } from '../TaxInformation';
|
|
25
|
+
import { TouchableOpacity } from 'react-native';
|
|
23
26
|
|
|
24
27
|
const CartUI = (props: any) => {
|
|
25
28
|
const {
|
|
@@ -46,6 +49,7 @@ const CartUI = (props: any) => {
|
|
|
46
49
|
const [curProduct, setCurProduct] = useState<any>(null)
|
|
47
50
|
const [openUpselling, setOpenUpselling] = useState(false)
|
|
48
51
|
const [canOpenUpselling, setCanOpenUpselling] = useState(false)
|
|
52
|
+
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
49
53
|
|
|
50
54
|
const isCartPending = cart?.status === 2
|
|
51
55
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
|
|
@@ -91,6 +95,16 @@ const CartUI = (props: any) => {
|
|
|
91
95
|
})
|
|
92
96
|
}
|
|
93
97
|
|
|
98
|
+
const getIncludedTaxes = () => {
|
|
99
|
+
if (cart?.taxes === null) {
|
|
100
|
+
return cart.business.tax_type === 1 ? cart?.tax : 0
|
|
101
|
+
} else {
|
|
102
|
+
return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
|
|
103
|
+
return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
|
|
104
|
+
}, 0)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
94
108
|
return (
|
|
95
109
|
<CContainer>
|
|
96
110
|
<BusinessItemAccordion
|
|
@@ -119,9 +133,7 @@ const CartUI = (props: any) => {
|
|
|
119
133
|
<OSTable>
|
|
120
134
|
<OText size={12} lineHeight={18}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
121
135
|
<OText size={12} lineHeight={18}>
|
|
122
|
-
|
|
123
|
-
? parsePrice((cart?.subtotal + cart?.tax) || 0)
|
|
124
|
-
: parsePrice(cart?.subtotal || 0)}
|
|
136
|
+
{parsePrice(cart?.subtotal + getIncludedTaxes())}
|
|
125
137
|
</OText>
|
|
126
138
|
</OSTable>
|
|
127
139
|
{cart?.discount > 0 && cart?.total >= 0 && (
|
|
@@ -137,15 +149,38 @@ const CartUI = (props: any) => {
|
|
|
137
149
|
<OText size={12} lineHeight={18}>- {parsePrice(cart?.discount || 0)}</OText>
|
|
138
150
|
</OSTable>
|
|
139
151
|
)}
|
|
140
|
-
{
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
152
|
+
{
|
|
153
|
+
cart.taxes?.length > 0 && cart.taxes.filter((tax: any) => tax.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
154
|
+
<OSTable key={tax.id}>
|
|
155
|
+
<OSRow>
|
|
156
|
+
<OText numberOfLines={1} >
|
|
157
|
+
{tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
158
|
+
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
159
|
+
</OText>
|
|
160
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
|
|
161
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
162
|
+
</TouchableOpacity>
|
|
163
|
+
</OSRow>
|
|
164
|
+
<OText>{parsePrice(tax?.summary?.tax || 0)}</OText>
|
|
165
|
+
</OSTable>
|
|
166
|
+
))
|
|
167
|
+
}
|
|
168
|
+
{
|
|
169
|
+
cart?.fees?.length > 0 && cart?.fees?.filter((fee : any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any) => (
|
|
170
|
+
<OSTable key={fee?.id}>
|
|
171
|
+
<OSRow>
|
|
172
|
+
<OText numberOfLines={1}>
|
|
173
|
+
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
174
|
+
({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
|
|
175
|
+
</OText>
|
|
176
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
|
|
177
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
178
|
+
</TouchableOpacity>
|
|
179
|
+
</OSRow>
|
|
180
|
+
<OText>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
|
|
181
|
+
</OSTable>
|
|
182
|
+
))
|
|
183
|
+
}
|
|
149
184
|
{orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
|
|
150
185
|
<OSTable>
|
|
151
186
|
<OText size={12} lineHeight={18}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
|
|
@@ -166,15 +201,6 @@ const CartUI = (props: any) => {
|
|
|
166
201
|
<OText size={12} lineHeight={18}>{parsePrice(cart?.driver_tip)}</OText>
|
|
167
202
|
</OSTable>
|
|
168
203
|
)}
|
|
169
|
-
{cart?.service_fee > 0 && (
|
|
170
|
-
<OSTable>
|
|
171
|
-
<OText size={12} lineHeight={18}>
|
|
172
|
-
{t('SERVICE_FEE', 'Service Fee')}
|
|
173
|
-
{`(${verifyDecimals(cart?.business?.service_fee, parseNumber)}%)`}
|
|
174
|
-
</OText>
|
|
175
|
-
<OText size={12} lineHeight={18}>{parsePrice(cart?.service_fee)}</OText>
|
|
176
|
-
</OSTable>
|
|
177
|
-
)}
|
|
178
204
|
{isCouponEnabled && !isCartPending && (
|
|
179
205
|
<OSTable>
|
|
180
206
|
<OSCoupon>
|
|
@@ -237,7 +263,13 @@ const CartUI = (props: any) => {
|
|
|
237
263
|
/>
|
|
238
264
|
|
|
239
265
|
</OModal>
|
|
240
|
-
|
|
266
|
+
<OModal
|
|
267
|
+
open={openTaxModal.open}
|
|
268
|
+
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
269
|
+
entireModal
|
|
270
|
+
>
|
|
271
|
+
<TaxInformation data={openTaxModal.data} products={cart.products} />
|
|
272
|
+
</OModal>
|
|
241
273
|
{openUpselling && (
|
|
242
274
|
<UpsellingProducts
|
|
243
275
|
handleUpsellingPage={handleUpsellingPage}
|
|
@@ -43,6 +43,9 @@ import { OrderDetailsParams } from '../../types';
|
|
|
43
43
|
import { USER_TYPE } from '../../config/constants';
|
|
44
44
|
import { GoogleMap } from '../GoogleMap';
|
|
45
45
|
import { verifyDecimals } from '../../utils';
|
|
46
|
+
import { OSRow } from '../OrderSummary/styles';
|
|
47
|
+
import { TaxInformation } from '../TaxInformation';
|
|
48
|
+
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
46
49
|
|
|
47
50
|
export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
48
51
|
const {
|
|
@@ -96,6 +99,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
96
99
|
business: false,
|
|
97
100
|
driver: false,
|
|
98
101
|
});
|
|
102
|
+
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
103
|
+
|
|
99
104
|
const { order, businessData } = props.order;
|
|
100
105
|
|
|
101
106
|
const getOrderStatus = (s: string) => {
|
|
@@ -324,6 +329,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
324
329
|
navigation.navigate('BottomTab');
|
|
325
330
|
};
|
|
326
331
|
|
|
332
|
+
const getIncludedTaxes = () => {
|
|
333
|
+
if (order?.taxes?.length === 0) {
|
|
334
|
+
return order.tax_type === 1 ? order?.summary?.tax ?? 0 : 0
|
|
335
|
+
} else {
|
|
336
|
+
return order?.taxes.reduce((taxIncluded: number, tax: any) => {
|
|
337
|
+
return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
|
|
338
|
+
}, 0)
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
327
342
|
useEffect(() => {
|
|
328
343
|
BackHandler.addEventListener('hardwareBackPress', handleArrowBack);
|
|
329
344
|
return () => {
|
|
@@ -658,7 +673,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
658
673
|
<Table>
|
|
659
674
|
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
660
675
|
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
|
|
661
|
-
|
|
676
|
+
{parsePrice(((order?.summary?.subtotal || order?.subtotal) + getIncludedTaxes()))}
|
|
662
677
|
</OText>
|
|
663
678
|
</Table>
|
|
664
679
|
{(order?.summary?.discount > 0 || order?.discount > 0) && (
|
|
@@ -679,17 +694,59 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
679
694
|
</OText>
|
|
680
695
|
</Table>
|
|
681
696
|
)}
|
|
682
|
-
{
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
697
|
+
{
|
|
698
|
+
order?.taxes?.length === 0 && order?.tax_type === 2 && (
|
|
699
|
+
<Table>
|
|
700
|
+
<OText size={12}>
|
|
701
|
+
{t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
|
|
702
|
+
</OText>
|
|
703
|
+
<OText>{parsePrice(order?.summary?.tax || 0)}</OText>
|
|
704
|
+
</Table>
|
|
705
|
+
)
|
|
706
|
+
}
|
|
707
|
+
{
|
|
708
|
+
order?.fees?.length === 0 && (
|
|
709
|
+
<Table>
|
|
710
|
+
<OText size={12}>
|
|
711
|
+
{t('SERVICE_FEE', 'Service fee')}
|
|
712
|
+
{`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
|
|
713
|
+
</OText>
|
|
714
|
+
<OText>{parsePrice(order?.summary?.service_fee || 0)}</OText>
|
|
715
|
+
</Table>
|
|
716
|
+
)
|
|
717
|
+
}
|
|
718
|
+
{
|
|
719
|
+
order?.taxes?.length > 0 && order?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
720
|
+
<Table key={tax.id}>
|
|
721
|
+
<OSRow>
|
|
722
|
+
<OText size={12} numberOfLines={1}>
|
|
723
|
+
{tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
724
|
+
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
725
|
+
</OText>
|
|
726
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })}>
|
|
727
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
728
|
+
</TouchableOpacity>
|
|
729
|
+
</OSRow>
|
|
730
|
+
<OText size={12}>{parsePrice(tax?.summary?.tax || 0)}</OText>
|
|
731
|
+
</Table>
|
|
732
|
+
))
|
|
733
|
+
}
|
|
734
|
+
{
|
|
735
|
+
order?.fees?.length > 0 && order?.fees?.filter((fee : any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
|
|
736
|
+
<Table key={fee.id}>
|
|
737
|
+
<OSRow>
|
|
738
|
+
<OText size={12} numberOfLines={1}>
|
|
739
|
+
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
740
|
+
({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
|
|
741
|
+
</OText>
|
|
742
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })}>
|
|
743
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
744
|
+
</TouchableOpacity>
|
|
745
|
+
</OSRow>
|
|
746
|
+
<OText size={12}>{parsePrice(fee?.fixed + fee?.summary?.percentage || 0)}</OText>
|
|
747
|
+
</Table>
|
|
748
|
+
))
|
|
749
|
+
}
|
|
693
750
|
{(order?.summary?.delivery_price > 0 ||
|
|
694
751
|
order?.deliveryFee > 0) && (
|
|
695
752
|
<Table>
|
|
@@ -715,17 +772,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
715
772
|
)}
|
|
716
773
|
</OText>
|
|
717
774
|
</Table>
|
|
718
|
-
|
|
719
|
-
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
|
|
720
|
-
{t('SERVICE_FEE', 'Service Fee')}
|
|
721
|
-
{`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
|
|
722
|
-
</OText>
|
|
723
|
-
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
|
|
724
|
-
{parsePrice(
|
|
725
|
-
order?.summary?.service_fee || order?.serviceFee || 0,
|
|
726
|
-
)}
|
|
727
|
-
</OText>
|
|
728
|
-
</Table>
|
|
775
|
+
|
|
729
776
|
<Total>
|
|
730
777
|
<Table>
|
|
731
778
|
<OText size={20} lineHeight={30} weight={'600'} color={theme.colors.textNormal}>{t('TOTAL', 'Total')}</OText>
|
|
@@ -752,6 +799,13 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
752
799
|
onClose={() => handleCloseModal()}
|
|
753
800
|
/>
|
|
754
801
|
</OModal>
|
|
802
|
+
<OModal
|
|
803
|
+
open={openTaxModal.open}
|
|
804
|
+
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
805
|
+
entireModal
|
|
806
|
+
>
|
|
807
|
+
<TaxInformation data={openTaxModal.data} products={order?.products} />
|
|
808
|
+
</OModal>
|
|
755
809
|
</OrderDetailsContainer>
|
|
756
810
|
);
|
|
757
811
|
};
|
|
@@ -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 { TaxInformation } from '../TaxInformation';
|
|
26
|
+
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
27
|
+
import { useTheme } from 'styled-components/native';
|
|
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={20} 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={20} 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, CheckoutAction, TotalCont } 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,7 +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
|
-
|
|
24
|
+
import { TouchableOpacity } from 'react-native';
|
|
25
|
+
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
26
|
+
import { TaxInformation } from '../TaxInformation';
|
|
25
27
|
const CartUI = (props: any) => {
|
|
26
28
|
const {
|
|
27
29
|
cart,
|
|
@@ -32,7 +34,7 @@ const CartUI = (props: any) => {
|
|
|
32
34
|
removeProduct,
|
|
33
35
|
handleCartOpen,
|
|
34
36
|
setIsCartsLoading,
|
|
35
|
-
|
|
37
|
+
isExpanded
|
|
36
38
|
} = props
|
|
37
39
|
|
|
38
40
|
const theme = useTheme()
|
|
@@ -46,6 +48,7 @@ const CartUI = (props: any) => {
|
|
|
46
48
|
const [curProduct, setCurProduct] = useState<any>(null)
|
|
47
49
|
const [openUpselling, setOpenUpselling] = useState(false)
|
|
48
50
|
const [canOpenUpselling, setCanOpenUpselling] = useState(false)
|
|
51
|
+
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
49
52
|
|
|
50
53
|
const isCartPending = cart?.status === 2
|
|
51
54
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
|
|
@@ -91,6 +94,16 @@ const CartUI = (props: any) => {
|
|
|
91
94
|
})
|
|
92
95
|
}
|
|
93
96
|
|
|
97
|
+
const getIncludedTaxes = () => {
|
|
98
|
+
if (cart?.taxes === null) {
|
|
99
|
+
return cart.business.tax_type === 1 ? cart?.tax : 0
|
|
100
|
+
} else {
|
|
101
|
+
return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
|
|
102
|
+
return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
|
|
103
|
+
}, 0)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
94
107
|
return (
|
|
95
108
|
<CContainer>
|
|
96
109
|
<BusinessItemAccordion
|
|
@@ -99,7 +112,7 @@ const CartUI = (props: any) => {
|
|
|
99
112
|
handleClearProducts={handleClearProducts}
|
|
100
113
|
handleCartOpen={handleCartOpen}
|
|
101
114
|
onNavigationRedirect={props.onNavigationRedirect}
|
|
102
|
-
|
|
115
|
+
isExpanded={isExpanded}
|
|
103
116
|
>
|
|
104
117
|
{cart?.products?.length > 0 && cart?.products.map((product: any) => (
|
|
105
118
|
<ProductItemAccordion
|
|
@@ -120,9 +133,7 @@ const CartUI = (props: any) => {
|
|
|
120
133
|
<OSTable>
|
|
121
134
|
<OText>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
122
135
|
<OText>
|
|
123
|
-
{cart
|
|
124
|
-
? parsePrice((cart?.subtotal + cart?.tax) || 0)
|
|
125
|
-
: parsePrice(cart?.subtotal || 0)}
|
|
136
|
+
{parsePrice(cart?.subtotal + getIncludedTaxes())}
|
|
126
137
|
</OText>
|
|
127
138
|
</OSTable>
|
|
128
139
|
{cart?.discount > 0 && cart?.total >= 0 && (
|
|
@@ -153,15 +164,38 @@ const CartUI = (props: any) => {
|
|
|
153
164
|
)}
|
|
154
165
|
</OSTable>
|
|
155
166
|
)}
|
|
156
|
-
{
|
|
157
|
-
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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 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={18} color={theme.colors.primary} />
|
|
177
|
+
</TouchableOpacity>
|
|
178
|
+
</OSRow>
|
|
179
|
+
<OText>{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 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={18} color={theme.colors.primary} />
|
|
193
|
+
</TouchableOpacity>
|
|
194
|
+
</OSRow>
|
|
195
|
+
<OText>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
|
|
196
|
+
</OSTable>
|
|
197
|
+
))
|
|
198
|
+
}
|
|
165
199
|
{orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
|
|
166
200
|
<OSTable>
|
|
167
201
|
<OText>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
|
|
@@ -255,7 +289,13 @@ const CartUI = (props: any) => {
|
|
|
255
289
|
/>
|
|
256
290
|
|
|
257
291
|
</OModal>
|
|
258
|
-
|
|
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>
|
|
259
299
|
{openUpselling && (
|
|
260
300
|
<UpsellingProducts
|
|
261
301
|
handleUpsellingPage={handleUpsellingPage}
|