Skip to content

Commit

Permalink
refactor: remove derived FX from account configurations, fix duplicat…
Browse files Browse the repository at this point in the history
…ed key error (#17962)
  • Loading branch information
heorhi-deriv authored Jan 14, 2025
1 parent 28943c8 commit 30b4e37
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import React from 'react';
import { useHistory } from 'react-router-dom';
import classNames from 'classnames';
import { Text, Icon, PageOverlay, CFDCompareAccountsCarousel } from '@deriv/components';

import { CFDCompareAccountsCarousel, Icon, PageOverlay, Text } from '@deriv/components';
import { useIsRtl } from '@deriv/hooks';
import { routes } from '@deriv/shared';
import { Localize, localize } from '@deriv/translations';
import { observer, useStore } from '@deriv/stores';
import { Localize, localize } from '@deriv/translations';
import { useDevice } from '@deriv-com/ui';
import { useIsRtl } from '@deriv/hooks';
import CFDCompareAccountsCard from './cfd-compare-accounts-card';

import {
getSortedCFDAvailableAccounts,
ctrader_data,
dxtrade_data,
getCtraderDemoData,
getDxtradeDemoData,
getEUAvailableAccounts,
getMT5DemoData,
getDxtradeDemoData,
getCtraderDemoData,
dxtrade_data,
ctrader_data,
getSortedCFDAvailableAccounts,
} from '../../Helpers/compare-accounts-config';

import CFDCompareAccountsCard from './cfd-compare-accounts-card';

const CompareCFDs = observer(() => {
const { isDesktop } = useDevice();
const is_rtl = useIsRtl();
Expand Down Expand Up @@ -147,7 +150,7 @@ const CompareCFDs = observer(() => {
{all_cfd_available_accounts.map(item => (
<CFDCompareAccountsCard
trading_platforms={item}
key={item.market_type + item.shortcode}
key={item.market_type + item.shortcode + (item?.product || '')}
is_eu_user={is_eu_user}
is_demo={is_demo}
/>
Expand Down
12 changes: 3 additions & 9 deletions packages/cfd/src/Helpers/compare-accounts-config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { localize } from '@deriv/translations';

import { TInstrumentsIcon, TModifiedTradingPlatformAvailableAccount, TProducts } from '../Components/props.types';
import { CFD_PLATFORMS, MARKET_TYPE, JURISDICTION, REGION, MARKET_TYPE_SHORTCODE, PRODUCT } from './cfd-config';

import { CFD_PLATFORMS, JURISDICTION, MARKET_TYPE, MARKET_TYPE_SHORTCODE, PRODUCT, REGION } from './cfd-config';

// Map the accounts according to the market type
const getHighlightedIconLabel = (
Expand Down Expand Up @@ -40,8 +42,6 @@ const getHighlightedIconLabel = (
return 'forex';
} else if (item === 'ETFs') {
return 'ETFs'; // Preserve the original form for ETFs
} else if (item === 'Derived FX') {
return 'derived_FX'; // Handle FX case
}
return item.toLowerCase().replace(/\s+/g, '_'); // Replace spaces with underscores
});
Expand Down Expand Up @@ -69,12 +69,6 @@ const getHighlightedIconLabel = (
text: localize('Basket indices'),
is_available: selected_region === REGION.NON_EU,
},
{
id: 'derived_FX',
icon: 'DerivedFX',
text: localize('Derived FX'),
is_available: selected_region === REGION.NON_EU,
},
];

return instrumentsData.map((item: TInstrumentsIcon) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ const getHighlightedIconLabel = (values: TValues) => {
{ highlighted: shouldHighlight('Basket indices'), icon: 'Baskets', text: localize('Basket indices') },
] as const)
: []),
...(!isEuRegion
? ([
{ highlighted: shouldHighlight('Derived FX'), icon: 'DerivedFX', text: localize('Derived FX') },
] as const)
: []),
] as const;
};

Expand Down

0 comments on commit 30b4e37

Please sign in to comment.