Skip to content

Commit

Permalink
[WALL] Farhan/WALL-3068/Wrong account status and trade status display…
Browse files Browse the repository at this point in the history
…ed for Migrated and Migration eligble MT5 accounts (#12737)

* fix: 🔧 wrong accountmigration badge in mt5 trade modal

* refactor: 🧹 separate logic and change name

* refactor: 🧹 change var name
  • Loading branch information
farhan-nurzi-deriv committed Jan 5, 2024
1 parent b2a4aa8 commit e19f7bc
Showing 1 changed file with 38 additions and 13 deletions.
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

0 comments on commit e19f7bc

Please sign in to comment.