@transferwise/comparison-components 20.0.4 → 20.1.2
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/CHANGELOG.md +10 -0
- package/dist/es/{ComparisonTableHeroContainer-015c3b3b.js → ComparisonTableHeroContainer-711ea55b.js} +2 -2
- package/dist/es/{ComparisonTableHeroContainer-015c3b3b.js.map → ComparisonTableHeroContainer-711ea55b.js.map} +1 -1
- package/dist/es/{ErrorTemplate-e9199922.js → ErrorTemplate-c5bf0627.js} +2 -2
- package/dist/es/{ErrorTemplate-e9199922.js.map → ErrorTemplate-c5bf0627.js.map} +1 -1
- package/dist/es/{ProviderComparisonTable-b571ac0e.js → ProviderComparisonTable-93c09571.js} +2 -2
- package/dist/es/{ProviderComparisonTable-b571ac0e.js.map → ProviderComparisonTable-93c09571.js.map} +1 -1
- package/dist/es/{ReceiveAmount-b3ea21f6.js → ReceiveAmount-5f58a372.js} +2 -2
- package/dist/es/{ReceiveAmount-b3ea21f6.js.map → ReceiveAmount-5f58a372.js.map} +1 -1
- package/dist/es/TransferFeeComparisonContainer-aff68efc.js +2 -0
- package/dist/es/{TransferFeeComparisonContainer-19ab2ee3.js.map → TransferFeeComparisonContainer-aff68efc.js.map} +1 -1
- package/dist/es/{TravelMoney-16401d8f.js → TravelMoney-0d589971.js} +2 -2
- package/dist/es/{TravelMoney-16401d8f.js.map → TravelMoney-0d589971.js.map} +1 -1
- package/dist/es/comparison/index.js +1 -1
- package/dist/es/comparison/index.js.map +1 -1
- package/dist/es/comparison-table/index.js +1 -1
- package/dist/es/comparison-table-hero/index.js +1 -1
- package/dist/es/index-1371a73e.js +2 -0
- package/dist/es/index-1371a73e.js.map +1 -0
- package/dist/es/index.js +1 -1
- package/dist/es/index.js.map +1 -1
- package/dist/es/provider-comparison-table/index.js +1 -1
- package/dist/es/provider-comparison-widget/index.js +1 -1
- package/dist/es/savingsCalculator-894a963b.js +2 -0
- package/dist/es/savingsCalculator-894a963b.js.map +1 -0
- package/dist/es/savingsCalculator.js +2 -0
- package/dist/es/savingsCalculator.js.map +1 -0
- package/dist/es/transfer-fee-comparison/index.js +1 -1
- package/dist/es/transformQuotesResponseV2.js +1 -1
- package/dist/es/travel-money/index.js +1 -1
- package/dist/umd/comparison-components.css +1 -1
- package/dist/umd/comparison-components.js +4 -4
- package/dist/umd/comparison-components.js.map +1 -1
- package/dist/umd/transfer-fee-comparison/transfer-fee-comparison.js +2 -2
- package/dist/umd/transfer-fee-comparison/transfer-fee-comparison.js.map +1 -1
- package/package.json +1 -1
- package/src/resources/clients/quotes/__test__/transformQuotesResponseV2.spec.ts +177 -0
- package/src/resources/clients/quotes/currenciesWithoutDecimals.ts +28 -0
- package/src/resources/clients/quotes/transformQuotesResponseV2.ts +15 -9
- package/src/resources/tracking/types.ts +1 -0
- package/src/transfer-fee-comparison/TransferFeeComparison.tsx +3 -0
- package/src/transfer-fee-comparison/TransferFeeComparisonContainer.spec.tsx +22 -1
- package/src/transfer-fee-comparison/TransferFeeComparisonContainer.tsx +9 -1
- package/src/transfer-fee-comparison/mocks/Quotes.ts +45 -0
- package/src/transfer-fee-comparison/transfer-fee-comparison-table/TransferFeeComparisonTable.tsx +2 -0
- package/src/transfer-fee-comparison/transfer-fee-comparison-table-row/TransferFeeComparisonTableRow.tsx +10 -1
- package/src/transfer-fee-comparison/transfer-fee-comparison-table-row/fee-makeup-popover/FeeMakeupPopover.tsx +6 -2
- package/src/transfer-fee-comparison/transfer-fee-comparison-table-row/fee-makeup-popover/fee-element/TransparentFeeElement.tsx +6 -2
- package/dist/es/TransferFeeComparisonContainer-19ab2ee3.js +0 -2
- package/dist/es/index-41366bca.js +0 -2
- package/dist/es/index-41366bca.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/comparison-components",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.1.2",
|
|
4
4
|
"description": "Display a comparison table of providers given a route and amount.",
|
|
5
5
|
"homepage": "https://wise.com/gb/compare/",
|
|
6
6
|
"main": "dist/umd/comparison-components.js",
|
|
@@ -483,4 +483,181 @@ describe('quotes v3 response transformations to the canonical model V2', () => {
|
|
|
483
483
|
|
|
484
484
|
expect(transformQuotesResponseV2(providers, wiseProvider)).toStrictEqual(expected);
|
|
485
485
|
});
|
|
486
|
+
|
|
487
|
+
it('given a route with a small send amount with a decimal currency, and provider does have a hidden fee, do show the hidden fee', () => {
|
|
488
|
+
const wiseProvider = {
|
|
489
|
+
...wiseQuoteApiAdjusted,
|
|
490
|
+
rate: 0.88665,
|
|
491
|
+
};
|
|
492
|
+
const providers = {
|
|
493
|
+
providers: [
|
|
494
|
+
{
|
|
495
|
+
name: 'Western Union',
|
|
496
|
+
alias: 'western-union',
|
|
497
|
+
logo: 'https://dq8dwmysp7hk1.cloudfront.net/logos/western-union.svg',
|
|
498
|
+
partner: true,
|
|
499
|
+
quotes: [
|
|
500
|
+
{
|
|
501
|
+
rate: 0.00759645,
|
|
502
|
+
fee: 0,
|
|
503
|
+
dateCollected: new Date('2018-10-23T12:03:27'),
|
|
504
|
+
receivedAmount: 21.67,
|
|
505
|
+
},
|
|
506
|
+
],
|
|
507
|
+
},
|
|
508
|
+
],
|
|
509
|
+
sendAmount: 25,
|
|
510
|
+
sourceCurrency: 'USD',
|
|
511
|
+
targetCurrency: 'EUR',
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
const expected = {
|
|
515
|
+
quotes: [
|
|
516
|
+
{
|
|
517
|
+
provider: {
|
|
518
|
+
name: 'Western Union',
|
|
519
|
+
alias: 'western-union',
|
|
520
|
+
logoUrl: 'https://dq8dwmysp7hk1.cloudfront.net/logos/western-union.svg',
|
|
521
|
+
partner: true,
|
|
522
|
+
},
|
|
523
|
+
route: {
|
|
524
|
+
sourceCurrency: 'USD',
|
|
525
|
+
targetCurrency: 'EUR',
|
|
526
|
+
},
|
|
527
|
+
rate: 0.00759645,
|
|
528
|
+
fees: {
|
|
529
|
+
breakdown: [
|
|
530
|
+
{
|
|
531
|
+
type: FeeType.HIDDEN,
|
|
532
|
+
amount: { value: 0.55, currency: 'USD' },
|
|
533
|
+
},
|
|
534
|
+
],
|
|
535
|
+
total: { value: 0.55, currency: 'USD' },
|
|
536
|
+
},
|
|
537
|
+
receiveAmount: { value: 21.67, currency: 'EUR' },
|
|
538
|
+
sendAmount: { value: 25, currency: 'USD' },
|
|
539
|
+
},
|
|
540
|
+
],
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
expect(transformQuotesResponseV2(providers, wiseProvider)).toStrictEqual(expected);
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
it('given a route with a small send amount with a non-decimal currency as source, and provider doesnt have a hidden fee, dont show the hidden fee', () => {
|
|
547
|
+
const wiseProvider = {
|
|
548
|
+
...wiseQuoteApiAdjusted,
|
|
549
|
+
rate: 0.0000612414,
|
|
550
|
+
};
|
|
551
|
+
const providers = {
|
|
552
|
+
providers: [
|
|
553
|
+
{
|
|
554
|
+
name: 'Western Union',
|
|
555
|
+
alias: 'western-union',
|
|
556
|
+
logo: 'https://dq8dwmysp7hk1.cloudfront.net/logos/western-union.svg',
|
|
557
|
+
partner: true,
|
|
558
|
+
quotes: [
|
|
559
|
+
{
|
|
560
|
+
rate: 0.00759645,
|
|
561
|
+
fee: 12175,
|
|
562
|
+
dateCollected: new Date('2018-10-23T12:03:27'),
|
|
563
|
+
receivedAmount: 0.17,
|
|
564
|
+
},
|
|
565
|
+
],
|
|
566
|
+
},
|
|
567
|
+
],
|
|
568
|
+
sendAmount: 15000,
|
|
569
|
+
sourceCurrency: 'IDR',
|
|
570
|
+
targetCurrency: 'EUR',
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
const expected = {
|
|
574
|
+
quotes: [
|
|
575
|
+
{
|
|
576
|
+
provider: {
|
|
577
|
+
name: 'Western Union',
|
|
578
|
+
alias: 'western-union',
|
|
579
|
+
logoUrl: 'https://dq8dwmysp7hk1.cloudfront.net/logos/western-union.svg',
|
|
580
|
+
partner: true,
|
|
581
|
+
},
|
|
582
|
+
route: {
|
|
583
|
+
sourceCurrency: 'IDR',
|
|
584
|
+
targetCurrency: 'EUR',
|
|
585
|
+
},
|
|
586
|
+
rate: 0.00759645,
|
|
587
|
+
fees: {
|
|
588
|
+
breakdown: [
|
|
589
|
+
{
|
|
590
|
+
type: FeeType.MARKETED,
|
|
591
|
+
amount: { value: 12175, currency: 'IDR' },
|
|
592
|
+
},
|
|
593
|
+
],
|
|
594
|
+
total: { value: 12175, currency: 'IDR' },
|
|
595
|
+
},
|
|
596
|
+
receiveAmount: { value: 0.17, currency: 'EUR' },
|
|
597
|
+
sendAmount: { value: 15000, currency: 'IDR' },
|
|
598
|
+
},
|
|
599
|
+
],
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
expect(transformQuotesResponseV2(providers, wiseProvider)).toStrictEqual(expected);
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
it('given a route with a small send amount with a non-decimal currency as target, and provider doesnt have a hidden fee, dont show the hidden fee', () => {
|
|
606
|
+
const wiseProvider = {
|
|
607
|
+
...wiseQuoteApiAdjusted,
|
|
608
|
+
rate: 0.0000612414,
|
|
609
|
+
};
|
|
610
|
+
const providers = {
|
|
611
|
+
providers: [
|
|
612
|
+
{
|
|
613
|
+
name: 'Western Union',
|
|
614
|
+
alias: 'western-union',
|
|
615
|
+
logo: 'https://dq8dwmysp7hk1.cloudfront.net/logos/western-union.svg',
|
|
616
|
+
partner: true,
|
|
617
|
+
quotes: [
|
|
618
|
+
{
|
|
619
|
+
rate: 0.00759645,
|
|
620
|
+
fee: 1.31,
|
|
621
|
+
dateCollected: new Date('2018-10-23T12:03:27'),
|
|
622
|
+
receivedAmount: 253,
|
|
623
|
+
},
|
|
624
|
+
],
|
|
625
|
+
},
|
|
626
|
+
],
|
|
627
|
+
sendAmount: 3,
|
|
628
|
+
sourceCurrency: 'GBP',
|
|
629
|
+
targetCurrency: 'JPY',
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
const expected = {
|
|
633
|
+
quotes: [
|
|
634
|
+
{
|
|
635
|
+
provider: {
|
|
636
|
+
name: 'Western Union',
|
|
637
|
+
alias: 'western-union',
|
|
638
|
+
logoUrl: 'https://dq8dwmysp7hk1.cloudfront.net/logos/western-union.svg',
|
|
639
|
+
partner: true,
|
|
640
|
+
},
|
|
641
|
+
route: {
|
|
642
|
+
sourceCurrency: 'GBP',
|
|
643
|
+
targetCurrency: 'JPY',
|
|
644
|
+
},
|
|
645
|
+
rate: 0.00759645,
|
|
646
|
+
fees: {
|
|
647
|
+
breakdown: [
|
|
648
|
+
{
|
|
649
|
+
type: FeeType.MARKETED,
|
|
650
|
+
amount: { value: 1.31, currency: 'GBP' },
|
|
651
|
+
},
|
|
652
|
+
],
|
|
653
|
+
total: { value: 1.31, currency: 'GBP' },
|
|
654
|
+
},
|
|
655
|
+
receiveAmount: { value: 253, currency: 'JPY' },
|
|
656
|
+
sendAmount: { value: 3, currency: 'GBP' },
|
|
657
|
+
},
|
|
658
|
+
],
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
expect(transformQuotesResponseV2(providers, wiseProvider)).toStrictEqual(expected);
|
|
662
|
+
});
|
|
486
663
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// From ISO 4217 (06/12/2021)
|
|
2
|
+
const CURRENCIES_WITHOUT_DECIMALS = new Set([
|
|
3
|
+
'CVE',
|
|
4
|
+
'IDR',
|
|
5
|
+
'ISK',
|
|
6
|
+
'BIF',
|
|
7
|
+
'CLP',
|
|
8
|
+
'DJF',
|
|
9
|
+
'GNF',
|
|
10
|
+
'ISK',
|
|
11
|
+
'JPY',
|
|
12
|
+
'KMF',
|
|
13
|
+
'KRW',
|
|
14
|
+
'PYG',
|
|
15
|
+
'RWF',
|
|
16
|
+
'UGX',
|
|
17
|
+
'UYI',
|
|
18
|
+
'VND',
|
|
19
|
+
'VUV',
|
|
20
|
+
'XAF',
|
|
21
|
+
'XOF',
|
|
22
|
+
'XPF',
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
const isCurrencyWithoutDecimals = (currencyCode: string): boolean =>
|
|
26
|
+
CURRENCIES_WITHOUT_DECIMALS.has(currencyCode);
|
|
27
|
+
|
|
28
|
+
export default isCurrencyWithoutDecimals;
|
|
@@ -10,6 +10,7 @@ import TransferFeeComparisonQuote, {
|
|
|
10
10
|
} from '../../../transfer-fee-comparison/domain/Quote';
|
|
11
11
|
import TW_ALIAS from '../../provider-constants';
|
|
12
12
|
|
|
13
|
+
import isCurrencyWithoutDecimals from './currenciesWithoutDecimals';
|
|
13
14
|
import extractQuote from './extractQuote';
|
|
14
15
|
import extractWiseQuote from './extractWiseQuote';
|
|
15
16
|
|
|
@@ -18,29 +19,29 @@ export type TransformQuotesResponseType = {
|
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
function extractHiddenFeeInSourceCurrency(
|
|
22
|
+
targetCurrencyCode: string,
|
|
21
23
|
sendAmount: number,
|
|
22
24
|
receivedAmount: number,
|
|
23
25
|
marketedFee: number,
|
|
24
26
|
midmarketRate: number,
|
|
25
27
|
) {
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
+
const noDecimalsCurrencyTolerance = isCurrencyWithoutDecimals(targetCurrencyCode) ? 0.5 : 0;
|
|
29
|
+
const toleranceAmountInPercentage = 0.00001;
|
|
30
|
+
const expectedReceivedAmount = floorToTwoDecimalNumbers(
|
|
31
|
+
midmarketRate * (sendAmount - marketedFee) - noDecimalsCurrencyTolerance,
|
|
32
|
+
);
|
|
28
33
|
|
|
29
34
|
const receivedTheExpectedAmount = numberEqualsWithRelativeTolerance(
|
|
30
35
|
receivedAmount,
|
|
31
36
|
expectedReceivedAmount,
|
|
32
37
|
toleranceAmountInPercentage,
|
|
33
38
|
);
|
|
34
|
-
const receivedHigherThanExpected =
|
|
35
|
-
!receivedTheExpectedAmount && receivedAmount > expectedReceivedAmount;
|
|
36
|
-
|
|
37
|
-
const expectedHasMoreThanACentMissing = expectedReceivedAmount - receivedAmount >= 0.01;
|
|
39
|
+
const receivedHigherThanExpected = receivedAmount > expectedReceivedAmount;
|
|
38
40
|
|
|
39
|
-
const hasHiddenFee =
|
|
40
|
-
!receivedTheExpectedAmount && !receivedHigherThanExpected && expectedHasMoreThanACentMissing;
|
|
41
|
+
const hasHiddenFee = !receivedTheExpectedAmount && !receivedHigherThanExpected;
|
|
41
42
|
const hiddenFeePaidOnTargetCurrency = hasHiddenFee ? expectedReceivedAmount - receivedAmount : 0;
|
|
42
43
|
|
|
43
|
-
return parseFloat((hiddenFeePaidOnTargetCurrency
|
|
44
|
+
return parseFloat((hiddenFeePaidOnTargetCurrency / midmarketRate).toFixed(2));
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
function extractFees(
|
|
@@ -99,6 +100,7 @@ function buildQuoteObject(
|
|
|
99
100
|
midMarketRate: number,
|
|
100
101
|
) {
|
|
101
102
|
const hiddenFee: number = extractHiddenFeeInSourceCurrency(
|
|
103
|
+
quotesResults.targetCurrency,
|
|
102
104
|
quotesResults.sendAmount,
|
|
103
105
|
quote.receivedAmount,
|
|
104
106
|
quote.fee,
|
|
@@ -132,4 +134,8 @@ function buildQuoteObject(
|
|
|
132
134
|
};
|
|
133
135
|
}
|
|
134
136
|
|
|
137
|
+
function floorToTwoDecimalNumbers(value: number): number {
|
|
138
|
+
return Math.floor(value * 100) / 100;
|
|
139
|
+
}
|
|
140
|
+
|
|
135
141
|
export default transformQuotesResponseV2;
|
|
@@ -24,6 +24,7 @@ export type TransferFeeComparisonProps = {
|
|
|
24
24
|
onFeePopoverClick?: (providerName: string) => void;
|
|
25
25
|
onMobileRowClick?: (providerName: string) => void;
|
|
26
26
|
onRowVisible?: (providerName: string) => void;
|
|
27
|
+
onWiseWithHiddenFees?: () => void;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
const TransferFeeComparison = ({
|
|
@@ -36,6 +37,7 @@ const TransferFeeComparison = ({
|
|
|
36
37
|
onFeePopoverClick,
|
|
37
38
|
onMobileRowClick,
|
|
38
39
|
onRowVisible,
|
|
40
|
+
onWiseWithHiddenFees,
|
|
39
41
|
}: TransferFeeComparisonProps): JSX.Element => {
|
|
40
42
|
return (
|
|
41
43
|
<div className={styles.transferFeeComparison__container}>
|
|
@@ -58,6 +60,7 @@ const TransferFeeComparison = ({
|
|
|
58
60
|
onFeePopoverClick={onFeePopoverClick}
|
|
59
61
|
onMobileRowClick={onMobileRowClick}
|
|
60
62
|
onRowVisible={onRowVisible}
|
|
63
|
+
onWiseWithHiddenFees={onWiseWithHiddenFees}
|
|
61
64
|
/>
|
|
62
65
|
</div>
|
|
63
66
|
<div className={styles.transferFeeComparison__footer}>
|
|
@@ -7,7 +7,7 @@ import Locale from '../domain/Locale';
|
|
|
7
7
|
|
|
8
8
|
import TransferFeeComparisonContainer from './TransferFeeComparisonContainer';
|
|
9
9
|
import { QUOTE_API } from './mocks/QuoteApi';
|
|
10
|
-
import { ALL_QUOTES } from './mocks/Quotes';
|
|
10
|
+
import { ALL_QUOTES, WISE_QUOTE_WITH_HIDDEN_FEE } from './mocks/Quotes';
|
|
11
11
|
import SEND_AMOUNT from './mocks/send-amount';
|
|
12
12
|
import translations from './transfer-fee-comparison-table-row/fee-makeup-popover/assets/translations/translations.json';
|
|
13
13
|
|
|
@@ -66,5 +66,26 @@ describe('TransferFeeComparisonContainer', () => {
|
|
|
66
66
|
|
|
67
67
|
expect(trackEventMock).toHaveBeenCalledTimes(2);
|
|
68
68
|
});
|
|
69
|
+
|
|
70
|
+
it('should call the tracking function when wise has hidden fees', () => {
|
|
71
|
+
render(
|
|
72
|
+
<IntlProvider locale="en" messages={translations.en}>
|
|
73
|
+
<TransferFeeComparisonContainer
|
|
74
|
+
enableLargestProviderFiltering
|
|
75
|
+
quoteApi={QUOTE_API}
|
|
76
|
+
locale={Locale.EN}
|
|
77
|
+
quotes={[WISE_QUOTE_WITH_HIDDEN_FEE]}
|
|
78
|
+
sendAmount={SEND_AMOUNT}
|
|
79
|
+
urlLocale="gb"
|
|
80
|
+
trackEvent={trackEventMock}
|
|
81
|
+
requiredNumberOfLargestProviders={1}
|
|
82
|
+
/>
|
|
83
|
+
</IntlProvider>,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const feePopovers = screen.queryAllByRole('button', { name: 'What makes up this fee' });
|
|
87
|
+
expect(feePopovers.length).toBeGreaterThan(0);
|
|
88
|
+
expect(trackEventMock).toHaveBeenCalledTimes(1);
|
|
89
|
+
});
|
|
69
90
|
});
|
|
70
91
|
});
|
|
@@ -3,6 +3,7 @@ import React, { useEffect, useState } from 'react';
|
|
|
3
3
|
|
|
4
4
|
import { getSupportedLocale } from '../common/getSupportedLocale/getSupportedLocale';
|
|
5
5
|
import Locale from '../domain/Locale';
|
|
6
|
+
import QuoteApi from '../domain/QuoteApi';
|
|
6
7
|
import { filter, hasEnoughProviders } from '../provider-filters/largest-provider';
|
|
7
8
|
import TW_ALIAS from '../resources/provider-constants';
|
|
8
9
|
import { EventName, TrackEventFn, WidgetName } from '../resources/tracking/types';
|
|
@@ -11,7 +12,6 @@ import TransferFeeComparison from './TransferFeeComparison';
|
|
|
11
12
|
import Money from './domain/Money';
|
|
12
13
|
import ProviderFilteringOption from './domain/ProviderFilteringOption';
|
|
13
14
|
import Quote from './domain/Quote';
|
|
14
|
-
import QuoteApi from '../domain/QuoteApi';
|
|
15
15
|
|
|
16
16
|
export type TransferFeeComparisonContainerProps = {
|
|
17
17
|
sendAmount: Money;
|
|
@@ -108,6 +108,13 @@ const TransferFeeComparisonContainer = ({
|
|
|
108
108
|
});
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
+
const onWiseWithHiddenFees = () => {
|
|
112
|
+
const trackingAttribute = getTrackingAttributes();
|
|
113
|
+
trackEvent(WidgetName.TransferFeeComparison, EventName.WiseHasHiddenFee, {
|
|
114
|
+
...trackingAttribute,
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
|
|
111
118
|
const filterToggleEnabled =
|
|
112
119
|
enableLargestProviderFiltering &&
|
|
113
120
|
hasEnoughProviders(quotes, urlLocale, requiredNumberOfLargestProviders);
|
|
@@ -134,6 +141,7 @@ const TransferFeeComparisonContainer = ({
|
|
|
134
141
|
onFeePopoverClick={onFeePopoverClick}
|
|
135
142
|
onMobileRowClick={onMobileRowClick}
|
|
136
143
|
onRowVisible={onRowVisible}
|
|
144
|
+
onWiseWithHiddenFees={onWiseWithHiddenFees}
|
|
137
145
|
/>
|
|
138
146
|
);
|
|
139
147
|
};
|
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
import TransferFeeComparisonQuote, { FeeType } from '../domain/Quote';
|
|
2
2
|
import MIDMARKET_RATE from '../mocks/midmarket-rate';
|
|
3
3
|
|
|
4
|
+
const WISE_QUOTE_WITH_HIDDEN_FEE = {
|
|
5
|
+
provider: {
|
|
6
|
+
alias: 'transferwise',
|
|
7
|
+
name: 'Wise',
|
|
8
|
+
logoUrl: 'https://wise.com/public-resources/assets/logos/wise/brand_logo_inverse.svg',
|
|
9
|
+
partner: false,
|
|
10
|
+
},
|
|
11
|
+
route: {
|
|
12
|
+
sourceCurrency: 'GBP',
|
|
13
|
+
targetCurrency: 'EUR',
|
|
14
|
+
},
|
|
15
|
+
rate: MIDMARKET_RATE,
|
|
16
|
+
fees: {
|
|
17
|
+
breakdown: [
|
|
18
|
+
{
|
|
19
|
+
type: FeeType.MARKETED,
|
|
20
|
+
amount: {
|
|
21
|
+
currency: 'GBP',
|
|
22
|
+
value: 3.69,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: FeeType.HIDDEN,
|
|
27
|
+
amount: {
|
|
28
|
+
currency: 'GBP',
|
|
29
|
+
value: 1,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
total: {
|
|
34
|
+
currency: 'GBP',
|
|
35
|
+
value: 4.69,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
receiveAmount: {
|
|
39
|
+
currency: 'EUR',
|
|
40
|
+
value: 1170.21,
|
|
41
|
+
},
|
|
42
|
+
sendAmount: {
|
|
43
|
+
currency: 'GBP',
|
|
44
|
+
value: 996.2,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
4
48
|
const WISE_QUOTE = {
|
|
5
49
|
provider: {
|
|
6
50
|
alias: 'transferwise',
|
|
@@ -165,6 +209,7 @@ const ALL_QUOTES: TransferFeeComparisonQuote[] = [
|
|
|
165
209
|
|
|
166
210
|
export {
|
|
167
211
|
WISE_QUOTE,
|
|
212
|
+
WISE_QUOTE_WITH_HIDDEN_FEE,
|
|
168
213
|
TRANSPARENT_PARTNER_QUOTE,
|
|
169
214
|
TRANSPARENT_NON_PARTNER_QUOTE,
|
|
170
215
|
NON_TRANSPARENT_NON_PARTNER_QUOTE,
|
package/src/transfer-fee-comparison/transfer-fee-comparison-table/TransferFeeComparisonTable.tsx
CHANGED
|
@@ -19,6 +19,7 @@ export type TransferFeeComparisonTableProps = {
|
|
|
19
19
|
onFeePopoverClick?: (providerName: string) => void;
|
|
20
20
|
onMobileRowClick?: (providerName: string) => void;
|
|
21
21
|
onRowVisible?: (providerName: string) => void;
|
|
22
|
+
onWiseWithHiddenFees?: () => void;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
export const TransferFeeComparisonTable = ({
|
|
@@ -30,6 +31,7 @@ export const TransferFeeComparisonTable = ({
|
|
|
30
31
|
onFeePopoverClick,
|
|
31
32
|
onMobileRowClick,
|
|
32
33
|
onRowVisible,
|
|
34
|
+
onWiseWithHiddenFees,
|
|
33
35
|
}: TransferFeeComparisonTableProps): JSX.Element => {
|
|
34
36
|
return (
|
|
35
37
|
<table className={componentStyles.transferFeeComparisonTable__rectangle}>
|
|
@@ -20,6 +20,7 @@ export type TransferFeeComparisonTableRowProps = {
|
|
|
20
20
|
onFeePopoverClick?: (providerName: string) => void;
|
|
21
21
|
onMobileRowClick?: (providerName: string) => void;
|
|
22
22
|
onRowVisible?: (providerName: string) => void;
|
|
23
|
+
onWiseWithHiddenFees?: () => void;
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
const TransferFeeComparisonTableRow = ({
|
|
@@ -31,6 +32,7 @@ const TransferFeeComparisonTableRow = ({
|
|
|
31
32
|
onFeePopoverClick,
|
|
32
33
|
onMobileRowClick,
|
|
33
34
|
onRowVisible,
|
|
35
|
+
onWiseWithHiddenFees,
|
|
34
36
|
}: TransferFeeComparisonTableRowProps): JSX.Element => {
|
|
35
37
|
const hiddenFee = quote.fees.breakdown.find((fee) => fee.type === FeeType.HIDDEN)?.amount || {
|
|
36
38
|
currency: quote.route.sourceCurrency,
|
|
@@ -39,6 +41,10 @@ const TransferFeeComparisonTableRow = ({
|
|
|
39
41
|
const [feeBreakdownOpen, setFeeBreakdownOpen] = useState(false);
|
|
40
42
|
const isMobile = IsMobile();
|
|
41
43
|
|
|
44
|
+
if (quote.provider.alias === TW_ALIAS && hiddenFee.value > 0) {
|
|
45
|
+
onWiseWithHiddenFees?.();
|
|
46
|
+
}
|
|
47
|
+
|
|
42
48
|
const { ref, inView } = useInView({
|
|
43
49
|
threshold: 0.5,
|
|
44
50
|
triggerOnce: true,
|
|
@@ -78,7 +84,9 @@ const TransferFeeComparisonTableRow = ({
|
|
|
78
84
|
<td className={componentStyles.row__fee}>
|
|
79
85
|
<TotalFeeAndHiddenFee
|
|
80
86
|
totalFee={quote.fees.total}
|
|
81
|
-
hiddenFee={
|
|
87
|
+
hiddenFee={
|
|
88
|
+
isProviderWise(quote) ? { value: 0, currency: hiddenFee.currency } : hiddenFee
|
|
89
|
+
}
|
|
82
90
|
darkMode={isProviderWise(quote)}
|
|
83
91
|
locale={locale}
|
|
84
92
|
/>
|
|
@@ -91,6 +99,7 @@ const TransferFeeComparisonTableRow = ({
|
|
|
91
99
|
onClose={() => setFeeBreakdownOpen(false)}
|
|
92
100
|
urlLocale={urlLocale}
|
|
93
101
|
locale={locale}
|
|
102
|
+
isProviderWise={isProviderWise(quote)}
|
|
94
103
|
onPopoverClick={() => {
|
|
95
104
|
onFeePopoverClick && onFeePopoverClick(quote.provider.name);
|
|
96
105
|
}}
|
|
@@ -18,6 +18,7 @@ export type FeeMakeupPopoverProps = {
|
|
|
18
18
|
onClose: () => void;
|
|
19
19
|
urlLocale: string;
|
|
20
20
|
locale: Locale;
|
|
21
|
+
isProviderWise: boolean;
|
|
21
22
|
onPopoverClick?: () => void;
|
|
22
23
|
};
|
|
23
24
|
|
|
@@ -28,9 +29,10 @@ const FeeMakeupPopover = ({
|
|
|
28
29
|
onClose,
|
|
29
30
|
urlLocale,
|
|
30
31
|
locale,
|
|
32
|
+
isProviderWise,
|
|
31
33
|
onPopoverClick,
|
|
32
34
|
}: FeeMakeupPopoverProps): JSX.Element => {
|
|
33
|
-
const content = PopoverContent(quote, midmarketRate, urlLocale);
|
|
35
|
+
const content = PopoverContent(quote, midmarketRate, urlLocale, isProviderWise);
|
|
34
36
|
const messages = translations[locale];
|
|
35
37
|
const intl = createIntl({ locale: locale, messages: messages });
|
|
36
38
|
|
|
@@ -60,8 +62,9 @@ const PopoverContent = (
|
|
|
60
62
|
quote: TransferFeeComparisonQuote,
|
|
61
63
|
midmarketRate: number,
|
|
62
64
|
urlLocale: string,
|
|
65
|
+
isProviderWise: boolean,
|
|
63
66
|
): JSX.Element => {
|
|
64
|
-
const hiddenFeesAmount = getFeesSumByType(quote, FeeType.HIDDEN);
|
|
67
|
+
const hiddenFeesAmount = isProviderWise ? 0 : getFeesSumByType(quote, FeeType.HIDDEN);
|
|
65
68
|
const marketedFeesAmount = getFeesSumByType(quote, FeeType.MARKETED);
|
|
66
69
|
|
|
67
70
|
if (hiddenFeesAmount > 0) {
|
|
@@ -81,6 +84,7 @@ const PopoverContent = (
|
|
|
81
84
|
midmarketRate={midmarketRate}
|
|
82
85
|
marketedFeesAmount={marketedFeesAmount}
|
|
83
86
|
urlLocale={urlLocale}
|
|
87
|
+
isProviderWise={isProviderWise}
|
|
84
88
|
/>
|
|
85
89
|
);
|
|
86
90
|
}
|
|
@@ -12,6 +12,7 @@ type TransparentFeeElementProps = {
|
|
|
12
12
|
midmarketRate: number;
|
|
13
13
|
marketedFeesAmount: number;
|
|
14
14
|
urlLocale: string;
|
|
15
|
+
isProviderWise: boolean;
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
const TransparentFeeElement = ({
|
|
@@ -19,12 +20,15 @@ const TransparentFeeElement = ({
|
|
|
19
20
|
midmarketRate,
|
|
20
21
|
marketedFeesAmount,
|
|
21
22
|
urlLocale,
|
|
23
|
+
isProviderWise,
|
|
22
24
|
}: TransparentFeeElementProps): JSX.Element => {
|
|
23
25
|
const COMPARE_LINK = createUrl(
|
|
24
26
|
`/${urlLocale}/compare?sourceCurrency=${quote.route.sourceCurrency}&targetCurrency=${quote.route.targetCurrency}`,
|
|
25
27
|
);
|
|
26
28
|
|
|
27
|
-
const
|
|
29
|
+
const currentProviderRate = isProviderWise ? midmarketRate : quote.rate;
|
|
30
|
+
|
|
31
|
+
const conversionRateTextId: string = getRateTextId(currentProviderRate, midmarketRate);
|
|
28
32
|
|
|
29
33
|
return (
|
|
30
34
|
<div className={componentStyles.feeMakeupPopover__contentContainer}>
|
|
@@ -46,7 +50,7 @@ const TransparentFeeElement = ({
|
|
|
46
50
|
id={conversionRateTextId}
|
|
47
51
|
values={{
|
|
48
52
|
providerName: quote.provider.name,
|
|
49
|
-
conversionRate:
|
|
53
|
+
conversionRate: currentProviderRate.toFixed(5),
|
|
50
54
|
midmarketRate: midmarketRate.toFixed(5),
|
|
51
55
|
a: (chunks: string) => (
|
|
52
56
|
<a href={COMPARE_LINK} target="_blank" rel="noreferrer">
|