From 90dd55781adf0f458a7598d6e3efd7b14a14cf33 Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Thu, 5 Dec 2024 14:52:50 +0800 Subject: [PATCH 01/22] fix: add product to create unique key --- .../Containers/cfd-compare-accounts/cfd-compare-accounts.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts.tsx b/packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts.tsx index b6f97a23ece3..90ace019f07b 100644 --- a/packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts.tsx +++ b/packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts.tsx @@ -114,7 +114,7 @@ const CompareCFDs = observer(() => { {all_cfd_available_accounts.map(item => ( From c984857d01099ee80543eed8b5a93d0ea364709f Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Thu, 5 Dec 2024 14:54:18 +0800 Subject: [PATCH 02/22] fix: add gold to type --- packages/cfd/src/Components/props.types.ts | 2 +- packages/stores/types.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cfd/src/Components/props.types.ts b/packages/cfd/src/Components/props.types.ts index 0f354d3c513b..1883762fa79a 100644 --- a/packages/cfd/src/Components/props.types.ts +++ b/packages/cfd/src/Components/props.types.ts @@ -9,7 +9,7 @@ export type TCFDPlatform = 'dxtrade' | 'mt5' | 'ctrader'; export type TCFDsPlatformType = 'dxtrade' | 'mt5' | 'ctrader' | ''; -export type TProducts = 'swap_free' | 'zero_spread' | 'ctrader' | 'derivx' | 'financial' | 'standard' | 'stp'; +export type TProducts = 'swap_free' | 'zero_spread' | 'ctrader' | 'derivx' | 'financial' | 'standard' | 'stp' | 'gold'; export type TShortcode = DetailsOfEachMT5Loginid['landing_company_short']; diff --git a/packages/stores/types.ts b/packages/stores/types.ts index 26124684d938..429e6ec219ea 100644 --- a/packages/stores/types.ts +++ b/packages/stores/types.ts @@ -28,7 +28,7 @@ import type { } from '@deriv/api-types'; import type { FeatureFlagsStore } from './src/stores'; -import { TContractInfo } from '../shared/src/utils/contract'; +import { TContractInfo } from '@deriv/shared/src/utils/contract/contract'; type TRoutes = | '/404' @@ -105,7 +105,7 @@ type TPopulateSettingsExtensionsMenuItem = { value: (props: T) => JSX.Element; }; -type TProduct = 'swap_free' | 'zero_spread' | 'ctrader' | 'derivx' | 'financial' | 'standard' | 'stp'; +type TProduct = 'swap_free' | 'zero_spread' | 'ctrader' | 'derivx' | 'financial' | 'standard' | 'stp' | 'gold'; type TRegionAvailability = 'Non-EU' | 'EU' | 'All'; From 5d19e4f0d82030cf427368cd7fac4bd53daca85e Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Thu, 5 Dec 2024 14:56:22 +0800 Subject: [PATCH 03/22] feat: add generateMarketTypeShortcode --- .../src/Helpers/compare-accounts-config.ts | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/packages/cfd/src/Helpers/compare-accounts-config.ts b/packages/cfd/src/Helpers/compare-accounts-config.ts index 9935902e5b71..1dcc11fdc873 100644 --- a/packages/cfd/src/Helpers/compare-accounts-config.ts +++ b/packages/cfd/src/Helpers/compare-accounts-config.ts @@ -207,7 +207,7 @@ const getSortedCFDAvailableAccounts = (available_accounts: TModifiedTradingPlatf item.product === PRODUCT.SWAPFREE && item.is_default_jurisdiction === 'true' ) - .map(item => ({ ...item, platform: CFD_PLATFORMS.MT5 } as const)); + .map(item => ({ ...item, platform: CFD_PLATFORMS.MT5 }) as const); const zero_spread_accounts = available_accounts .filter( item => @@ -215,7 +215,7 @@ const getSortedCFDAvailableAccounts = (available_accounts: TModifiedTradingPlatf item.product === PRODUCT.ZEROSPREAD && item.is_default_jurisdiction === 'true' ) - .map(item => ({ ...item, platform: CFD_PLATFORMS.MT5 } as const)); + .map(item => ({ ...item, platform: CFD_PLATFORMS.MT5 }) as const); const financial_accounts = available_accounts .filter( item => @@ -223,10 +223,10 @@ const getSortedCFDAvailableAccounts = (available_accounts: TModifiedTradingPlatf item.shortcode !== JURISDICTION.MALTA_INVEST && item.is_default_jurisdiction === 'true' ) - .map(item => ({ ...item, platform: CFD_PLATFORMS.MT5 } as const)); + .map(item => ({ ...item, platform: CFD_PLATFORMS.MT5 }) as const); const gaming_accounts = available_accounts .filter(item => item.market_type === MARKET_TYPE.GAMING && item.is_default_jurisdiction === 'true') - .map(item => ({ ...item, platform: CFD_PLATFORMS.MT5 } as const)); + .map(item => ({ ...item, platform: CFD_PLATFORMS.MT5 }) as const); return [...gaming_accounts, ...financial_accounts, ...swap_free_accounts, ...zero_spread_accounts]; }; @@ -239,7 +239,7 @@ const getEUAvailableAccounts = (available_accounts: TModifiedTradingPlatformAvai item.shortcode === JURISDICTION.MALTA_INVEST && item.is_default_jurisdiction === 'true' ) - .map(item => ({ ...item, platform: CFD_PLATFORMS.MT5 } as const)); + .map(item => ({ ...item, platform: CFD_PLATFORMS.MT5 }) as const); return [...financial_accounts]; }; @@ -319,6 +319,31 @@ const getCtraderDemoData = (available_accounts: TModifiedTradingPlatformAvailabl return available_accounts.filter(item => item.platform === CFD_PLATFORMS.CTRADER); }; +const generateMarketTypeShortcode = ( + trading_platforms: TModifiedTradingPlatformAvailableAccount, + market_type: TModifiedTradingPlatformAvailableAccount['market_type'] | 'CFDs' +) => { + // First check if platform is MT5 + if (trading_platforms.platform !== CFD_PLATFORMS.MT5) { + return market_type ?? ''; + } + + // Check conditions for generating full shortcode + const isAllMarketType = market_type === MARKET_TYPE.ALL; + const isSTPProduct = trading_platforms.product === PRODUCT.STP; + const isGoldProduct = trading_platforms.product === PRODUCT.GOLD; + + if (isAllMarketType || isSTPProduct) { + return `${market_type}_${trading_platforms.product}_${trading_platforms.shortcode}`; + } + + if (isGoldProduct) { + return `${market_type}_${trading_platforms.product}`; + } + + return market_type ?? ''; +}; + export { getHighlightedIconLabel, getJuridisctionDescription, @@ -336,4 +361,5 @@ export { getMT5DemoData, getDxtradeDemoData, getCtraderDemoData, + generateMarketTypeShortcode, }; From 0545f155d4a291b89a8c70f700b3138568ea4d8e Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Thu, 5 Dec 2024 14:57:55 +0800 Subject: [PATCH 04/22] feat: add new tag to gold account --- .../cfd-compare-accounts/cfd-compare-accounts-card.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts-card.tsx b/packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts-card.tsx index 1900c679cd1c..46ab7faecc2f 100644 --- a/packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts-card.tsx +++ b/packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts-card.tsx @@ -13,7 +13,7 @@ const CFDCompareAccountsCard = ({ trading_platforms, is_eu_user, is_demo }: TCom
- {trading_platforms.product === PRODUCT.ZEROSPREAD && ( + {trading_platforms.product === PRODUCT.GOLD && ( Date: Thu, 5 Dec 2024 14:58:43 +0800 Subject: [PATCH 05/22] feat: used generate market type shortcode func --- .../cfd-compare-accounts-title-icon.tsx | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts-title-icon.tsx b/packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts-title-icon.tsx index 9b7e97cc87d9..c61d15daa3af 100644 --- a/packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts-title-icon.tsx +++ b/packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts-title-icon.tsx @@ -1,22 +1,26 @@ import React from 'react'; -import { Text, Popover } from '@deriv/components'; -import { useDevice } from '@deriv-com/ui'; + +import { Popover, Text } from '@deriv/components'; import { localize } from '@deriv/translations'; -import TradigPlatformIconProps from '../../Assets/svgs/trading-platform'; +import { useDevice } from '@deriv-com/ui'; + import { TCompareAccountsCard } from 'Components/props.types'; -import { getAccountCardTitle, getMarketType, getAccountIcon } from '../../Helpers/compare-accounts-config'; -import { CFD_PLATFORMS, MARKET_TYPE, MARKET_TYPE_SHORTCODE } from '../../Helpers/cfd-config'; -import { PRODUCT } from '@deriv/shared'; + +import TradigPlatformIconProps from '../../Assets/svgs/trading-platform'; +import { CFD_PLATFORMS, MARKET_TYPE_SHORTCODE } from '../../Helpers/cfd-config'; +import { + generateMarketTypeShortcode, + getAccountCardTitle, + getAccountIcon, + getMarketType, +} from '../../Helpers/compare-accounts-config'; const CFDCompareAccountsTitleIcon = ({ trading_platforms, is_eu_user, is_demo }: TCompareAccountsCard) => { const { isDesktop } = useDevice(); const market_type = !is_eu_user ? getMarketType(trading_platforms) : 'CFDs'; - const market_type_shortcode = - trading_platforms.platform === CFD_PLATFORMS.MT5 && - (market_type === MARKET_TYPE.ALL || trading_platforms.product === PRODUCT.STP) - ? `${market_type}_${trading_platforms.product}_${trading_platforms.shortcode}` - : market_type ?? ''; + const market_type_shortcode = generateMarketTypeShortcode(trading_platforms, market_type); + const jurisdiction_card_icon = trading_platforms.platform === CFD_PLATFORMS.DXTRADE || trading_platforms.platform === CFD_PLATFORMS.CTRADER ? getAccountIcon(trading_platforms.platform) From b3e549fa15969319d73115a64192af0a82c22d2d Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Thu, 5 Dec 2024 14:59:15 +0800 Subject: [PATCH 06/22] feat: added gold to product obj --- packages/cfd/src/Helpers/cfd-config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cfd/src/Helpers/cfd-config.ts b/packages/cfd/src/Helpers/cfd-config.ts index 89a89035a48c..52813016b9b1 100644 --- a/packages/cfd/src/Helpers/cfd-config.ts +++ b/packages/cfd/src/Helpers/cfd-config.ts @@ -24,6 +24,7 @@ export const PRODUCT = { CTRADER: 'ctrader', DERIVX: 'derivx', STP: 'stp', + GOLD: 'gold', } as const; export const MOBILE_PLATFORMS = { From 23fe2dc38a9a7297e6ed96c2236a3149769f16c8 Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Thu, 5 Dec 2024 15:00:07 +0800 Subject: [PATCH 07/22] feat: mapped gold account in getSortedCFDAvailableAccounts --- .../src/Helpers/compare-accounts-config.ts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/cfd/src/Helpers/compare-accounts-config.ts b/packages/cfd/src/Helpers/compare-accounts-config.ts index 1dcc11fdc873..15020ab00e7e 100644 --- a/packages/cfd/src/Helpers/compare-accounts-config.ts +++ b/packages/cfd/src/Helpers/compare-accounts-config.ts @@ -221,13 +221,31 @@ const getSortedCFDAvailableAccounts = (available_accounts: TModifiedTradingPlatf item => item.market_type === MARKET_TYPE.FINANCIAL && item.shortcode !== JURISDICTION.MALTA_INVEST && + item.product !== PRODUCT.GOLD && item.is_default_jurisdiction === 'true' ) .map(item => ({ ...item, platform: CFD_PLATFORMS.MT5 }) as const); + + const gold_accounts = available_accounts + .filter( + item => + item.market_type === MARKET_TYPE.FINANCIAL && + item.shortcode !== JURISDICTION.MALTA_INVEST && + item.product === PRODUCT.GOLD && + item.is_default_jurisdiction === 'true' + ) + .map(item => ({ ...item, platform: CFD_PLATFORMS.MT5 }) as const); + const gaming_accounts = available_accounts .filter(item => item.market_type === MARKET_TYPE.GAMING && item.is_default_jurisdiction === 'true') .map(item => ({ ...item, platform: CFD_PLATFORMS.MT5 }) as const); - return [...gaming_accounts, ...financial_accounts, ...swap_free_accounts, ...zero_spread_accounts]; + return [ + ...gaming_accounts, + ...financial_accounts, + ...swap_free_accounts, + ...zero_spread_accounts, + ...gold_accounts, + ]; }; // Get the maltainvest accounts for EU and DIEL clients From d15f44348adcba6978b54c71a2e7dfe0d300c7d0 Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Fri, 6 Dec 2024 11:17:24 +0800 Subject: [PATCH 08/22] feat: added gold icon --- .../src/Assets/svgs/trading-platform/ic-appstore-gold.svg | 1 + packages/cfd/src/Assets/svgs/trading-platform/index.tsx | 4 +++- packages/cfd/src/Helpers/compare-accounts-config.ts | 7 ++++++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 packages/cfd/src/Assets/svgs/trading-platform/ic-appstore-gold.svg diff --git a/packages/cfd/src/Assets/svgs/trading-platform/ic-appstore-gold.svg b/packages/cfd/src/Assets/svgs/trading-platform/ic-appstore-gold.svg new file mode 100644 index 000000000000..db12abf55932 --- /dev/null +++ b/packages/cfd/src/Assets/svgs/trading-platform/ic-appstore-gold.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/cfd/src/Assets/svgs/trading-platform/index.tsx b/packages/cfd/src/Assets/svgs/trading-platform/index.tsx index 82462dd8a01a..8662f25be9b6 100644 --- a/packages/cfd/src/Assets/svgs/trading-platform/index.tsx +++ b/packages/cfd/src/Assets/svgs/trading-platform/index.tsx @@ -5,9 +5,10 @@ import CTrader from './ic-appstore-ctrader.svg'; import DerivX from './ic-appstore-deriv-x.svg'; import Derived from './ic-appstore-derived.svg'; import Financial from './ic-appstore-financial.svg'; +import Gold from './ic-appstore-gold.svg'; +import Standard from './ic-appstore-standard.svg'; import SwapFree from './ic-appstore-swap-free.svg'; import ZeroSpread from './ic-appstore-zero-spread.svg'; -import Standard from './ic-appstore-standard.svg'; export interface IconProps { icon: T; @@ -25,6 +26,7 @@ export const PlatformIcons = { DerivX, ZeroSpread, Standard, + Gold, }; const TradingPlatformIcon = ({ icon, className, size, onClick }: IconProps) => { diff --git a/packages/cfd/src/Helpers/compare-accounts-config.ts b/packages/cfd/src/Helpers/compare-accounts-config.ts index 15020ab00e7e..46a1fd4e9740 100644 --- a/packages/cfd/src/Helpers/compare-accounts-config.ts +++ b/packages/cfd/src/Helpers/compare-accounts-config.ts @@ -119,7 +119,12 @@ const getAccountIcon = (shortcode: string, product?: TProducts) => { case MARKET_TYPE.SYNTHETIC: return 'Standard'; case MARKET_TYPE.FINANCIAL: - return 'Financial'; + switch (product) { + case PRODUCT.GOLD: + return 'Gold'; + default: + return 'Financial'; + } case MARKET_TYPE.ALL: switch (product) { case PRODUCT.ZEROSPREAD: From af71e6b05a3ec12a76ef6e0bea33c807bcec9d01 Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Fri, 6 Dec 2024 11:22:10 +0800 Subject: [PATCH 09/22] feat: added gold title --- packages/cfd/src/Helpers/cfd-config.ts | 1 + packages/cfd/src/Helpers/compare-accounts-config.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/packages/cfd/src/Helpers/cfd-config.ts b/packages/cfd/src/Helpers/cfd-config.ts index 52813016b9b1..ebe672e8120f 100644 --- a/packages/cfd/src/Helpers/cfd-config.ts +++ b/packages/cfd/src/Helpers/cfd-config.ts @@ -58,6 +58,7 @@ export const MARKET_TYPE_SHORTCODE = { FINANCIAL: 'financial', FINANCIAL_LABUAN: 'financial_stp_labuan', FINANCIAL_MALTA_INVEST: 'financial_maltainvest', + FINANCIAL_GOLD: 'financial_gold', ALL_SWAP_FREE_SVG: 'all_swap_free_svg', ALL_ZERO_SPREAD_BVI: 'all_zero_spread_bvi', ALL_ZS_BVI: 'all_bvi', diff --git a/packages/cfd/src/Helpers/compare-accounts-config.ts b/packages/cfd/src/Helpers/compare-accounts-config.ts index 46a1fd4e9740..f8e9cbfccab6 100644 --- a/packages/cfd/src/Helpers/compare-accounts-config.ts +++ b/packages/cfd/src/Helpers/compare-accounts-config.ts @@ -77,6 +77,8 @@ const getAccountCardTitle = (shortcode: string, is_demo?: boolean) => { return is_demo ? localize('Financial Demo') : localize('Financial'); case MARKET_TYPE_SHORTCODE.FINANCIAL_LABUAN: return localize('Financial - STP'); + case MARKET_TYPE_SHORTCODE.FINANCIAL_GOLD: + return is_demo ? localize('Gold Demo') : localize('Gold'); case MARKET_TYPE_SHORTCODE.ALL_SWAP_FREE_SVG: return is_demo ? localize('Swap-Free Demo') : localize('Swap-Free'); case MARKET_TYPE_SHORTCODE.ALL_ZERO_SPREAD_BVI: From 8823116022b2c1b84a7349e6de53f819f3b89227 Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Fri, 6 Dec 2024 11:25:54 +0800 Subject: [PATCH 10/22] fix: forex instruments --- packages/cfd/src/Helpers/compare-accounts-config.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/cfd/src/Helpers/compare-accounts-config.ts b/packages/cfd/src/Helpers/compare-accounts-config.ts index f8e9cbfccab6..76d720901197 100644 --- a/packages/cfd/src/Helpers/compare-accounts-config.ts +++ b/packages/cfd/src/Helpers/compare-accounts-config.ts @@ -8,12 +8,17 @@ const getHighlightedIconLabel = ( selected_region?: string ): TInstrumentsIcon[] => { const market_type = getMarketType(trading_platforms); - const market_type_shortcode = market_type.concat('_', trading_platforms.shortcode ?? ''); + const market_type_shortcode = + trading_platforms.product === PRODUCT.GOLD + ? market_type.concat('_', trading_platforms.product) + : market_type.concat('_', trading_platforms.shortcode ?? ''); const getForexLabel = () => { if (selected_region === REGION.EU) { return localize('Forex'); } else if (market_type_shortcode === MARKET_TYPE_SHORTCODE.FINANCIAL_LABUAN) { return localize('Forex: standard/exotic'); + } else if (market_type_shortcode === MARKET_TYPE_SHORTCODE.FINANCIAL_GOLD) { + return localize('Forex'); } else if ( (trading_platforms.platform === CFD_PLATFORMS.MT5 && market_type_shortcode === MARKET_TYPE_SHORTCODE.ALL_SWAP_FREE_SVG) || From 3fb95a3568d19370a0c478c76700c120485e0887 Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Fri, 6 Dec 2024 12:06:18 +0800 Subject: [PATCH 11/22] fix: fixed eu title and icon --- packages/cfd/src/Helpers/cfd-config.ts | 2 ++ packages/cfd/src/Helpers/compare-accounts-config.ts | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/packages/cfd/src/Helpers/cfd-config.ts b/packages/cfd/src/Helpers/cfd-config.ts index ebe672e8120f..1b651232890a 100644 --- a/packages/cfd/src/Helpers/cfd-config.ts +++ b/packages/cfd/src/Helpers/cfd-config.ts @@ -16,6 +16,7 @@ export const MARKET_TYPE = { GAMING: 'gaming', FINANCIAL: 'financial', ALL: 'all', + CFDS: 'CFDs', } as const; export const PRODUCT = { @@ -59,6 +60,7 @@ export const MARKET_TYPE_SHORTCODE = { FINANCIAL_LABUAN: 'financial_stp_labuan', FINANCIAL_MALTA_INVEST: 'financial_maltainvest', FINANCIAL_GOLD: 'financial_gold', + CFDS_GOLD: 'CFDs_gold', ALL_SWAP_FREE_SVG: 'all_swap_free_svg', ALL_ZERO_SPREAD_BVI: 'all_zero_spread_bvi', ALL_ZS_BVI: 'all_bvi', diff --git a/packages/cfd/src/Helpers/compare-accounts-config.ts b/packages/cfd/src/Helpers/compare-accounts-config.ts index 76d720901197..8fe014276c3c 100644 --- a/packages/cfd/src/Helpers/compare-accounts-config.ts +++ b/packages/cfd/src/Helpers/compare-accounts-config.ts @@ -83,6 +83,7 @@ const getAccountCardTitle = (shortcode: string, is_demo?: boolean) => { case MARKET_TYPE_SHORTCODE.FINANCIAL_LABUAN: return localize('Financial - STP'); case MARKET_TYPE_SHORTCODE.FINANCIAL_GOLD: + case MARKET_TYPE_SHORTCODE.CFDS_GOLD: return is_demo ? localize('Gold Demo') : localize('Gold'); case MARKET_TYPE_SHORTCODE.ALL_SWAP_FREE_SVG: return is_demo ? localize('Swap-Free Demo') : localize('Swap-Free'); @@ -132,6 +133,9 @@ const getAccountIcon = (shortcode: string, product?: TProducts) => { default: return 'Financial'; } + case MARKET_TYPE.CFDS: + if (product === PRODUCT.GOLD) return 'Gold'; + break; case MARKET_TYPE.ALL: switch (product) { case PRODUCT.ZEROSPREAD: From d9b18a899ba38b967edd6e323eb3a52f0692c494 Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Fri, 6 Dec 2024 12:09:17 +0800 Subject: [PATCH 12/22] fix: cfds icon --- packages/cfd/src/Helpers/cfd-config.ts | 1 - packages/cfd/src/Helpers/compare-accounts-config.ts | 10 ++++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/cfd/src/Helpers/cfd-config.ts b/packages/cfd/src/Helpers/cfd-config.ts index 1b651232890a..0aad9dbebf05 100644 --- a/packages/cfd/src/Helpers/cfd-config.ts +++ b/packages/cfd/src/Helpers/cfd-config.ts @@ -16,7 +16,6 @@ export const MARKET_TYPE = { GAMING: 'gaming', FINANCIAL: 'financial', ALL: 'all', - CFDS: 'CFDs', } as const; export const PRODUCT = { diff --git a/packages/cfd/src/Helpers/compare-accounts-config.ts b/packages/cfd/src/Helpers/compare-accounts-config.ts index 8fe014276c3c..7fb672635a74 100644 --- a/packages/cfd/src/Helpers/compare-accounts-config.ts +++ b/packages/cfd/src/Helpers/compare-accounts-config.ts @@ -133,9 +133,6 @@ const getAccountIcon = (shortcode: string, product?: TProducts) => { default: return 'Financial'; } - case MARKET_TYPE.CFDS: - if (product === PRODUCT.GOLD) return 'Gold'; - break; case MARKET_TYPE.ALL: switch (product) { case PRODUCT.ZEROSPREAD: @@ -149,7 +146,12 @@ const getAccountIcon = (shortcode: string, product?: TProducts) => { case CFD_PLATFORMS.CTRADER: return 'CTrader'; default: - return 'CFDs'; + switch (product) { + case PRODUCT.GOLD: + return 'Gold'; + default: + return 'CFDs'; + } } }; From 15b74d2b671359d999340e551740e249d69ffc4b Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Fri, 6 Dec 2024 12:12:17 +0800 Subject: [PATCH 13/22] fix: eu sorting --- .../cfd/src/Helpers/compare-accounts-config.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/cfd/src/Helpers/compare-accounts-config.ts b/packages/cfd/src/Helpers/compare-accounts-config.ts index 7fb672635a74..ae1fd1b06b1f 100644 --- a/packages/cfd/src/Helpers/compare-accounts-config.ts +++ b/packages/cfd/src/Helpers/compare-accounts-config.ts @@ -1,6 +1,7 @@ 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 Item from '@deriv/components/src/components/mobile-drawer/mobile-drawer-item'; // Map the accounts according to the market type const getHighlightedIconLabel = ( @@ -273,10 +274,21 @@ const getEUAvailableAccounts = (available_accounts: TModifiedTradingPlatformAvai item => item.market_type === MARKET_TYPE.FINANCIAL && item.shortcode === JURISDICTION.MALTA_INVEST && - item.is_default_jurisdiction === 'true' + item.is_default_jurisdiction === 'true' && + item.product !== PRODUCT.GOLD + ) + .map(item => ({ ...item, platform: CFD_PLATFORMS.MT5 }) as const); + + const gold_accounts = available_accounts + .filter( + item => + item.market_type === MARKET_TYPE.FINANCIAL && + item.shortcode === JURISDICTION.MALTA_INVEST && + item.is_default_jurisdiction === 'true' && + item.product === PRODUCT.GOLD ) .map(item => ({ ...item, platform: CFD_PLATFORMS.MT5 }) as const); - return [...financial_accounts]; + return [...financial_accounts, ...gold_accounts]; }; // Make the Deriv X data same as trading_platform_available_accounts From d98a11a10aab0673805375b05b408635dcd83dbe Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Fri, 6 Dec 2024 12:29:28 +0800 Subject: [PATCH 14/22] fix: eu instruments --- packages/cfd/src/Components/props.types.ts | 1 + .../cfd-instruments-label-highlighted.tsx | 9 +-------- .../instruments-icon-with-label.tsx | 1 + .../cfd/src/Helpers/compare-accounts-config.ts | 17 +++++++++++++---- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/cfd/src/Components/props.types.ts b/packages/cfd/src/Components/props.types.ts index 1883762fa79a..fc4c6fcb4b8a 100644 --- a/packages/cfd/src/Components/props.types.ts +++ b/packages/cfd/src/Components/props.types.ts @@ -249,6 +249,7 @@ export type TInstrumentsIcon = { highlighted?: boolean; className?: string; is_asterisk?: boolean; + is_available?: boolean; }; export type TCompareAccountsCard = { diff --git a/packages/cfd/src/Containers/cfd-compare-accounts/cfd-instruments-label-highlighted.tsx b/packages/cfd/src/Containers/cfd-compare-accounts/cfd-instruments-label-highlighted.tsx index 5d542839c2ab..5d63800f9776 100644 --- a/packages/cfd/src/Containers/cfd-compare-accounts/cfd-instruments-label-highlighted.tsx +++ b/packages/cfd/src/Containers/cfd-compare-accounts/cfd-instruments-label-highlighted.tsx @@ -1,6 +1,4 @@ import React from 'react'; -import { Text } from '@deriv/components'; -import { Localize } from '@deriv/translations'; import InstrumentsIconWithLabel from './instruments-icon-with-label'; import { TInstrumentsIcon, TCompareAccountsCard } from 'Components/props.types'; import { getHighlightedIconLabel } from '../../Helpers/compare-accounts-config'; @@ -17,7 +15,7 @@ const CFDInstrumentsLabelHighlighted = ({ trading_platforms }: TCompareAccountsC {is_eu_user ? ( {iconData - .filter(item => item.highlighted) + .filter(instrument => instrument.is_available !== false) .map(item => ( ))} -
- - - -
) : ( iconData.map(item => ( diff --git a/packages/cfd/src/Containers/cfd-compare-accounts/instruments-icon-with-label.tsx b/packages/cfd/src/Containers/cfd-compare-accounts/instruments-icon-with-label.tsx index 2ff4404647bd..237171117a3e 100644 --- a/packages/cfd/src/Containers/cfd-compare-accounts/instruments-icon-with-label.tsx +++ b/packages/cfd/src/Containers/cfd-compare-accounts/instruments-icon-with-label.tsx @@ -6,6 +6,7 @@ import TradingInstrumentsIcon from '../../Assets/svgs/trading-instruments'; const InstrumentsIconWithLabel = ({ icon, text, highlighted, className, is_asterisk }: TInstrumentsIcon) => { const { isMobile } = useDevice(); + return (
({ From a6b3a7a6b8aed498a0f68bab8de8a087f4575be2 Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Fri, 6 Dec 2024 14:18:19 +0800 Subject: [PATCH 15/22] fix: non eu demo accounts --- packages/cfd/src/Helpers/compare-accounts-config.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/cfd/src/Helpers/compare-accounts-config.ts b/packages/cfd/src/Helpers/compare-accounts-config.ts index de3100e4c57f..ab16872e60ac 100644 --- a/packages/cfd/src/Helpers/compare-accounts-config.ts +++ b/packages/cfd/src/Helpers/compare-accounts-config.ts @@ -361,11 +361,15 @@ const getMT5DemoData = (available_accounts: TModifiedTradingPlatformAvailableAcc const gaming_demo_accounts = available_accounts.filter( item => item.market_type === MARKET_TYPE.GAMING && item.shortcode === JURISDICTION.SVG ); + const gold_demo_accounts = available_accounts.filter( + item => item.market_type === MARKET_TYPE.FINANCIAL && item.product === PRODUCT.GOLD + ); return [ ...gaming_demo_accounts, ...financial_demo_accounts, ...swap_free_demo_accounts, ...zero_spread_demo_accounts, + ...gold_demo_accounts, ]; }; const getDxtradeDemoData = (available_accounts: TModifiedTradingPlatformAvailableAccount[]) => { From 81b5fb25aa110bbc3719c4c33e8789720c4b7ae1 Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Fri, 6 Dec 2024 14:33:36 +0800 Subject: [PATCH 16/22] fix: commit issue --- packages/stores/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stores/types.ts b/packages/stores/types.ts index 2e8f7f7cb3f9..725cb579ff48 100644 --- a/packages/stores/types.ts +++ b/packages/stores/types.ts @@ -27,7 +27,7 @@ import type { WebsiteStatus, } from '@deriv/api-types'; -import { TContractInfo } from '@deriv/shared/src/utils/contract/contract'; +import { TContractInfo } from '../shared/src/utils/contract'; import type { FeatureFlagsStore } from './src/stores'; From 698b4eae3e262b5d840bd46688c79fbc2ecc7762 Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Fri, 6 Dec 2024 14:47:07 +0800 Subject: [PATCH 17/22] fix: test failures --- .../cfd-instruments-label-highlighted.spec.tsx | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/packages/cfd/src/Containers/cfd-compare-accounts/__tests__/cfd-instruments-label-highlighted.spec.tsx b/packages/cfd/src/Containers/cfd-compare-accounts/__tests__/cfd-instruments-label-highlighted.spec.tsx index f496590f33dc..8b47ff2073d3 100644 --- a/packages/cfd/src/Containers/cfd-compare-accounts/__tests__/cfd-instruments-label-highlighted.spec.tsx +++ b/packages/cfd/src/Containers/cfd-compare-accounts/__tests__/cfd-instruments-label-highlighted.spec.tsx @@ -55,20 +55,4 @@ describe('', () => { expect(containerElement).toBeInTheDocument(); expect(containerElement).toHaveClass('compare-cfd-account-outline'); }); - - it('should render the "Boom 300 and Crash 300 Index" for EU user', () => { - const mockStoreEU = mockStore({ - traders_hub: { - selected_region: 'EU', - is_eu_user: true, - }, - }); - - const wrapper = ({ children }: { children: JSX.Element }) => ( - {children} - ); - - render(, { wrapper }); - expect(screen.getByText(/Boom 300 and Crash 300 Index/i)).toBeInTheDocument(); - }); }); From 22f2ab47fbf53876c9d43afc8027999ba3bcac9b Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Fri, 6 Dec 2024 15:34:59 +0800 Subject: [PATCH 18/22] fix: demo accounts filtering --- packages/cfd/src/Helpers/compare-accounts-config.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/cfd/src/Helpers/compare-accounts-config.ts b/packages/cfd/src/Helpers/compare-accounts-config.ts index c33278b68283..7a07ab33477f 100644 --- a/packages/cfd/src/Helpers/compare-accounts-config.ts +++ b/packages/cfd/src/Helpers/compare-accounts-config.ts @@ -359,14 +359,17 @@ const getMT5DemoData = (available_accounts: TModifiedTradingPlatformAvailableAcc item.platform === CFD_PLATFORMS.MT5 ); const financial_demo_accounts = available_accounts.filter( - item => item.market_type === MARKET_TYPE.FINANCIAL && item.shortcode === JURISDICTION.SVG + item => + item.market_type === MARKET_TYPE.FINANCIAL && item.product !== PRODUCT.STP && item.product !== PRODUCT.GOLD ); const gaming_demo_accounts = available_accounts.filter( item => item.market_type === MARKET_TYPE.GAMING && item.shortcode === JURISDICTION.SVG ); + const gold_demo_accounts = available_accounts.filter( item => item.market_type === MARKET_TYPE.FINANCIAL && item.product === PRODUCT.GOLD ); + return [ ...gaming_demo_accounts, ...financial_demo_accounts, From ffe0db2cb0a6531d4d3334b60d32c01a8e6be917 Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Fri, 6 Dec 2024 15:49:12 +0800 Subject: [PATCH 19/22] fix: removed unwanter import --- packages/cfd/src/Helpers/compare-accounts-config.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/cfd/src/Helpers/compare-accounts-config.ts b/packages/cfd/src/Helpers/compare-accounts-config.ts index 7a07ab33477f..a202984527ca 100644 --- a/packages/cfd/src/Helpers/compare-accounts-config.ts +++ b/packages/cfd/src/Helpers/compare-accounts-config.ts @@ -1,7 +1,6 @@ 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 Item from '@deriv/components/src/components/mobile-drawer/mobile-drawer-item'; // Map the accounts according to the market type const getHighlightedIconLabel = ( From 9e429d993a22c950b0f9fd58200e8968c8de259a Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Thu, 12 Dec 2024 11:48:48 +0800 Subject: [PATCH 20/22] fix: compare accounts header --- .../cfd-compare-accounts.tsx | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts.tsx b/packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts.tsx index 90ace019f07b..565d9e8491b2 100644 --- a/packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts.tsx +++ b/packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts.tsx @@ -17,7 +17,6 @@ import { dxtrade_data, ctrader_data, } from '../../Helpers/compare-accounts-config'; -import { REGION } from '../../Helpers/cfd-config'; const CompareCFDs = observer(() => { const { isDesktop } = useDevice(); @@ -26,8 +25,7 @@ const CompareCFDs = observer(() => { const store = useStore(); const { client, traders_hub } = store; const { trading_platform_available_accounts } = client; - const { is_demo, is_eu_user, available_dxtrade_accounts, selected_region, available_ctrader_accounts } = - traders_hub; + const { is_demo, is_eu_user, available_dxtrade_accounts, available_ctrader_accounts } = traders_hub; const sorted_available_accounts = !is_eu_user ? getSortedCFDAvailableAccounts(trading_platform_available_accounts) @@ -64,20 +62,12 @@ const CompareCFDs = observer(() => { ? all_cfd_available_accounts.length + 1 : all_cfd_available_accounts.length; - const getCompareAccountsHeader = () => - selected_region === REGION.EU ? ( - - ) : ( - - ); + const getCompareAccountsHeader = () => ( + + ); const DesktopHeader = (
From 2458e1ac4b2aa5297b2243bc255037aca407dc2a Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Thu, 12 Dec 2024 11:52:34 +0800 Subject: [PATCH 21/22] fix: accounts demo title case --- .../cfd/src/Helpers/compare-accounts-config.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/cfd/src/Helpers/compare-accounts-config.ts b/packages/cfd/src/Helpers/compare-accounts-config.ts index a202984527ca..a75ecc06a750 100644 --- a/packages/cfd/src/Helpers/compare-accounts-config.ts +++ b/packages/cfd/src/Helpers/compare-accounts-config.ts @@ -87,24 +87,24 @@ const getHighlightedIconLabel = ( const getAccountCardTitle = (shortcode: string, is_demo?: boolean) => { switch (shortcode) { case MARKET_TYPE_SHORTCODE.SYNTHETIC: - return is_demo ? localize('Standard Demo') : localize('Standard'); + return is_demo ? localize('Standard demo') : localize('Standard'); case MARKET_TYPE_SHORTCODE.FINANCIAL: - return is_demo ? localize('Financial Demo') : localize('Financial'); + return is_demo ? localize('Financial demo') : localize('Financial'); case MARKET_TYPE_SHORTCODE.FINANCIAL_LABUAN: return localize('Financial - STP'); case MARKET_TYPE_SHORTCODE.FINANCIAL_GOLD: case MARKET_TYPE_SHORTCODE.CFDS_GOLD: - return is_demo ? localize('Gold Demo') : localize('Gold'); + return is_demo ? localize('Gold demo') : localize('Gold'); case MARKET_TYPE_SHORTCODE.ALL_SWAP_FREE_SVG: - return is_demo ? localize('Swap-Free Demo') : localize('Swap-Free'); + return is_demo ? localize('Swap-Free demo') : localize('Swap-Free'); case MARKET_TYPE_SHORTCODE.ALL_ZERO_SPREAD_BVI: - return is_demo ? localize('Zero Spread Demo') : localize('Zero Spread'); + return is_demo ? localize('Zero Spread demo') : localize('Zero Spread'); case CFD_PLATFORMS.DXTRADE: - return is_demo ? localize('Deriv X Demo') : localize('Deriv X'); + return is_demo ? localize('Deriv X demo') : localize('Deriv X'); case CFD_PLATFORMS.CTRADER: - return is_demo ? localize('Deriv cTrader Demo') : localize('Deriv cTrader'); + return is_demo ? localize('Deriv cTrader demo') : localize('Deriv cTrader'); default: - return is_demo ? localize('CFDs Demo') : localize('CFDs'); + return is_demo ? localize('CFDs demo') : localize('CFDs'); } }; From 0fc90305e11b4236a6d258b38e9c23df3f64b466 Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Thu, 12 Dec 2024 13:20:03 +0800 Subject: [PATCH 22/22] fix: demo title test cases --- .../cfd-compare-accounts-title-icon.spec.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/cfd/src/Containers/cfd-compare-accounts/__tests__/cfd-compare-accounts-title-icon.spec.tsx b/packages/cfd/src/Containers/cfd-compare-accounts/__tests__/cfd-compare-accounts-title-icon.spec.tsx index be78c5baf695..762c4eb99448 100644 --- a/packages/cfd/src/Containers/cfd-compare-accounts/__tests__/cfd-compare-accounts-title-icon.spec.tsx +++ b/packages/cfd/src/Containers/cfd-compare-accounts/__tests__/cfd-compare-accounts-title-icon.spec.tsx @@ -101,7 +101,7 @@ describe('', () => { mocked_props.is_demo = true; mocked_props.is_eu_user = false; render(); - expect(screen.getByText('Standard Demo')).toBeInTheDocument(); + expect(screen.getByText('Standard demo')).toBeInTheDocument(); }); test('should render correct title for financial product in demo account', () => { @@ -115,7 +115,7 @@ describe('', () => { mocked_props.is_demo = true; mocked_props.is_eu_user = false; render(); - expect(screen.getByText('Financial Demo')).toBeInTheDocument(); + expect(screen.getByText('Financial demo')).toBeInTheDocument(); }); test('should render correct title for Swap-Free with correct product type demo account', () => { @@ -128,7 +128,7 @@ describe('', () => { mocked_props.is_demo = true; mocked_props.is_eu_user = false; render(); - expect(screen.getByText('Swap-Free Demo')).toBeInTheDocument(); + expect(screen.getByText('Swap-Free demo')).toBeInTheDocument(); }); test('should render correct title for Zero Spread with correct product type demo account', () => { @@ -142,7 +142,7 @@ describe('', () => { mocked_props.is_demo = true; mocked_props.is_eu_user = false; render(); - expect(screen.getByText('Zero Spread Demo')).toBeInTheDocument(); + expect(screen.getByText('Zero Spread demo')).toBeInTheDocument(); }); test('should render correct title for DerivX with correct product type demo account', () => { @@ -154,7 +154,7 @@ describe('', () => { mocked_props.is_demo = true; mocked_props.is_eu_user = false; render(); - expect(screen.getByText('Deriv X Demo')).toBeInTheDocument(); + expect(screen.getByText('Deriv X demo')).toBeInTheDocument(); }); test('should render correct title for EU clients demo accounts', () => { @@ -164,6 +164,6 @@ describe('', () => { mocked_props.is_demo = true; mocked_props.is_eu_user = true; render(); - expect(screen.getByText('CFDs Demo')).toBeInTheDocument(); + expect(screen.getByText('CFDs demo')).toBeInTheDocument(); }); });