Skip to content

Commit

Permalink
fix: compare account modal
Browse files Browse the repository at this point in the history
  • Loading branch information
amina-deriv committed Jan 19, 2023
1 parent f076d96 commit 8044e96
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const CurrentSwitcherContainer = ({
const { client, modules, traders_hub }: TRootStore = store;

const { document_status } = client.authentication_status;
const { is_eu_user, is_demo } = traders_hub;
const { is_eu_user, is_demo, is_currency_switcher_disabled_for_mf } = traders_hub;
const { current_list } = modules.cfd;

const has_mf_mt5_account = Object.keys(current_list)
Expand All @@ -36,11 +36,12 @@ const CurrentSwitcherContainer = ({

const Dropdown = () => {
const icon_dropdown = (
<div className='currency-switcher-container__arrow'>
<div className='currency-switcher-container__arrow' {...props}>
<Icon icon='IcChevronDownBold' />
</div>
);
if (is_eu_user && has_mf_mt5_account) {

if ((is_eu_user && has_mf_mt5_account) || is_currency_switcher_disabled_for_mf) {
return null;
} else if (is_demo) {
return null;
Expand All @@ -53,7 +54,6 @@ const CurrentSwitcherContainer = ({
className={classNames(className, 'currency-switcher-container', {
'currency-switcher-container--has-interaction': has_interaction,
})}
{...props}
>
<div className='currency-switcher-container--left'>
<CurrencyIcon icon={icon} size={32} className='currency-switcher__currency--icon' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const RealAccountCard = () => {

const { accounts, loginid } = client;
const { current_list } = modules.cfd;
const { openModal, is_eu_user, multipliers_account_status } = traders_hub;
const { openModal, is_eu_user, is_currency_switcher_disabled_for_mf } = traders_hub;
const { balance, currency } = accounts[loginid] || default_balance;

const has_mf_mt5_account = Object.keys(current_list)
Expand All @@ -35,7 +35,7 @@ const RealAccountCard = () => {
}
icon={currency}
onClick={() => {
if (multipliers_account_status) {
if (is_currency_switcher_disabled_for_mf) {
return null;
} else if (!is_eu_user && !has_mf_mt5_account) {
openModal('currency_selection');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,46 @@ import { useStores } from 'Stores/index';
import RealAccountCard from './real-account-card';
import './real-account-switcher.scss';

const AccountNeedsVerification = observer(({ multipliers_account_status }: { multipliers_account_status: string }) => {
const { client, traders_hub } = useStores();
const { account_list, loginid } = client;
type AccountNeedsVerificationProps = {
multipliers_account_status: string;
is_currency_switcher_disabled_for_mf: boolean;
};
const AccountNeedsVerification = observer(
({ multipliers_account_status, is_currency_switcher_disabled_for_mf }: AccountNeedsVerificationProps) => {
const { client, traders_hub } = useStores();
const { account_list, loginid } = client;

const { openModal, openFailedVerificationModal } = traders_hub;
const { openModal, openFailedVerificationModal } = traders_hub;

const title = account_list.find((acc: { loginid: string }) => loginid === acc.loginid).title;
const icon = account_list.find((acc: { loginid: string }) => loginid === acc.loginid).icon;
const title = account_list.find((acc: { loginid: string }) => loginid === acc.loginid).title;
const icon = account_list.find((acc: { loginid: string }) => loginid === acc.loginid).icon;

return (
<CurrencySwitcherContainer
className='real-account-switcher__container'
title={title}
icon={icon}
onClick={() => {
if (multipliers_account_status) {
return null;
}
return openModal('currency_selection');
}}
>
<StatusBadge
account_status={multipliers_account_status}
openFailedVerificationModal={openFailedVerificationModal}
selected_account_type='multipliers'
/>
</CurrencySwitcherContainer>
);
});
return (
<CurrencySwitcherContainer
className='real-account-switcher__container'
title={title}
icon={icon}
onClick={() => {
if (is_currency_switcher_disabled_for_mf) {
return null;
}
return openModal('currency_selection');
}}
>
<StatusBadge
account_status={multipliers_account_status}
openFailedVerificationModal={openFailedVerificationModal}
selected_account_type='multipliers'
/>
</CurrencySwitcherContainer>
);
}
);

const RealAccountSwitcher = () => {
const { client, traders_hub } = useStores();
const { is_logging_in, is_switching, has_any_real_account } = client;
const { multipliers_account_status } = traders_hub;
const { multipliers_account_status, is_currency_switcher_disabled_for_mf } = traders_hub;

if (is_switching || is_logging_in) {
return (
Expand All @@ -51,7 +57,12 @@ const RealAccountSwitcher = () => {
}

if (multipliers_account_status) {
return <AccountNeedsVerification multipliers_account_status={multipliers_account_status} />;