Skip to content

Commit

Permalink
chore: Mt5 account title updated and icons added (#10379)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamza-deriv authored and vinu-deriv committed Oct 10, 2023
1 parent 3fa4a17 commit dd5f3d9
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Button, Icon, Money, ThemedScrollbars, Text } from '@deriv/components';
import { formatMoney, getCFDAccount, getCFDAccountDisplay, CFD_PLATFORMS } from '@deriv/shared';
import { formatMoney, getCFDAccount, getCFDAccountDisplay, CFD_PLATFORMS, getMT5Icon } from '@deriv/shared';
import { localize, Localize } from '@deriv/translations';

const getDerivAccount = (client_accounts, login_id) =>
Expand Down Expand Up @@ -161,17 +161,16 @@ const AccountHasPendingConditions = ({
{mt5_open_positions.map(account => (
<Content
key={account.login}
currency_icon={`IcMt5-${getCFDAccount({
currency_icon={`IcMt5-${getMT5Icon({
market_type: account.market_type,
sub_account_type: account.sub_account_type,
platform: CFD_PLATFORMS.MT5,
is_eu,
})}`}
loginid={account.display_login}
title={getCFDAccountDisplay({
market_type: account.market_type,
sub_account_type: account.sub_account_type,
platform: CFD_PLATFORMS.MT5,
shortcode: account.landing_company_short,
is_eu,
})}
value={
Expand All @@ -189,17 +188,16 @@ const AccountHasPendingConditions = ({
{mt5_balance.map(account => (
<Content
key={account.login}
currency_icon={`IcMt5-${getCFDAccount({
currency_icon={`IcMt5-${getMT5Icon({
market_type: account.market_type,
sub_account_type: account.sub_account_type,
platform: CFD_PLATFORMS.MT5,
is_eu,
})}`}
loginid={account.display_login}
title={getCFDAccountDisplay({
market_type: account.market_type,
sub_account_type: account.sub_account_type,
platform: CFD_PLATFORMS.MT5,
shortcode: account.landing_company_short,
is_eu,
})}
value={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ const character_limit_no = 110;
const max_allowed_reasons = 3;

const ClosingAccountReason = observer(({ onBackClick }) => {
const { client } = useStore();
const { client, traders_hub } = useStore();
const { dxtrade_accounts_list, mt5_login_list, account_list } = client;
const { is_eu_user } = traders_hub;
const { is_appstore } = React.useContext(PlatformContext);
const [is_account_closed, setIsAccountClosed] = React.useState(false);
const [is_loading, setIsLoading] = React.useState(false);
Expand Down Expand Up @@ -233,6 +234,7 @@ const ClosingAccountReason = observer(({ onBackClick }) => {
client_accounts={account_list}
dxtrade_accounts_list={dxtrade_accounts_list}
onBackClick={onBackClick}
is_eu={is_eu_user}
/>
)}
{which_modal_should_render === 'inaccessible_modal' && (
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/components/icon/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,9 +700,11 @@ import './mt5/ic-mt5-password-updated.svg';
import './mt5/ic-mt5-responsive.svg';
import './mt5/ic-mt5-support.svg';
import './mt5/ic-mt5-swap-free-platform.svg';
import './mt5/ic-mt5-swap-free.svg';
import './mt5/ic-mt5-synthetic-dashboard.svg';
import './mt5/ic-mt5-synthetic-indices.svg';
import './mt5/ic-mt5-synthetic-platform.svg';
import './mt5/ic-mt5-synthetic.svg';
import './mt5/ic-mt5-trade-types.svg';
import './option/ic-option-accumulators.svg';
import './option/ic-option-call-put-reset.svg';
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions packages/components/src/components/icon/mt5/ic-mt5-synthetic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 13 additions & 2 deletions packages/shared/src/utils/cfd/cfd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export const getCFDAccountDisplay = ({
let cfd_account_key = getCFDAccountKey({ market_type, sub_account_type, platform, shortcode });
if (!cfd_account_key) return undefined;

if (cfd_account_key === 'financial' && is_eu) {
if (cfd_account_key === 'financial_demo' && is_eu) {
if (is_mt5_trade_modal) cfd_account_key = 'mt5_cfds';
else cfd_account_key = 'cfd';
}
Expand All @@ -206,6 +206,11 @@ type TGetCFDAccount = TGetAccount & {
is_transfer_form?: boolean;
};

type TGetMT5Icon = {
market_type: TMarketType;
is_eu?: boolean;
};

export const getCFDAccount = ({
market_type,
sub_account_type,
Expand All @@ -216,7 +221,7 @@ export const getCFDAccount = ({
let cfd_account_key = getCFDAccountKey({ market_type, sub_account_type, platform });
if (!cfd_account_key) return undefined;

if (cfd_account_key === 'financial' && is_eu) {
if (cfd_account_key === 'financial_demo' && is_eu) {
cfd_account_key = 'cfd';
}

Expand All @@ -225,6 +230,12 @@ export const getCFDAccount = ({
return CFD_text[cfd_account_key as keyof typeof CFD_text];
};

export const getMT5Icon = ({ market_type, is_eu }: TGetMT5Icon) => {
if (market_type === 'all' && !is_eu) return 'SwapFree';
if (market_type === 'financial' && is_eu) return 'CFDs';
return market_type;
};

export const setSharedCFDText = (all_shared_CFD_text: { [key: string]: () => void }) => {
CFD_text_translated = all_shared_CFD_text;
};
Expand Down

0 comments on commit dd5f3d9

Please sign in to comment.