From ac5323a742db555d064f59604a2c988389d7b3da Mon Sep 17 00:00:00 2001 From: hirad-deriv Date: Wed, 6 Nov 2024 11:13:05 +0800 Subject: [PATCH] Hirad/UPM-1681/Account closure and transfer modal issue (#17207) * chore: fixed the transfer and account closure pop up issues * chore: updated the types --- .../closing-account-pending-balance.tsx | 1 + .../closing-account-pending-positions.tsx | 1 + packages/account/src/Types/common.type.ts | 5 ++++- packages/cashier/src/stores/account-transfer-store.ts | 1 + .../AccountSwitcher/account-switcher-account-list.jsx | 5 ++++- .../src/App/Containers/AccountSwitcher/account-switcher.jsx | 1 + packages/shared/src/utils/cfd/cfd.ts | 2 +- 7 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/account/src/Sections/Security/ClosingAccount/closing-account-pending-conditions/closing-account-pending-balance.tsx b/packages/account/src/Sections/Security/ClosingAccount/closing-account-pending-conditions/closing-account-pending-balance.tsx index 8d712e55a39c..ccf1cdf0e277 100644 --- a/packages/account/src/Sections/Security/ClosingAccount/closing-account-pending-conditions/closing-account-pending-balance.tsx +++ b/packages/account/src/Sections/Security/ClosingAccount/closing-account-pending-conditions/closing-account-pending-balance.tsx @@ -62,6 +62,7 @@ const ClosingAccountPendingBalance = observer(({ platform, account_balance }: TC platform, shortcode: is_mt5_platform ? (account.landing_company_short as TShortcode) : undefined, is_eu: is_eu_user, + product: account.product, }) ?? '' } value={ diff --git a/packages/account/src/Sections/Security/ClosingAccount/closing-account-pending-conditions/closing-account-pending-positions.tsx b/packages/account/src/Sections/Security/ClosingAccount/closing-account-pending-conditions/closing-account-pending-positions.tsx index fa372338304f..6541ff28ceb5 100644 --- a/packages/account/src/Sections/Security/ClosingAccount/closing-account-pending-conditions/closing-account-pending-positions.tsx +++ b/packages/account/src/Sections/Security/ClosingAccount/closing-account-pending-conditions/closing-account-pending-positions.tsx @@ -63,6 +63,7 @@ const ClosingAccountPendingPositions = observer( ? (account.landing_company_short as TShortcode) : undefined, is_eu: is_eu_user, + product: account.product, }) ?? '' } value={ diff --git a/packages/account/src/Types/common.type.ts b/packages/account/src/Types/common.type.ts index 342ec0fffeb7..a3010b1835fc 100644 --- a/packages/account/src/Types/common.type.ts +++ b/packages/account/src/Types/common.type.ts @@ -217,17 +217,20 @@ export type TAccounts = { title?: string; }; +type TProduct = 'financial' | 'synthetic' | 'swap_free' | 'zero_spread' | 'cTrader' | 'derivx'; + type TPendingAccountDetails = { balance?: number; currency?: string; display_login?: string; positions?: number; withdrawals?: number; + product?: TProduct; }; export type TDetailsOfDerivAccount = TAccounts & TPendingAccountDetails; export type TDetailsOfMT5Account = DetailsOfEachMT5Loginid & TPendingAccountDetails; -export type TDetailsOfDerivXAccount = TDetailsOfMT5Account & { account_id?: string }; +export type TDetailsOfDerivXAccount = TDetailsOfMT5Account & { account_id?: string; product?: TProduct }; export type TDetailsOfCtraderAccount = DetailsOfEachMT5Loginid & { display_balance?: string; platform?: string; diff --git a/packages/cashier/src/stores/account-transfer-store.ts b/packages/cashier/src/stores/account-transfer-store.ts index 946c78b42a29..7360359ced3b 100644 --- a/packages/cashier/src/stores/account-transfer-store.ts +++ b/packages/cashier/src/stores/account-transfer-store.ts @@ -402,6 +402,7 @@ export default class AccountTransferStore { platform: account.account_type, is_eu: this.root_store.client.is_eu, is_transfer_form: true, + product: account.product, }) || '' }`; const account_text_display = is_cfd diff --git a/packages/core/src/App/Containers/AccountSwitcher/account-switcher-account-list.jsx b/packages/core/src/App/Containers/AccountSwitcher/account-switcher-account-list.jsx index 26db737bd2c9..e69cc8a5dfe5 100644 --- a/packages/core/src/App/Containers/AccountSwitcher/account-switcher-account-list.jsx +++ b/packages/core/src/App/Containers/AccountSwitcher/account-switcher-account-list.jsx @@ -16,6 +16,7 @@ const AccountList = ({ is_disabled, is_virtual, is_eu, + product, loginid, market_type, redirectAccount, @@ -57,6 +58,7 @@ const AccountList = ({ sub_account_type={sub_account_type} has_error={has_error} platform={platform} + product={product} is_dark_mode_on={is_dark_mode_on} shortcode={shortcode} should_show_server_name={should_show_server_name} @@ -132,12 +134,13 @@ const AccountDisplay = ({ sub_account_type, platform, server, + product, is_dark_mode_on, is_eu, shortcode, should_show_server_name, }) => { - const account_title = getCFDAccountDisplay({ market_type, sub_account_type, platform, is_eu, shortcode }); + const account_title = getCFDAccountDisplay({ market_type, sub_account_type, platform, is_eu, shortcode, product }); // TODO: Remove once account with error has market_type and sub_account_type in details response const getServerName = React.useCallback(account => { if (account) { diff --git a/packages/core/src/App/Containers/AccountSwitcher/account-switcher.jsx b/packages/core/src/App/Containers/AccountSwitcher/account-switcher.jsx index 84096081edae..2373190d050e 100644 --- a/packages/core/src/App/Containers/AccountSwitcher/account-switcher.jsx +++ b/packages/core/src/App/Containers/AccountSwitcher/account-switcher.jsx @@ -240,6 +240,7 @@ const AccountSwitcher = observer(({ history, is_mobile, is_visible }) => { is_disabled={account.is_disabled} is_virtual={account.is_virtual} loginid={account.loginid} + product={account.product} redirectAccount={account.is_disabled ? undefined : () => doSwitch(account.loginid)} onClickResetVirtualBalance={resetBalance} selected_loginid={account_loginid} diff --git a/packages/shared/src/utils/cfd/cfd.ts b/packages/shared/src/utils/cfd/cfd.ts index c02c93227034..097d60201410 100644 --- a/packages/shared/src/utils/cfd/cfd.ts +++ b/packages/shared/src/utils/cfd/cfd.ts @@ -99,7 +99,7 @@ export const getCFDAccountKey = ({ return 'all_demo'; } } - if (market_type === 'all') { + if (market_type === 'all' && platform !== CFD_PLATFORMS.MT5) { switch (platform) { case CFD_PLATFORMS.CTRADER: return 'ctrader';