ordering-ui-react-native 0.14.39 → 0.14.41-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/Cart/index.tsx +135 -42
- package/src/components/Cart/styles.tsx +7 -0
- package/src/components/Checkout/index.tsx +28 -166
- package/src/components/OrderDetails/index.tsx +102 -34
- package/src/components/OrderDetails/styles.tsx +7 -0
- package/src/components/OrderSummary/index.tsx +140 -37
- package/src/components/OrderSummary/styles.tsx +10 -2
- package/src/components/PaymentOptions/index.tsx +3 -1
- package/src/components/PaymentOptionsWebView/index.tsx +150 -0
- package/src/components/ProductForm/index.tsx +6 -6
- 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/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OIcon.tsx +4 -1
- package/src/index.tsx +2 -0
- package/src/navigators/HomeNavigator.tsx +6 -0
- package/src/pages/ProductDetails.tsx +55 -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/src/components/BusinessItemAccordion/index.tsx +12 -9
- package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -2
- package/themes/original/src/components/BusinessProductsListing/index.tsx +8 -4
- package/themes/original/src/components/BusinessesListing/index.tsx +100 -75
- package/themes/original/src/components/Cart/index.tsx +122 -24
- package/themes/original/src/components/Cart/styles.tsx +8 -1
- package/themes/original/src/components/Checkout/index.tsx +38 -3
- package/themes/original/src/components/Help/index.tsx +1 -1
- package/themes/original/src/components/MessageListing/index.tsx +4 -2
- package/themes/original/src/components/OrderDetails/index.tsx +114 -42
- package/themes/original/src/components/OrderDetails/styles.tsx +8 -1
- package/themes/original/src/components/OrderProgress/index.tsx +2 -1
- package/themes/original/src/components/OrderSummary/index.tsx +132 -23
- package/themes/original/src/components/OrderSummary/styles.tsx +7 -0
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
- package/themes/original/src/components/PaymentOptions/index.tsx +8 -2
- package/themes/original/src/components/ProductForm/index.tsx +61 -60
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +3 -2
- package/themes/original/src/components/SingleProductCard/index.tsx +36 -19
- 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 +26 -18
- package/themes/original/src/types/index.tsx +2 -0
|
@@ -38,7 +38,8 @@ import {
|
|
|
38
38
|
Icons,
|
|
39
39
|
OrderDriver,
|
|
40
40
|
Map,
|
|
41
|
-
LoadingWrapper
|
|
41
|
+
LoadingWrapper,
|
|
42
|
+
Divider
|
|
42
43
|
} from './styles'
|
|
43
44
|
import { OButton, OIcon, OModal, OText } from '../shared'
|
|
44
45
|
import { ProductItemAccordion } from '../ProductItemAccordion'
|
|
@@ -106,10 +107,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
106
107
|
const [unreadAlert, setUnreadAlert] = useState({ business: false, driver: false })
|
|
107
108
|
const [isReviewed, setIsReviewed] = useState(false)
|
|
108
109
|
const [openOrderCreating, setOpenOrderCreating] = useState(false)
|
|
109
|
-
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false,
|
|
110
|
+
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, tax: null, type: '' })
|
|
110
111
|
const { order, loading, businessData, error } = props.order
|
|
111
|
-
const isTaxIncluded = order?.tax_type === 1
|
|
112
|
-
|
|
113
112
|
|
|
114
113
|
const getOrderStatus = (s: string) => {
|
|
115
114
|
const status = parseInt(s)
|
|
@@ -209,6 +208,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
209
208
|
}
|
|
210
209
|
}
|
|
211
210
|
|
|
211
|
+
const getIncludedTaxesDiscounts = () => {
|
|
212
|
+
return order?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
|
|
213
|
+
}
|
|
214
|
+
|
|
212
215
|
useEffect(() => {
|
|
213
216
|
BackHandler.addEventListener('hardwareBackPress', handleArrowBack);
|
|
214
217
|
return () => {
|
|
@@ -277,7 +280,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
277
280
|
<OText size={20} color={theme.colors.white} space>
|
|
278
281
|
{t('TOTAL', 'Total')}
|
|
279
282
|
</OText>
|
|
280
|
-
<OText size={20} color={theme.colors.white}>{parsePrice(order?.summary?.total
|
|
283
|
+
<OText size={20} color={theme.colors.white}>{parsePrice(order?.summary?.total ?? order?.total)}</OText>
|
|
281
284
|
</View>
|
|
282
285
|
</HeaderInfo>
|
|
283
286
|
</Header>
|
|
@@ -376,18 +379,18 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
376
379
|
<OText style={{ textAlign: 'left' }}>{order?.customer?.address}</OText>
|
|
377
380
|
</InfoBlock>
|
|
378
381
|
</Customer>
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
382
|
+
{order?.delivery_option !== undefined && order?.delivery_type === 1 && (
|
|
383
|
+
<View>
|
|
384
|
+
<OText size={18} style={{ textAlign: 'left' }}>{t('DELIVERY_PREFERENCE', 'Delivery Preference')}</OText>
|
|
385
|
+
<OText style={{ textAlign: 'left' }}>{order?.delivery_option?.name}</OText>
|
|
386
|
+
</View>
|
|
387
|
+
)}
|
|
388
|
+
{order?.comment && (
|
|
389
|
+
<View>
|
|
390
|
+
<OText size={18} style={{ textAlign: 'left' }} >{t('COMMENT', 'Comment')}</OText>
|
|
391
|
+
<OText style={{ textAlign: 'left' }}>{order?.comment}</OText>
|
|
392
|
+
</View>
|
|
393
|
+
)}
|
|
391
394
|
{order?.driver && (
|
|
392
395
|
<>
|
|
393
396
|
{order?.driver?.location && parseInt(order?.status) === 9 && (
|
|
@@ -442,26 +445,49 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
442
445
|
<Table>
|
|
443
446
|
<OText>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
444
447
|
<OText>
|
|
445
|
-
{parsePrice(((order?.summary?.subtotal
|
|
448
|
+
{parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()))}
|
|
446
449
|
</OText>
|
|
447
450
|
</Table>
|
|
448
|
-
{order?.summary?.discount > 0 && (
|
|
451
|
+
{(order?.summary?.discount > 0 ?? order?.discount > 0) && order?.offers?.length === 0 && (
|
|
449
452
|
<Table>
|
|
450
453
|
{order?.offer_type === 1 ? (
|
|
451
454
|
<OText>
|
|
452
|
-
{t('DISCOUNT', 'Discount')}
|
|
453
|
-
<
|
|
455
|
+
{t('DISCOUNT', theme?.defaultLanguages?.DISCOUNT || 'Discount')}{' '}
|
|
456
|
+
<span>{`(${verifyDecimals(order?.offer_rate, parsePrice)}%)`}</span>
|
|
454
457
|
</OText>
|
|
455
458
|
) : (
|
|
456
|
-
<OText>{t('DISCOUNT', 'Discount')}</OText>
|
|
459
|
+
<OText>{t('DISCOUNT', theme?.defaultLanguages?.DISCOUNT || 'Discount')}</OText>
|
|
457
460
|
)}
|
|
458
|
-
<OText>- {parsePrice(order?.summary?.discount)}</OText>
|
|
461
|
+
<OText>- {parsePrice(order?.summary?.discount ?? order?.discount)}</OText>
|
|
459
462
|
</Table>
|
|
460
463
|
)}
|
|
464
|
+
{
|
|
465
|
+
order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
|
|
466
|
+
<Table key={offer.id}>
|
|
467
|
+
<OSRow>
|
|
468
|
+
<OText numberOfLines={1}>
|
|
469
|
+
{offer.name}
|
|
470
|
+
{offer.rate_type === 1 && (
|
|
471
|
+
<OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
472
|
+
)}
|
|
473
|
+
</OText>
|
|
474
|
+
<TouchableOpacity style={{ marginLeft: 5 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
|
|
475
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
476
|
+
</TouchableOpacity>
|
|
477
|
+
</OSRow>
|
|
478
|
+
<OText>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
479
|
+
</Table>
|
|
480
|
+
))
|
|
481
|
+
}
|
|
482
|
+
<Divider />
|
|
461
483
|
{order?.summary?.subtotal_with_discount > 0 && order?.summary?.discount > 0 && order?.summary?.total >= 0 && (
|
|
462
484
|
<Table>
|
|
463
485
|
<OText>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
|
|
464
|
-
|
|
486
|
+
{order?.tax_type === 1 ? (
|
|
487
|
+
<OText>{parsePrice((order?.summary?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0))}</OText>
|
|
488
|
+
) : (
|
|
489
|
+
<OText>{parsePrice(order?.summary?.subtotal_with_discount ?? 0)}</OText>
|
|
490
|
+
)}
|
|
465
491
|
</Table>
|
|
466
492
|
)}
|
|
467
493
|
{
|
|
@@ -470,7 +496,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
470
496
|
<OText>
|
|
471
497
|
{t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
|
|
472
498
|
</OText>
|
|
473
|
-
<OText>{parsePrice(order?.summary?.tax
|
|
499
|
+
<OText>{parsePrice(order?.summary?.tax ?? 0)}</OText>
|
|
474
500
|
</Table>
|
|
475
501
|
)
|
|
476
502
|
}
|
|
@@ -481,7 +507,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
481
507
|
{t('SERVICE_FEE', 'Service fee')}
|
|
482
508
|
{`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
|
|
483
509
|
</OText>
|
|
484
|
-
<OText>{parsePrice(order?.summary?.service_fee
|
|
510
|
+
<OText>{parsePrice(order?.summary?.service_fee ?? 0)}</OText>
|
|
485
511
|
</Table>
|
|
486
512
|
)
|
|
487
513
|
}
|
|
@@ -493,11 +519,11 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
493
519
|
{tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
494
520
|
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
495
521
|
</OText>
|
|
496
|
-
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })}>
|
|
522
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax, type: 'tax' })}>
|
|
497
523
|
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
498
524
|
</TouchableOpacity>
|
|
499
525
|
</OSRow>
|
|
500
|
-
<OText>{parsePrice(tax?.summary?.tax
|
|
526
|
+
<OText>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
|
|
501
527
|
</Table>
|
|
502
528
|
))
|
|
503
529
|
}
|
|
@@ -509,11 +535,29 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
509
535
|
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
510
536
|
({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
|
|
511
537
|
</OText>
|
|
512
|
-
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })}>
|
|
538
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })}>
|
|
539
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
540
|
+
</TouchableOpacity>
|
|
541
|
+
</OSRow>
|
|
542
|
+
<OText>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
|
|
543
|
+
</Table>
|
|
544
|
+
))
|
|
545
|
+
}
|
|
546
|
+
{
|
|
547
|
+
order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
|
|
548
|
+
<Table key={offer.id}>
|
|
549
|
+
<OSRow>
|
|
550
|
+
<OText numberOfLines={1}>
|
|
551
|
+
{offer.name}
|
|
552
|
+
{offer.rate_type === 1 && (
|
|
553
|
+
<OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
554
|
+
)}
|
|
555
|
+
</OText>
|
|
556
|
+
<TouchableOpacity style={{ marginLeft: 5 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
|
|
513
557
|
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
514
558
|
</TouchableOpacity>
|
|
515
559
|
</OSRow>
|
|
516
|
-
<OText
|
|
560
|
+
<OText>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
517
561
|
</Table>
|
|
518
562
|
))
|
|
519
563
|
}
|
|
@@ -523,6 +567,24 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
523
567
|
<OText>{parsePrice(order?.summary?.delivery_price)}</OText>
|
|
524
568
|
</Table>
|
|
525
569
|
)}
|
|
570
|
+
{
|
|
571
|
+
order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
|
|
572
|
+
<Table key={offer.id}>
|
|
573
|
+
<OSRow>
|
|
574
|
+
<OText numberOfLines={1}>
|
|
575
|
+
{offer.name}
|
|
576
|
+
{offer.rate_type === 1 && (
|
|
577
|
+
<OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
578
|
+
)}
|
|
579
|
+
</OText>
|
|
580
|
+
<TouchableOpacity style={{ marginLeft: 5 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
|
|
581
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
582
|
+
</TouchableOpacity>
|
|
583
|
+
</OSRow>
|
|
584
|
+
<OText>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
585
|
+
</Table>
|
|
586
|
+
))
|
|
587
|
+
}
|
|
526
588
|
{order?.summary?.driver_tip > 0 && (
|
|
527
589
|
<Table>
|
|
528
590
|
<OText>
|
|
@@ -534,14 +596,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
534
596
|
`(${verifyDecimals(order?.summary?.driver_tip, parseNumber)}%)`
|
|
535
597
|
)}
|
|
536
598
|
</OText>
|
|
537
|
-
<OText>{parsePrice(order?.summary?.driver_tip ??
|
|
599
|
+
<OText>{parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip)}</OText>
|
|
538
600
|
</Table>
|
|
539
601
|
)}
|
|
540
602
|
<Total>
|
|
541
603
|
<Table>
|
|
542
604
|
<OText style={styles.textBold}>{t('TOTAL', 'Total')}</OText>
|
|
543
605
|
<OText style={styles.textBold} color={theme.colors.primary}>
|
|
544
|
-
{parsePrice(order?.summary?.total ??
|
|
606
|
+
{parsePrice(order?.summary?.total ?? order?.total)}
|
|
545
607
|
</OText>
|
|
546
608
|
</Table>
|
|
547
609
|
</Total>
|
|
@@ -616,10 +678,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
616
678
|
</OModal>
|
|
617
679
|
<OModal
|
|
618
680
|
open={openTaxModal.open}
|
|
619
|
-
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
681
|
+
onClose={() => setOpenTaxModal({ open: false, data: null, type: '' })}
|
|
620
682
|
entireModal
|
|
683
|
+
title={`${openTaxModal.data?.name ||
|
|
684
|
+
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}%`})` : ''} `}
|
|
621
685
|
>
|
|
622
|
-
<TaxInformation
|
|
686
|
+
<TaxInformation
|
|
687
|
+
type={openTaxModal.type}
|
|
688
|
+
data={openTaxModal.data}
|
|
689
|
+
products={order?.products}
|
|
690
|
+
/>
|
|
623
691
|
</OModal>
|
|
624
692
|
</OrderDetailsContainer>
|
|
625
693
|
)
|
|
@@ -119,3 +119,10 @@ export const LoadingWrapper = styled.View`
|
|
|
119
119
|
justify-content: flex-start;
|
|
120
120
|
align-content: flex-start;
|
|
121
121
|
`
|
|
122
|
+
|
|
123
|
+
export const Divider = styled.View`
|
|
124
|
+
border-color: #EAEAEA;
|
|
125
|
+
border-width: 1px;
|
|
126
|
+
margin-top: 5px;
|
|
127
|
+
margin-bottom: 5px;
|
|
128
|
+
`
|
|
@@ -14,12 +14,13 @@ 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
|
-
import { OInput, OModal, OText } from '../shared';
|
|
23
|
+
import { OAlert, OInput, OModal, OText } from '../shared';
|
|
23
24
|
import { verifyDecimals } from '../../utils';
|
|
24
25
|
import { useTheme } from 'styled-components/native';
|
|
25
26
|
import { TaxInformation } from '../TaxInformation';
|
|
@@ -36,7 +37,8 @@ const OrderSummaryUI = (props: any) => {
|
|
|
36
37
|
isFromCheckout,
|
|
37
38
|
commentState,
|
|
38
39
|
handleChangeComment,
|
|
39
|
-
onNavigationRedirect
|
|
40
|
+
onNavigationRedirect,
|
|
41
|
+
handleRemoveOfferClick
|
|
40
42
|
} = props;
|
|
41
43
|
|
|
42
44
|
const theme = useTheme();
|
|
@@ -46,6 +48,7 @@ const OrderSummaryUI = (props: any) => {
|
|
|
46
48
|
const [{ parsePrice, parseNumber }] = useUtils();
|
|
47
49
|
const [validationFields] = useValidationFields();
|
|
48
50
|
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
51
|
+
const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
|
|
49
52
|
|
|
50
53
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
|
|
51
54
|
|
|
@@ -55,15 +58,15 @@ const OrderSummaryUI = (props: any) => {
|
|
|
55
58
|
|
|
56
59
|
const handleEditProduct = (product: any) => {
|
|
57
60
|
onNavigationRedirect &&
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
onNavigationRedirect('ProductDetails', {
|
|
62
|
+
isCartProduct: true,
|
|
63
|
+
productCart: product,
|
|
64
|
+
businessSlug: cart?.business?.slug,
|
|
65
|
+
businessId: cart?.business_id,
|
|
66
|
+
categoryId: product?.category_id,
|
|
67
|
+
productId: product?.id,
|
|
68
|
+
isFromCheckout: isFromCheckout,
|
|
69
|
+
})
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
const getIncludedTaxes = () => {
|
|
@@ -76,6 +79,22 @@ const OrderSummaryUI = (props: any) => {
|
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
|
|
82
|
+
const getIncludedTaxesDiscounts = () => {
|
|
83
|
+
return cart?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const onRemoveOffer = (id: number) => {
|
|
87
|
+
setConfirm({
|
|
88
|
+
open: true,
|
|
89
|
+
content: [t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')],
|
|
90
|
+
title: t('OFFER', 'Offer'),
|
|
91
|
+
handleOnAccept: () => {
|
|
92
|
+
setConfirm({ ...confirm, open: false })
|
|
93
|
+
handleRemoveOfferClick(id)
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
|
|
79
98
|
return (
|
|
80
99
|
<OSContainer>
|
|
81
100
|
{cart?.products?.length > 0 && (
|
|
@@ -99,35 +118,65 @@ const OrderSummaryUI = (props: any) => {
|
|
|
99
118
|
{cart?.valid && (
|
|
100
119
|
<OSBill>
|
|
101
120
|
<OSTable>
|
|
102
|
-
<OText size={
|
|
103
|
-
<OText size={
|
|
121
|
+
<OText size={16}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
122
|
+
<OText size={16}>{parsePrice(cart?.subtotal + getIncludedTaxes())}</OText>
|
|
104
123
|
</OSTable>
|
|
105
|
-
{cart?.discount > 0 && cart?.total >= 0 && (
|
|
124
|
+
{cart?.discount > 0 && cart?.total >= 0 && cart?.offers?.length === 0 && (
|
|
106
125
|
<OSTable>
|
|
107
126
|
{cart?.discount_type === 1 ? (
|
|
108
|
-
<OText size={
|
|
109
|
-
{t('DISCOUNT', 'Discount')}
|
|
110
|
-
<OText size={
|
|
127
|
+
<OText size={16}>
|
|
128
|
+
{t('DISCOUNT', 'Discount')}{' '}
|
|
129
|
+
<OText size={16}>{`(${verifyDecimals(cart?.discount_rate, parsePrice)}%)`}</OText>
|
|
111
130
|
</OText>
|
|
112
131
|
) : (
|
|
113
|
-
<OText size={
|
|
132
|
+
<OText size={16}>{t('DISCOUNT', 'Discount')}</OText>
|
|
133
|
+
)}
|
|
134
|
+
<OText size={16}>- {parsePrice(cart?.discount || 0)}</OText>
|
|
135
|
+
</OSTable>
|
|
136
|
+
)}
|
|
137
|
+
{
|
|
138
|
+
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
|
|
139
|
+
<OSTable key={offer.id}>
|
|
140
|
+
<OSRow>
|
|
141
|
+
<OText size={16}>{offer.name}</OText>
|
|
142
|
+
{offer.rate_type === 1 && (
|
|
143
|
+
<OText size={16}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
144
|
+
)}
|
|
145
|
+
<TouchableOpacity style={{ marginLeft: 5, top: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
|
|
146
|
+
<AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
|
|
147
|
+
</TouchableOpacity>
|
|
148
|
+
<TouchableOpacity style={{ marginLeft: 5, top: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
|
|
149
|
+
<AntIcon name='closecircle' size={20} color={theme.colors.primary} />
|
|
150
|
+
</TouchableOpacity>
|
|
151
|
+
</OSRow>
|
|
152
|
+
<OText size={16} numberOfLines={2}>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
153
|
+
</OSTable>
|
|
154
|
+
))
|
|
155
|
+
}
|
|
156
|
+
<Divider />
|
|
157
|
+
{cart?.subtotal_with_discount > 0 && cart?.discount > 0 && cart?.total >= 0 && (
|
|
158
|
+
<OSTable>
|
|
159
|
+
<OText size={16} numberOfLines={1}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
|
|
160
|
+
{cart?.business?.tax_type === 1 ? (
|
|
161
|
+
<OText size={16}>{parsePrice(cart?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0)}</OText>
|
|
162
|
+
) : (
|
|
163
|
+
<OText size={16}>{parsePrice(cart?.subtotal_with_discount ?? 0)}</OText>
|
|
114
164
|
)}
|
|
115
|
-
<OText size={18}>- {parsePrice(cart?.discount || 0)}</OText>
|
|
116
165
|
</OSTable>
|
|
117
166
|
)}
|
|
118
167
|
{
|
|
119
168
|
cart?.taxes?.length > 0 && cart?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
120
169
|
<OSTable key={tax?.id}>
|
|
121
170
|
<OSRow>
|
|
122
|
-
<OText size={
|
|
171
|
+
<OText size={16} numberOfLines={1}>
|
|
123
172
|
{tax?.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
124
173
|
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
125
174
|
</OText>
|
|
126
|
-
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
|
|
175
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax, type: 'tax' })} >
|
|
127
176
|
<AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
|
|
128
177
|
</TouchableOpacity>
|
|
129
178
|
</OSRow>
|
|
130
|
-
<OText size={
|
|
179
|
+
<OText size={16}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
|
|
131
180
|
</OSTable>
|
|
132
181
|
))
|
|
133
182
|
}
|
|
@@ -135,27 +184,69 @@ const OrderSummaryUI = (props: any) => {
|
|
|
135
184
|
cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
|
|
136
185
|
<OSTable key={fee.id}>
|
|
137
186
|
<OSRow>
|
|
138
|
-
<OText size={
|
|
187
|
+
<OText size={16} numberOfLines={1}>
|
|
139
188
|
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
140
189
|
({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
|
|
141
190
|
</OText>
|
|
142
|
-
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
|
|
191
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
|
|
192
|
+
<AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
|
|
193
|
+
</TouchableOpacity>
|
|
194
|
+
</OSRow>
|
|
195
|
+
<OText size={16}>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
|
|
196
|
+
</OSTable>
|
|
197
|
+
))
|
|
198
|
+
}
|
|
199
|
+
{
|
|
200
|
+
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
|
|
201
|
+
<OSTable key={offer.id}>
|
|
202
|
+
<OSRow>
|
|
203
|
+
<OText size={16}>{offer.name}</OText>
|
|
204
|
+
{offer.rate_type === 1 && (
|
|
205
|
+
<OText size={16}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
206
|
+
)}
|
|
207
|
+
<TouchableOpacity style={{ marginLeft: 5, top: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
|
|
143
208
|
<AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
|
|
144
209
|
</TouchableOpacity>
|
|
210
|
+
<TouchableOpacity style={{ marginLeft: 5, top: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
|
|
211
|
+
<AntIcon name='closecircle' size={20} color={theme.colors.primary} />
|
|
212
|
+
</TouchableOpacity>
|
|
145
213
|
</OSRow>
|
|
146
|
-
<OText size={
|
|
214
|
+
<OText size={16}>
|
|
215
|
+
- {parsePrice(offer?.summary?.discount)}
|
|
216
|
+
</OText>
|
|
147
217
|
</OSTable>
|
|
148
218
|
))
|
|
149
219
|
}
|
|
150
220
|
{orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
|
|
151
221
|
<OSTable>
|
|
152
|
-
<OText size={
|
|
153
|
-
<OText size={
|
|
222
|
+
<OText size={16}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
|
|
223
|
+
<OText size={16}>{parsePrice(cart?.delivery_price)}</OText>
|
|
154
224
|
</OSTable>
|
|
155
225
|
)}
|
|
226
|
+
{
|
|
227
|
+
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
|
|
228
|
+
<OSTable key={offer.id}>
|
|
229
|
+
<OSRow>
|
|
230
|
+
<OText size={16}>{offer.name}</OText>
|
|
231
|
+
{offer.rate_type === 1 && (
|
|
232
|
+
<OText size={16}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
233
|
+
)}
|
|
234
|
+
<TouchableOpacity style={{ marginLeft: 3, top: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
|
|
235
|
+
<AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
|
|
236
|
+
</TouchableOpacity>
|
|
237
|
+
<TouchableOpacity style={{ marginLeft: 3, top: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
|
|
238
|
+
<AntIcon name='closecircle' size={20} color={theme.colors.primary} />
|
|
239
|
+
</TouchableOpacity>
|
|
240
|
+
</OSRow>
|
|
241
|
+
<OText size={16}>
|
|
242
|
+
- {parsePrice(offer?.summary?.discount)}
|
|
243
|
+
</OText>
|
|
244
|
+
</OSTable>
|
|
245
|
+
))
|
|
246
|
+
}
|
|
156
247
|
{cart?.driver_tip > 0 && (
|
|
157
248
|
<OSTable>
|
|
158
|
-
<OText size={
|
|
249
|
+
<OText size={16}>
|
|
159
250
|
{t('DRIVER_TIP', 'Driver tip')}
|
|
160
251
|
{cart?.driver_tip_rate > 0 &&
|
|
161
252
|
parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
|
|
@@ -164,7 +255,7 @@ const OrderSummaryUI = (props: any) => {
|
|
|
164
255
|
`(${verifyDecimals(cart?.driver_tip_rate, parseNumber)}%)`
|
|
165
256
|
)}
|
|
166
257
|
</OText>
|
|
167
|
-
<OText size={
|
|
258
|
+
<OText size={16}>{parsePrice(cart?.driver_tip)}</OText>
|
|
168
259
|
</OSTable>
|
|
169
260
|
)}
|
|
170
261
|
{isCouponEnabled && !isCartPending && (
|
|
@@ -177,22 +268,20 @@ const OrderSummaryUI = (props: any) => {
|
|
|
177
268
|
</View>
|
|
178
269
|
</View>
|
|
179
270
|
)}
|
|
180
|
-
{cart?.total >= 1 && (
|
|
181
271
|
<View style={{ marginTop: 15, borderTopWidth: 1, borderTopColor: '#d9d9d9' }}>
|
|
182
272
|
<OSTable style={{ marginTop: 15 }}>
|
|
183
|
-
<OText size={
|
|
273
|
+
<OText size={16} style={{ fontWeight: 'bold' }}>
|
|
184
274
|
{t('TOTAL', 'Total')}
|
|
185
275
|
</OText>
|
|
186
|
-
<OText size={
|
|
187
|
-
{parsePrice(cart?.total)}
|
|
276
|
+
<OText size={16} style={{ fontWeight: 'bold' }} color={theme.colors.primary}>
|
|
277
|
+
{parsePrice(cart?.total >= 0 ? cart?.total : 0)}
|
|
188
278
|
</OText>
|
|
189
279
|
</OSTable>
|
|
190
280
|
</View>
|
|
191
|
-
)}
|
|
192
281
|
{cart?.status !== 2 && (
|
|
193
282
|
<OSTable>
|
|
194
283
|
<View style={{ width: '100%', marginTop: 20 }}>
|
|
195
|
-
<OText>{t('COMMENTS', 'Comments')}</OText>
|
|
284
|
+
<OText size={16}>{t('COMMENTS', 'Comments')}</OText>
|
|
196
285
|
<View style={{ flex: 1, width: '100%' }}>
|
|
197
286
|
<OInput
|
|
198
287
|
value={cart?.comment}
|
|
@@ -227,9 +316,23 @@ const OrderSummaryUI = (props: any) => {
|
|
|
227
316
|
open={openTaxModal.open}
|
|
228
317
|
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
229
318
|
entireModal
|
|
319
|
+
title={`${openTaxModal.data?.name ||
|
|
320
|
+
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}%`})` : ''} `}
|
|
230
321
|
>
|
|
231
|
-
<TaxInformation
|
|
322
|
+
<TaxInformation
|
|
323
|
+
type={openTaxModal.type}
|
|
324
|
+
data={openTaxModal.data}
|
|
325
|
+
products={cart?.products}
|
|
326
|
+
/>
|
|
232
327
|
</OModal>
|
|
328
|
+
<OAlert
|
|
329
|
+
open={confirm.open}
|
|
330
|
+
title={confirm.title}
|
|
331
|
+
content={confirm.content}
|
|
332
|
+
onAccept={confirm.handleOnAccept}
|
|
333
|
+
onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
|
|
334
|
+
onClose={() => setConfirm({ ...confirm, open: false, title: null })}
|
|
335
|
+
/>
|
|
233
336
|
</>
|
|
234
337
|
)}
|
|
235
338
|
</OSContainer>
|
|
@@ -33,5 +33,13 @@ export const OSCoupon = styled.View`
|
|
|
33
33
|
export const OSRow = styled.View`
|
|
34
34
|
flex-direction: row;
|
|
35
35
|
overflow: hidden;
|
|
36
|
-
width:
|
|
37
|
-
|
|
36
|
+
width: 70%;
|
|
37
|
+
flex-wrap: wrap;
|
|
38
|
+
`
|
|
39
|
+
|
|
40
|
+
export const Divider = styled.View`
|
|
41
|
+
border-color: #EAEAEA;
|
|
42
|
+
border-width: 1px;
|
|
43
|
+
margin-top: 5px;
|
|
44
|
+
margin-bottom: 10px;
|
|
45
|
+
`
|
|
@@ -45,6 +45,8 @@ const stripeOptions: any = ['stripe_direct', 'stripe', 'stripe_connect']
|
|
|
45
45
|
// { name: 'iDEAL', value: 'ideal' }
|
|
46
46
|
// ]
|
|
47
47
|
|
|
48
|
+
const webViewPaymentGateway: any = ['paypal', 'square']
|
|
49
|
+
|
|
48
50
|
const PaymentOptionsUI = (props: any) => {
|
|
49
51
|
const {
|
|
50
52
|
cart,
|
|
@@ -92,7 +94,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
92
94
|
const handlePaymentMethodClick = (paymethod: any) => {
|
|
93
95
|
const isPopupMethod = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal', 'square'].includes(paymethod?.gateway)
|
|
94
96
|
handlePaymethodClick(paymethod, isPopupMethod)
|
|
95
|
-
|
|
97
|
+
if (webViewPaymentGateway.includes(paymethod?.gateway)) {
|
|
96
98
|
handlePaymentMethodClickCustom(paymethod)
|
|
97
99
|
}
|
|
98
100
|
setCardData(paymethodData)
|