Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WALL] Farhan/WALL-3068/Wrong account status and trade status displayed for Migrated and Migration eligble MT5 accounts #12737

Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ const MT5TradeScreen: FC<MT5TradeScreenProps> = ({ mt5Account }) => {
[ctraderAccountsList, dxtradeAccountsList, mt5Account]
);

const shouldShowAccountBalance = useMemo(() => {
if (
platform === mt5Platform &&
platformToAccountsListMapper.mt5?.filter(account => account?.market_type === marketType)[0]?.status ===
'migrated_without_position'
)
return false;
return true;
}, [marketType, mt5Platform, platform, platformToAccountsListMapper.mt5]);

const details = useMemo(() => {
return platform === mt5Platform
? platformToAccountsListMapper.mt5?.filter(account => account?.market_type === marketType)[0]
Expand All @@ -61,17 +71,32 @@ const MT5TradeScreen: FC<MT5TradeScreenProps> = ({ mt5Account }) => {
return details?.login;
}, [details, dxtradePlatform, mt5Platform, platform]);

const showNoNewPositionsMessage = useMemo(() => {
return (
!activeWalletData?.is_virtual &&
details?.landing_company_short === 'svg' &&
['synthetic', 'financial'].includes(marketType ?? '') && (
<InlineMessage type='warning' variant='outlined'>
No new positions
</InlineMessage>
)
);
}, [activeWalletData?.is_virtual, details?.landing_company_short, marketType]);
const migrationMessage = useMemo(() => {
if (platform === mt5Platform && !activeWalletData?.is_virtual) {
switch (
platformToAccountsListMapper.mt5?.filter(account => account?.market_type === marketType)[0]?.status
) {
case 'migrated_with_position':
return (
<InlineMessage size='sm' type='warning' variant='outlined'>
<WalletText color='warning' size='2xs' weight='bold'>
No new positions
</WalletText>
</InlineMessage>
);
case 'migrated_without_position':
return (
<InlineMessage size='sm' type='warning' variant='outlined'>
<WalletText color='warning' size='2xs' weight='bold'>
Account closed
</WalletText>
</InlineMessage>
);
default:
return null;
}
}
}, [activeWalletData?.is_virtual, marketType, mt5Platform, platform, platformToAccountsListMapper.mt5]);

return (
<div className='wallets-mt5-trade-screen'>
Expand All @@ -97,8 +122,8 @@ const MT5TradeScreen: FC<MT5TradeScreenProps> = ({ mt5Account }) => {
</div>
</div>
<div className='wallets-mt5-trade-screen__details-description--right'>
<WalletText weight='bold'>{details?.display_balance}</WalletText>
{showNoNewPositionsMessage}
{shouldShowAccountBalance && <WalletText weight='bold'>{details?.display_balance}</WalletText>}
{migrationMessage}
</div>
</div>

Expand Down