ordering-ui-react-native 0.14.34 → 0.14.36-release
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 +2 -2
- package/src/components/BusinessItemAccordion/index.tsx +2 -2
- package/src/components/BusinessProductsListing/index.tsx +10 -26
- package/src/components/Cart/index.tsx +136 -62
- package/src/components/Cart/styles.tsx +7 -0
- package/src/components/Checkout/index.tsx +10 -6
- package/src/components/OrderDetails/index.tsx +102 -34
- package/src/components/OrderDetails/styles.tsx +7 -0
- package/src/components/OrderSummary/index.tsx +142 -58
- package/src/components/OrderSummary/styles.tsx +10 -2
- package/src/components/ProductForm/index.tsx +6 -8
- package/src/components/SingleProductCard/index.tsx +1 -1
- package/src/components/StripeElementsForm/index.tsx +28 -13
- package/src/components/TaxInformation/index.tsx +58 -26
- package/src/components/UpsellingProducts/index.tsx +13 -31
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/navigators/HomeNavigator.tsx +6 -0
- package/src/pages/ProductDetails.tsx +55 -0
- package/src/types/index.tsx +2 -0
- package/src/types/react-native-color-matrix-image-filters/index.d.ts +1 -0
- package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
- package/themes/kiosk/src/components/Cart/index.tsx +14 -21
- package/themes/kiosk/src/components/CartItem/index.tsx +9 -7
- package/themes/kiosk/src/components/CustomerName/index.tsx +2 -1
- package/themes/kiosk/src/components/Intro/index.tsx +4 -4
- package/themes/kiosk/src/components/OptionCard/index.tsx +11 -6
- package/themes/kiosk/src/components/PaymentOptions/index.tsx +46 -44
- package/themes/original/index.tsx +4 -0
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -9
- package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -2
- package/themes/original/src/components/BusinessPreorder/index.tsx +37 -35
- package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +35 -0
- package/themes/original/src/components/BusinessProductsListing/index.tsx +22 -49
- package/themes/original/src/components/BusinessesListing/index.tsx +100 -75
- package/themes/original/src/components/Cart/index.tsx +129 -52
- package/themes/original/src/components/Cart/styles.tsx +8 -1
- package/themes/original/src/components/Checkout/index.tsx +2 -0
- package/themes/original/src/components/FacebookLogin/index.tsx +20 -5
- package/themes/original/src/components/Help/index.tsx +1 -1
- package/themes/original/src/components/Home/index.tsx +5 -3
- package/themes/original/src/components/MessageListing/index.tsx +4 -2
- package/themes/original/src/components/OrderDetails/index.tsx +117 -43
- package/themes/original/src/components/OrderDetails/styles.tsx +8 -1
- package/themes/original/src/components/OrderSummary/index.tsx +141 -51
- package/themes/original/src/components/OrderSummary/styles.tsx +7 -0
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
- package/themes/original/src/components/ProductForm/index.tsx +67 -77
- package/themes/original/src/components/ProductForm/styles.tsx +9 -2
- package/themes/original/src/components/SingleProductCard/index.tsx +21 -11
- package/themes/original/src/components/SingleProductCard/styles.tsx +4 -0
- package/themes/original/src/components/StripeElementsForm/index.tsx +28 -13
- package/themes/original/src/components/TaxInformation/index.tsx +59 -27
- package/themes/original/src/components/UpsellingProducts/index.tsx +85 -83
- package/themes/original/src/types/index.tsx +6 -0
|
@@ -5,11 +5,11 @@ import { StyleSheet, View } from 'react-native';
|
|
|
5
5
|
import { OButton, OIcon, OText } from '../shared';
|
|
6
6
|
import { LanguageSelector } from '../LanguageSelector';
|
|
7
7
|
import { TouchableOpacity } from 'react-native-gesture-handler';
|
|
8
|
-
import { useWindowDimensions } from 'react-native';
|
|
8
|
+
import { useWindowDimensions, Platform } from 'react-native';
|
|
9
9
|
|
|
10
10
|
export const Home = (props: any) => {
|
|
11
11
|
const { onNavigationRedirect } = props;
|
|
12
|
-
const { width } = useWindowDimensions();
|
|
12
|
+
const { width, height } = useWindowDimensions();
|
|
13
13
|
const [, t] = useLanguage();
|
|
14
14
|
const [orderState] = useOrder();
|
|
15
15
|
|
|
@@ -18,7 +18,9 @@ export const Home = (props: any) => {
|
|
|
18
18
|
return (
|
|
19
19
|
<View style={styles.container}>
|
|
20
20
|
<View>
|
|
21
|
-
<
|
|
21
|
+
<View style={{paddingTop: (height <= 756 && Platform.OS !== 'ios') ? (height * 0.05) : 0 }}>
|
|
22
|
+
<LanguageSelector />
|
|
23
|
+
</View>
|
|
22
24
|
<OIcon
|
|
23
25
|
src={theme.images.logos.logotypeInvert}
|
|
24
26
|
style={{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react'
|
|
2
|
-
import { useLanguage, useOrder, ToastType, useToast, OrderList, OrderDetails as OrderDetailsConTableoller } from 'ordering-components/native'
|
|
2
|
+
import { useLanguage, useOrder, ToastType, useToast, OrderList, OrderDetails as OrderDetailsConTableoller, useBusiness } from 'ordering-components/native'
|
|
3
3
|
import { useTheme } from 'styled-components/native';
|
|
4
4
|
import { useFocusEffect } from '@react-navigation/native'
|
|
5
5
|
import { OText, OModal } from '../shared'
|
|
@@ -214,6 +214,7 @@ const OrderMessageUI = (props: any) => {
|
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
export const OrderListing = (props: OrdersOptionParams) => {
|
|
217
|
+
const [businessState] = useBusiness();
|
|
217
218
|
const OrderListingProps = {
|
|
218
219
|
...props,
|
|
219
220
|
UIComponent: OrdersOptionUI,
|
|
@@ -224,6 +225,7 @@ export const OrderListing = (props: OrdersOptionParams) => {
|
|
|
224
225
|
pageSize: 10,
|
|
225
226
|
controlType: 'infinity'
|
|
226
227
|
},
|
|
228
|
+
businessId: businessState?.business?.id,
|
|
227
229
|
profileMessages: true,
|
|
228
230
|
orderBy: 'last_direct_message_at',
|
|
229
231
|
orderDirection: 'asc'
|
|
@@ -287,6 +289,7 @@ export const MessageListing = (props: MessageListingParams) => {
|
|
|
287
289
|
setSelectedOrderId={setSelectedOrderId}
|
|
288
290
|
setOrderList={setOrderListStatus}
|
|
289
291
|
setOpenMessges={setOpenMessges}
|
|
292
|
+
franchiseId={props.franchiseId}
|
|
290
293
|
/>
|
|
291
294
|
{openMessages && seletedOrder && (
|
|
292
295
|
<OModal
|
|
@@ -304,4 +307,3 @@ export const MessageListing = (props: MessageListingParams) => {
|
|
|
304
307
|
</MessageListingWrapper>
|
|
305
308
|
)
|
|
306
309
|
}
|
|
307
|
-
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
Icons,
|
|
36
36
|
OrderDriver,
|
|
37
37
|
Map,
|
|
38
|
+
Divider,
|
|
38
39
|
} from './styles';
|
|
39
40
|
import { OButton, OIcon, OModal, OText } from '../shared';
|
|
40
41
|
import { ProductItemAccordion } from '../ProductItemAccordion';
|
|
@@ -100,7 +101,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
100
101
|
business: false,
|
|
101
102
|
driver: false,
|
|
102
103
|
});
|
|
103
|
-
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false,
|
|
104
|
+
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, tax: null, type: '' })
|
|
104
105
|
|
|
105
106
|
const { order, businessData } = props.order;
|
|
106
107
|
|
|
@@ -349,6 +350,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
349
350
|
}
|
|
350
351
|
}
|
|
351
352
|
|
|
353
|
+
const getIncludedTaxesDiscounts = () => {
|
|
354
|
+
return order?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
|
|
355
|
+
}
|
|
356
|
+
|
|
352
357
|
const handleClickOrderReview = (order: any) => {
|
|
353
358
|
navigation.navigate(
|
|
354
359
|
'ReviewOrder',
|
|
@@ -527,7 +532,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
527
532
|
onPress={() => order?.business?.cellphone &&
|
|
528
533
|
Linking.openURL(`tel:${order?.business?.cellphone}`)
|
|
529
534
|
}
|
|
530
|
-
style={{ paddingEnd: 5 }}
|
|
535
|
+
style={{ paddingEnd: 5 }}
|
|
536
|
+
>
|
|
531
537
|
<OIcon
|
|
532
538
|
src={theme.images.general.phone}
|
|
533
539
|
width={16}
|
|
@@ -611,7 +617,9 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
611
617
|
<OText size={16} style={{ textAlign: 'left' }} color={theme.colors.textNormal}>
|
|
612
618
|
{t('DELIVERY_PREFERENCE', 'Delivery Preference')}
|
|
613
619
|
</OText>
|
|
614
|
-
<OText size={12} style={{ textAlign: 'left' }} color={theme.colors.textNormal}>
|
|
620
|
+
<OText size={12} style={{ textAlign: 'left' }} color={theme.colors.textNormal}>
|
|
621
|
+
{order?.delivery_option?.name ? t(order?.delivery_option?.name.toUpperCase().replace(/\s/g, '_')) : t('EITHER_WAY', 'Either way')}
|
|
622
|
+
</OText>
|
|
615
623
|
</View>
|
|
616
624
|
)}
|
|
617
625
|
{order?.comment && (
|
|
@@ -728,10 +736,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
728
736
|
<Table>
|
|
729
737
|
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
730
738
|
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
|
|
731
|
-
{parsePrice(((order?.summary?.subtotal
|
|
739
|
+
{parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()))}
|
|
732
740
|
</OText>
|
|
733
741
|
</Table>
|
|
734
|
-
{(order?.summary?.discount > 0
|
|
742
|
+
{(order?.summary?.discount > 0 ?? order?.discount > 0) && order?.offers?.length === 0 && (
|
|
735
743
|
<Table>
|
|
736
744
|
{order?.offer_type === 1 ? (
|
|
737
745
|
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
|
|
@@ -749,24 +757,53 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
749
757
|
</OText>
|
|
750
758
|
</Table>
|
|
751
759
|
)}
|
|
760
|
+
{
|
|
761
|
+
order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
|
|
762
|
+
<Table key={offer.id}>
|
|
763
|
+
<OSRow>
|
|
764
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal} numberOfLines={1}>
|
|
765
|
+
{offer.name}
|
|
766
|
+
{offer.rate_type === 1 && (
|
|
767
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
768
|
+
)}
|
|
769
|
+
</OText>
|
|
770
|
+
<TouchableOpacity style={{ marginLeft: 5 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
|
|
771
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
772
|
+
</TouchableOpacity>
|
|
773
|
+
</OSRow>
|
|
774
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
775
|
+
</Table>
|
|
776
|
+
))
|
|
777
|
+
}
|
|
778
|
+
<Divider />
|
|
779
|
+
{order?.summary?.subtotal_with_discount > 0 && order?.summary?.discount > 0 && order?.summary?.total >= 0 && (
|
|
780
|
+
<Table>
|
|
781
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
|
|
782
|
+
{order?.tax_type === 1 ? (
|
|
783
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{parsePrice((order?.summary?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0))}</OText>
|
|
784
|
+
) : (
|
|
785
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{parsePrice(order?.summary?.subtotal_with_discount ?? 0)}</OText>
|
|
786
|
+
)}
|
|
787
|
+
</Table>
|
|
788
|
+
)}
|
|
752
789
|
{
|
|
753
790
|
order?.taxes?.length === 0 && order?.tax_type === 2 && (
|
|
754
791
|
<Table>
|
|
755
|
-
<OText size={12}>
|
|
792
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
|
|
756
793
|
{t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
|
|
757
794
|
</OText>
|
|
758
|
-
<OText size={12}>{parsePrice(order?.summary?.tax || 0)}</OText>
|
|
795
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{parsePrice(order?.summary?.tax || 0)}</OText>
|
|
759
796
|
</Table>
|
|
760
797
|
)
|
|
761
798
|
}
|
|
762
799
|
{
|
|
763
800
|
order?.fees?.length === 0 && (
|
|
764
801
|
<Table>
|
|
765
|
-
<OText size={12}>
|
|
802
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
|
|
766
803
|
{t('SERVICE_FEE', 'Service fee')}
|
|
767
804
|
{`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
|
|
768
805
|
</OText>
|
|
769
|
-
<OText size={12}>{parsePrice(order?.summary?.service_fee || 0)}</OText>
|
|
806
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{parsePrice(order?.summary?.service_fee || 0)}</OText>
|
|
770
807
|
</Table>
|
|
771
808
|
)
|
|
772
809
|
}
|
|
@@ -774,15 +811,15 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
774
811
|
order?.taxes?.length > 0 && order?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
775
812
|
<Table key={tax.id}>
|
|
776
813
|
<OSRow>
|
|
777
|
-
<OText size={12} numberOfLines={1}>
|
|
814
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal} numberOfLines={1}>
|
|
778
815
|
{tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
779
816
|
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
780
817
|
</OText>
|
|
781
|
-
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })}>
|
|
818
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax, type: 'tax' })}>
|
|
782
819
|
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
783
820
|
</TouchableOpacity>
|
|
784
821
|
</OSRow>
|
|
785
|
-
<OText size={12}>{parsePrice(tax?.summary?.tax
|
|
822
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
|
|
786
823
|
</Table>
|
|
787
824
|
))
|
|
788
825
|
}
|
|
@@ -790,53 +827,84 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
790
827
|
order?.fees?.length > 0 && order?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
|
|
791
828
|
<Table key={fee.id}>
|
|
792
829
|
<OSRow>
|
|
793
|
-
<OText size={12} numberOfLines={1}>
|
|
830
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal} numberOfLines={1}>
|
|
794
831
|
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
795
832
|
({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
|
|
796
833
|
</OText>
|
|
797
|
-
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })}>
|
|
834
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })}>
|
|
798
835
|
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
799
836
|
</TouchableOpacity>
|
|
800
837
|
</OSRow>
|
|
801
|
-
<OText size={12}>{parsePrice(fee?.fixed + fee?.summary?.percentage
|
|
838
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
|
|
802
839
|
</Table>
|
|
803
840
|
))
|
|
804
841
|
}
|
|
805
|
-
{
|
|
806
|
-
order?.
|
|
807
|
-
<Table>
|
|
808
|
-
<
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
842
|
+
{
|
|
843
|
+
order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
|
|
844
|
+
<Table key={offer.id}>
|
|
845
|
+
<OSRow>
|
|
846
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal} numberOfLines={1}>
|
|
847
|
+
{offer.name}
|
|
848
|
+
{offer.rate_type === 1 && (
|
|
849
|
+
<OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
850
|
+
)}
|
|
851
|
+
</OText>
|
|
852
|
+
<TouchableOpacity style={{ marginLeft: 5 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
|
|
853
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
854
|
+
</TouchableOpacity>
|
|
855
|
+
</OSRow>
|
|
856
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
814
857
|
</Table>
|
|
815
|
-
)
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
{
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
{
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
858
|
+
))
|
|
859
|
+
}
|
|
860
|
+
{order?.summary?.delivery_price > 0 && (
|
|
861
|
+
<Table>
|
|
862
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
|
|
863
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{parsePrice(order?.summary?.delivery_price)}</OText>
|
|
864
|
+
</Table>
|
|
865
|
+
)}
|
|
866
|
+
{
|
|
867
|
+
order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
|
|
868
|
+
<Table key={offer.id}>
|
|
869
|
+
<OSRow>
|
|
870
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal} numberOfLines={1}>
|
|
871
|
+
{offer.name}
|
|
872
|
+
{offer.rate_type === 1 && (
|
|
873
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
874
|
+
)}
|
|
875
|
+
</OText>
|
|
876
|
+
<TouchableOpacity style={{ marginLeft: 5 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
|
|
877
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
878
|
+
</TouchableOpacity>
|
|
879
|
+
</OSRow>
|
|
880
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
881
|
+
</Table>
|
|
882
|
+
))
|
|
883
|
+
}
|
|
884
|
+
{order?.summary?.driver_tip > 0 && (
|
|
885
|
+
<Table>
|
|
886
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
|
|
887
|
+
{t('DRIVER_TIP', 'Driver tip')}
|
|
888
|
+
{order?.summary?.driver_tip > 0 &&
|
|
889
|
+
parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
|
|
890
|
+
!parseInt(configs?.driver_tip_use_custom?.value, 10) &&
|
|
891
|
+
(
|
|
892
|
+
`(${verifyDecimals(order?.summary?.driver_tip, parseNumber)}%)`
|
|
893
|
+
)}
|
|
894
|
+
</OText>
|
|
895
|
+
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip)}</OText>
|
|
896
|
+
</Table>
|
|
897
|
+
)}
|
|
830
898
|
<Total>
|
|
831
899
|
<Table>
|
|
832
900
|
<OText size={20} lineHeight={30} weight={'600'} color={theme.colors.textNormal}>{t('TOTAL', 'Total')}</OText>
|
|
833
901
|
<OText size={20} lineHeight={30} weight={'600'} color={theme.colors.textNormal}>
|
|
834
|
-
{parsePrice(order?.summary?.total
|
|
902
|
+
{parsePrice(order?.summary?.total ?? order?.total)}
|
|
835
903
|
</OText>
|
|
836
904
|
</Table>
|
|
837
905
|
</Total>
|
|
838
906
|
{order?.payment_events?.length > 0 && (
|
|
839
|
-
<View style={{marginTop: 10}}>
|
|
907
|
+
<View style={{ marginTop: 10 }}>
|
|
840
908
|
<OText size={20} weight='bold' color={theme.colors.textNormal}>{t('PAYMENTS', 'Payments')}</OText>
|
|
841
909
|
<View
|
|
842
910
|
style={{
|
|
@@ -902,10 +970,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
902
970
|
</OModal>
|
|
903
971
|
<OModal
|
|
904
972
|
open={openTaxModal.open}
|
|
905
|
-
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
973
|
+
onClose={() => setOpenTaxModal({ open: false, data: null, type: '' })}
|
|
906
974
|
entireModal
|
|
975
|
+
title={`${openTaxModal.data?.name ||
|
|
976
|
+
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}%`})` : ''} `}
|
|
907
977
|
>
|
|
908
|
-
<TaxInformation
|
|
978
|
+
<TaxInformation
|
|
979
|
+
type={openTaxModal.type}
|
|
980
|
+
data={openTaxModal.data}
|
|
981
|
+
products={order?.products}
|
|
982
|
+
/>
|
|
909
983
|
</OModal>
|
|
910
984
|
</OrderDetailsContainer>
|
|
911
985
|
);
|
|
@@ -116,5 +116,12 @@ export const Map = styled.View`
|
|
|
116
116
|
width: 100%;
|
|
117
117
|
height: 250px;
|
|
118
118
|
margin-top: 20px;
|
|
119
|
-
border-radius: 20px
|
|
119
|
+
border-radius: 20px;
|
|
120
|
+
`
|
|
121
|
+
|
|
122
|
+
export const Divider = styled.View`
|
|
123
|
+
border-color: #EAEAEA;
|
|
124
|
+
border-width: 1px;
|
|
125
|
+
margin-top: 5px;
|
|
126
|
+
margin-bottom: 5px;
|
|
120
127
|
`
|
|
@@ -14,17 +14,18 @@ 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';
|
|
21
22
|
import { CouponControl } from '../CouponControl';
|
|
22
23
|
import { OInput, OModal, OText } from '../shared';
|
|
23
|
-
import { ProductForm } from '../ProductForm';
|
|
24
24
|
import { verifyDecimals } from '../../utils';
|
|
25
25
|
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
26
26
|
import { TaxInformation } from '../TaxInformation';
|
|
27
27
|
import { TouchableOpacity } from 'react-native';
|
|
28
|
+
import { OAlert } from '../../../../../src/components/shared'
|
|
28
29
|
|
|
29
30
|
const OrderSummaryUI = (props: any) => {
|
|
30
31
|
const {
|
|
@@ -35,7 +36,9 @@ const OrderSummaryUI = (props: any) => {
|
|
|
35
36
|
isCartPending,
|
|
36
37
|
isFromCheckout,
|
|
37
38
|
commentState,
|
|
38
|
-
handleChangeComment
|
|
39
|
+
handleChangeComment,
|
|
40
|
+
onNavigationRedirect,
|
|
41
|
+
handleRemoveOfferClick
|
|
39
42
|
} = props;
|
|
40
43
|
|
|
41
44
|
const theme = useTheme()
|
|
@@ -44,10 +47,8 @@ const OrderSummaryUI = (props: any) => {
|
|
|
44
47
|
const [orderState] = useOrder();
|
|
45
48
|
const [{ parsePrice, parseNumber }] = useUtils();
|
|
46
49
|
const [validationFields] = useValidationFields();
|
|
47
|
-
const [
|
|
48
|
-
const [
|
|
49
|
-
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
50
|
-
|
|
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 })
|
|
51
52
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
|
|
52
53
|
|
|
53
54
|
const handleDeleteClick = (product: any) => {
|
|
@@ -55,14 +56,15 @@ const OrderSummaryUI = (props: any) => {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
const handleEditProduct = (product: any) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
onNavigationRedirect('ProductDetails', {
|
|
60
|
+
isCartProduct: true,
|
|
61
|
+
productCart: product,
|
|
62
|
+
businessSlug: cart?.business?.slug,
|
|
63
|
+
businessId: cart?.business_id,
|
|
64
|
+
categoryId: product?.category_id,
|
|
65
|
+
productId: product?.id,
|
|
66
|
+
isFromCheckout: isFromCheckout,
|
|
67
|
+
})
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
const getIncludedTaxes = () => {
|
|
@@ -75,6 +77,22 @@ const OrderSummaryUI = (props: any) => {
|
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
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
|
+
|
|
78
96
|
const cart = orderState?.carts?.[`businessId:${props.cart.business_id}`]
|
|
79
97
|
|
|
80
98
|
const walletName: any = {
|
|
@@ -110,9 +128,11 @@ const OrderSummaryUI = (props: any) => {
|
|
|
110
128
|
<OSBill>
|
|
111
129
|
<OSTable>
|
|
112
130
|
<OText size={12}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
113
|
-
<OText size={12}>
|
|
131
|
+
<OText size={12}>
|
|
132
|
+
{parsePrice(cart?.subtotal + getIncludedTaxes())}
|
|
133
|
+
</OText>
|
|
114
134
|
</OSTable>
|
|
115
|
-
{cart?.discount > 0 && cart?.total >= 0 && (
|
|
135
|
+
{cart?.discount > 0 && cart?.total >= 0 && cart?.offers?.length === 0 && (
|
|
116
136
|
<OSTable>
|
|
117
137
|
{cart?.discount_type === 1 ? (
|
|
118
138
|
<OText size={12}>
|
|
@@ -126,34 +146,87 @@ const OrderSummaryUI = (props: any) => {
|
|
|
126
146
|
</OSTable>
|
|
127
147
|
)}
|
|
128
148
|
{
|
|
129
|
-
cart?.
|
|
130
|
-
<OSTable key={
|
|
149
|
+
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
|
|
150
|
+
<OSTable key={offer.id}>
|
|
131
151
|
<OSRow>
|
|
132
|
-
<OText size={12}
|
|
133
|
-
|
|
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')}{' '}
|
|
134
186
|
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
135
187
|
</OText>
|
|
136
|
-
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
|
|
137
|
-
<AntIcon name='exclamationcircleo' size={
|
|
188
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax, type: 'tax' })} >
|
|
189
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
138
190
|
</TouchableOpacity>
|
|
139
191
|
</OSRow>
|
|
140
|
-
<OText size={12}>{parsePrice(tax?.summary?.tax
|
|
192
|
+
<OText size={12}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
|
|
141
193
|
</OSTable>
|
|
142
194
|
))
|
|
143
195
|
}
|
|
144
196
|
{
|
|
145
|
-
cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))
|
|
146
|
-
<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}>
|
|
147
199
|
<OSRow>
|
|
148
200
|
<OText size={12} numberOfLines={1}>
|
|
149
201
|
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
150
|
-
({parsePrice(fee?.fixed)} + {fee
|
|
202
|
+
({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
|
|
151
203
|
</OText>
|
|
152
|
-
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
|
|
153
|
-
<AntIcon name='exclamationcircleo' size={
|
|
204
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
|
|
205
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
154
206
|
</TouchableOpacity>
|
|
155
207
|
</OSRow>
|
|
156
|
-
<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>
|
|
157
230
|
</OSTable>
|
|
158
231
|
))
|
|
159
232
|
}
|
|
@@ -163,6 +236,27 @@ const OrderSummaryUI = (props: any) => {
|
|
|
163
236
|
<OText size={12}>{parsePrice(cart?.delivery_price)}</OText>
|
|
164
237
|
</OSTable>
|
|
165
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
|
+
}
|
|
166
260
|
{cart?.driver_tip > 0 && (
|
|
167
261
|
<OSTable>
|
|
168
262
|
<OText size={12}>
|
|
@@ -202,7 +296,7 @@ const OrderSummaryUI = (props: any) => {
|
|
|
202
296
|
{t('TOTAL', 'Total')}
|
|
203
297
|
</OText>
|
|
204
298
|
<OText size={14} style={{ fontWeight: 'bold' }} >
|
|
205
|
-
{parsePrice(cart?.
|
|
299
|
+
{parsePrice(cart?.total >= 0 ? cart?.total : 0)}
|
|
206
300
|
</OText>
|
|
207
301
|
</OSTable>
|
|
208
302
|
</View>
|
|
@@ -242,31 +336,27 @@ const OrderSummaryUI = (props: any) => {
|
|
|
242
336
|
)}
|
|
243
337
|
</OSBill>
|
|
244
338
|
)}
|
|
245
|
-
<OModal
|
|
246
|
-
open={openProduct}
|
|
247
|
-
entireModal
|
|
248
|
-
customClose
|
|
249
|
-
onClose={() => setModalIsOpen(false)}
|
|
250
|
-
>
|
|
251
|
-
<ProductForm
|
|
252
|
-
isCartProduct
|
|
253
|
-
productCart={curProduct}
|
|
254
|
-
businessSlug={cart?.business?.slug}
|
|
255
|
-
businessId={cart?.business_id}
|
|
256
|
-
categoryId={curProduct?.category_id}
|
|
257
|
-
productId={curProduct?.id}
|
|
258
|
-
onSave={handlerProductAction}
|
|
259
|
-
onClose={() => setModalIsOpen(false)}
|
|
260
|
-
isFromCheckout={isFromCheckout}
|
|
261
|
-
/>
|
|
262
|
-
</OModal>
|
|
263
339
|
<OModal
|
|
264
340
|
open={openTaxModal.open}
|
|
265
|
-
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
341
|
+
onClose={() => setOpenTaxModal({ open: false, data: null, type: '' })}
|
|
266
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}%`})` : ''} `}
|
|
267
345
|
>
|
|
268
|
-
<TaxInformation
|
|
346
|
+
<TaxInformation
|
|
347
|
+
type={openTaxModal.type}
|
|
348
|
+
data={openTaxModal.data}
|
|
349
|
+
products={cart?.products}
|
|
350
|
+
/>
|
|
269
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
|
+
/>
|
|
270
360
|
</>
|
|
271
361
|
)}
|
|
272
362
|
</OSContainer>
|