Skip to content

Commit

Permalink
Revert "Vinu/79411/derivez cashier transfer (#6896)" (#7158)
Browse files Browse the repository at this point in the history
This reverts commit 5d9c943.
  • Loading branch information
carolsachdeva committed Dec 13, 2022
1 parent a1e8b26 commit 3ea7941
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 248 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ describe('<AccountTransferForm />', () => {
},
},
},
common: {
is_from_derivgo: false,
},
};
});
beforeAll(() => {
Expand Down Expand Up @@ -324,22 +321,6 @@ describe('<AccountTransferForm />', () => {
).toBeInTheDocument();
});

it('should show proper note if transfer fee is 2%, is_derivez_transfer, and is_dxtrade_allowed is false', () => {
(isMobile as jest.Mock).mockReturnValue(true);
mockRootStore.modules.cashier.account_transfer.selected_from.is_derivez = true;
mockRootStore.modules.cashier.account_transfer.selected_to.is_derivez = true;
mockRootStore.modules.cashier.account_transfer.transfer_fee = 2;
mockRootStore.common.is_from_derivgo = true;

renderAccountTransferForm();

expect(
screen.getByText(
'We’ll charge a 2% transfer fee or 0 USD, whichever is higher, for transfers between your Deriv cryptocurrency and Deriv MT5 accounts, your Deriv cryptocurrency and Deriv EZ accounts, and your Deriv cryptocurrency and Deriv X accounts. Please bear in mind that some transfers may not be possible.'
)
).toBeInTheDocument();
});

it('should show proper note if transfer fee is 2% and is_mt_transfer is false', () => {
(isMobile as jest.Mock).mockReturnValue(true);
mockRootStore.modules.cashier.account_transfer.transfer_fee = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ type TAccountTransferNoteProps = {
is_mt_transfer: boolean;
minimum_fee: string | number;
transfer_fee: string | number;
is_from_derivgo: boolean;
is_derivez_transfer: boolean;
};

const AccountTransferBullet = ({ children }: TAccountTransferBulletProps) => (
Expand All @@ -38,24 +36,12 @@ const AccountTransferNote = ({
is_mt_transfer,
minimum_fee,
transfer_fee,
is_from_derivgo,
is_derivez_transfer,
}: TAccountTransferNoteProps) => {
const platform_name_dxtrade = getPlatformSettings('dxtrade').name;
const platform_name_mt5 = getPlatformSettings('mt5').name;
const platform_name_derivez = getPlatformSettings('derivez').name;

//TODO to refactor derivez notes once this account is used in deriv app and not only from derivgo
const getTransferFeeNote = () => {
if (transfer_fee === 0) {
if (is_from_derivgo && is_derivez_transfer) {
return (
<Localize
i18n_default_text='We do not charge a transfer fee for transfers in the same currency between your Deriv fiat and {{platform_name_mt5}} accounts, your Deriv fiat and {{platform_name_derivez}} accounts and your Deriv fiat and {{platform_name_dxtrade}} accounts.'
values={{ platform_name_dxtrade, platform_name_mt5, platform_name_derivez }}
/>
);
}
return is_dxtrade_allowed ? (
<Localize
i18n_default_text='We do not charge a transfer fee for transfers in the same currency between your Deriv fiat and {{platform_name_mt5}} accounts and between your Deriv fiat and {{platform_name_dxtrade}} accounts.'
Expand All @@ -68,14 +54,6 @@ const AccountTransferNote = ({
/>
);
} else if (transfer_fee === 1) {
if (is_from_derivgo && is_derivez_transfer) {
return (
<Localize
i18n_default_text='We’ll charge a 1% transfer fee for transfers in different currencies between your Deriv fiat and {{platform_name_mt5}} accounts, your Deriv fiat and {{platform_name_derivez}} accounts, and your Deriv fiat and {{platform_name_dxtrade}} accounts.'
values={{ platform_name_dxtrade, platform_name_mt5, platform_name_derivez }}
/>
);
}
return is_dxtrade_allowed ? (
<Localize
i18n_default_text='We’ll charge a 1% transfer fee for transfers in different currencies between your Deriv fiat and {{platform_name_mt5}} accounts and between your Deriv fiat and {{platform_name_dxtrade}} accounts.'
Expand All @@ -97,20 +75,7 @@ const AccountTransferNote = ({
}}
/>
);
} else if (transfer_fee === 2 && (is_mt_transfer || is_dxtrade_transfer || is_derivez_transfer)) {
if (is_from_derivgo && is_derivez_transfer) {
return (
<Localize
i18n_default_text='We’ll charge a 2% transfer fee or {{minimum_fee}} {{currency}}, whichever is higher, for transfers between your Deriv cryptocurrency and Deriv MT5 accounts, your Deriv cryptocurrency and {{platform_name_derivez}} accounts, and your Deriv cryptocurrency and {{platform_name_dxtrade}} accounts.'
values={{
minimum_fee,
currency: getCurrencyDisplayCode(currency),
platform_name_derivez,
platform_name_dxtrade,
}}
/>
);
}
} else if (transfer_fee === 2 && (is_mt_transfer || is_dxtrade_transfer)) {
return is_dxtrade_allowed ? (
<Localize
i18n_default_text='We’ll charge a 2% transfer fee or {{minimum_fee}} {{currency}}, whichever is higher, for transfers between your Deriv cryptocurrency and Deriv MT5 accounts and between your Deriv cryptocurrency and {{platform_name_dxtrade}} accounts.'
Expand All @@ -129,7 +94,7 @@ const AccountTransferNote = ({
}}
/>
);
} else if (transfer_fee === 2 && !is_mt_transfer && !is_dxtrade_transfer && !is_derivez_transfer) {
} else if (transfer_fee === 2 && !is_mt_transfer && !is_dxtrade_transfer) {
return (
<Localize
i18n_default_text='We’ll charge a 2% transfer fee or {{minimum_fee}} {{currency}}, whichever is higher, for transfers between your Deriv fiat and Deriv cryptocurrency accounts.'
Expand All @@ -146,12 +111,7 @@ const AccountTransferNote = ({
return (
<div className='account-transfer-form__notes'>
<AccountTransferBullet>
{is_from_derivgo && is_derivez_transfer ? (
<Localize
i18n_default_text='You may transfer between your Deriv fiat, cryptocurrency, {{platform_name_mt5}}, {{platform_name_derivez}} and {{platform_name_dxtrade}} accounts.'
values={{ platform_name_dxtrade, platform_name_mt5, platform_name_derivez }}
/>
) : is_dxtrade_allowed ? (
{is_dxtrade_allowed ? (
<Localize
i18n_default_text='You may transfer between your Deriv fiat, cryptocurrency, {{platform_name_mt5}}, and {{platform_name_dxtrade}} accounts.'
values={{ platform_name_dxtrade, platform_name_mt5 }}
Expand All @@ -164,20 +124,7 @@ const AccountTransferNote = ({
)}
</AccountTransferBullet>
<AccountTransferBullet>
{is_from_derivgo && is_derivez_transfer ? (
<Localize
i18n_default_text='Each day, you can make up to {{ allowed_internal }} transfers between your Deriv accounts, up to {{ allowed_mt5 }} transfers between your Deriv and {{platform_name_mt5}} accounts, up to {{ allowed_derivez }} transfers between your Deriv and {{platform_name_derivez}} accounts, and up to {{ allowed_dxtrade }} transfers between your Deriv and {{platform_name_dxtrade}} accounts.'
values={{
allowed_internal: allowed_transfers_count?.internal,
allowed_mt5: allowed_transfers_count?.mt5,
allowed_dxtrade: allowed_transfers_count?.dxtrade,
allowed_derivez: allowed_transfers_count?.derivez,
platform_name_dxtrade,
platform_name_mt5,
platform_name_derivez,
}}
/>
) : is_dxtrade_allowed ? (
{is_dxtrade_allowed ? (
<Localize
i18n_default_text='Each day, you can make up to {{ allowed_internal }} transfers between your Deriv accounts, up to {{ allowed_mt5 }} transfers between your Deriv and {{platform_name_mt5}} accounts, and up to {{ allowed_dxtrade }} transfers between your Deriv and {{platform_name_dxtrade}} accounts.'
values={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,12 @@
&-wrapper {
display: flex;
flex-direction: column;
justify-content: center;
justify-content: flex-start;
align-items: flex-start;
margin-left: 8px;
margin-right: 8px;
}
}
&__icon {
display: flex;
justify-content: center;
}
&__balance {
margin-left: auto;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const AccountOption = ({ account, idx }: TAccountsList) => {
return (
<React.Fragment key={idx}>
{(account.currency || account.platform_icon) && (
<div className='account-transfer-form__icon'>
<div>
<Icon
icon={account.platform_icon || `IcCurrency-${account?.currency?.toLowerCase()}`}
className='account-transfer-form__currency-icon'
Expand All @@ -42,15 +42,11 @@ const AccountOption = ({ account, idx }: TAccountsList) => {

<div className='account-transfer-form__currency-wrapper'>
<Text size='xxs' line_height='xs' styles={{ color: 'inherit', fontWeight: 'inherit' }}>
{account.is_dxtrade || account.is_mt || account.is_derivez
? account.text
: getCurrencyName(account.currency)}
{account.is_dxtrade || account.is_mt ? account.text : getCurrencyName(account.currency)}
</Text>
<Text size='xxxs' align='left' color='less-prominent'>
{account.value}
</Text>
{!account.is_derivez && (
<Text size='xxxs' align='left' color='less-prominent'>
{account.value}
</Text>
)}
</div>

<span className='account-transfer-form__balance'>
Expand All @@ -69,16 +65,13 @@ let remaining_transfers: boolean | undefined;
let accounts_from: Array<TAccount> = [];
let mt_accounts_from: Array<TAccount> = [];
let dxtrade_accounts_from: Array<TAccount> = [];
let derivez_accounts_from: Array<TAccount> = [];
let accounts_to: Array<TAccount> = [];
let mt_accounts_to: Array<TAccount> = [];
let dxtrade_accounts_to: Array<TAccount> = [];
let derivez_accounts_to: Array<TAccount> = [];

const AccountTransferForm = ({ error, setSideNotes }: TAccountTransferFormProps) => {
const {
client,
common: { is_from_derivgo },
modules: { cashier },
} = useStore();

Expand Down Expand Up @@ -121,12 +114,10 @@ const AccountTransferForm = ({ error, setSideNotes }: TAccountTransferFormProps)
const { daily_transfers } = account_limits;
const mt5_remaining_transfers = daily_transfers?.mt5;
const dxtrade_remaining_transfers = daily_transfers?.dxtrade;
const derivez_remaining_transfers = daily_transfers?.derivez;
const internal_remaining_transfers = daily_transfers?.internal;

const is_mt_transfer = selected_to.is_mt || selected_from.is_mt;
const is_dxtrade_transfer = selected_to.is_dxtrade || selected_from.is_dxtrade;
const is_derivez_transfer = selected_to.is_derivez || selected_from.is_derivez;

const platform_name_dxtrade = getPlatformSettings('dxtrade').name;

Expand Down Expand Up @@ -154,17 +145,14 @@ const AccountTransferForm = ({ error, setSideNotes }: TAccountTransferFormProps)
return selected_from.currency === selected_to.currency ? !amount : !converter_from_amount;
};

const getAccounts = (type: string, { is_mt, is_dxtrade, is_derivez }: TAccount) => {
const getAccounts = (type: string, { is_mt, is_dxtrade }: TAccount) => {
if (type === 'from') {
if (is_mt) return mt_accounts_from;
if (is_dxtrade) return dxtrade_accounts_from;
if (is_derivez) return derivez_accounts_from;

return accounts_from;
} else if (type === 'to') {
if (is_mt) return mt_accounts_to;
if (is_dxtrade) return dxtrade_accounts_to;
if (is_derivez) return derivez_accounts_to;
return accounts_to;
}
return [];
Expand All @@ -178,54 +166,44 @@ const AccountTransferForm = ({ error, setSideNotes }: TAccountTransferFormProps)
accounts_from = [];
mt_accounts_from = [];
dxtrade_accounts_from = [];
derivez_accounts_from = [];
accounts_to = [];
mt_accounts_to = [];
dxtrade_accounts_to = [];
derivez_accounts_to = [];

accounts_list.forEach((account, idx) => {
const text = <AccountOption idx={idx} account={account} />;
const value = account.value;

const is_cfd_account = account.is_mt || account.is_dxtrade || account.is_derivez;
const is_cfd_account = account.is_mt || account.is_dxtrade;

getAccounts('from', account).push({
text,
value,
is_mt: account.is_mt,
is_dxtrade: account.is_dxtrade,
is_derivez: account.is_derivez,
nativepicker_text: `${is_cfd_account ? account.market_type : getCurrencyName(account.currency)} (${
account.balance
} ${is_cfd_account ? account.currency : account.text})`,
});
const is_selected_from = account.value === selected_from.value;

if (
(selected_from.is_mt && (account.is_dxtrade || account.is_derivez)) ||
(selected_from.is_dxtrade && (account.is_mt || account.is_derivez)) ||
(selected_from.is_derivez && (account.is_mt || account.is_dxtrade))
)
return;
if ((selected_from.is_mt && account.is_dxtrade) || (selected_from.is_dxtrade && account.is_mt)) return;

// account from and to cannot be the same
if (!is_selected_from) {
const is_selected_from_mt = selected_from.is_mt && account.is_mt;
const is_selected_from_dxtrade = selected_from.is_dxtrade && account.is_dxtrade;
const is_selected_from_derivez = selected_from.is_derivez && account.is_derivez;

// cannot transfer to MT account from MT
// cannot transfer to Dxtrade account from Dxtrade

const is_disabled = is_selected_from_mt || is_selected_from_dxtrade || is_selected_from_derivez;
const is_disabled = is_selected_from_mt || is_selected_from_dxtrade;

getAccounts('to', account).push({
text,
value,
is_mt: account.is_mt,
is_dxtrade: account.is_dxtrade,
is_derivez: account.is_derivez,
disabled: is_disabled,
nativepicker_text: `${is_cfd_account ? account.market_type : getCurrencyName(account.currency)} (${
account.balance
Expand All @@ -239,7 +217,6 @@ const AccountTransferForm = ({ error, setSideNotes }: TAccountTransferFormProps)
...(dxtrade_accounts_from.length && {
[localize('{{platform_name_dxtrade}} accounts', { platform_name_dxtrade })]: dxtrade_accounts_from,
}),
...(derivez_accounts_from.length && { [localize('Deriv EZ accounts')]: derivez_accounts_from }),
...(accounts_from.length && { [localize('Deriv accounts')]: accounts_from }),
});

Expand All @@ -248,7 +225,6 @@ const AccountTransferForm = ({ error, setSideNotes }: TAccountTransferFormProps)
...(dxtrade_accounts_to.length && {
[localize('{{platform_name_dxtrade}} accounts', { platform_name_dxtrade })]: dxtrade_accounts_to,
}),
...(derivez_accounts_to.length && { [localize('Deriv EZ accounts')]: derivez_accounts_to }),
...(accounts_to.length && { [localize('Deriv accounts')]: accounts_to }),
});
}, [accounts_list, selected_to, selected_from]); // eslint-disable-line react-hooks/exhaustive-deps
Expand All @@ -265,7 +241,6 @@ const AccountTransferForm = ({ error, setSideNotes }: TAccountTransferFormProps)
internal: internal_remaining_transfers?.allowed,
mt5: mt5_remaining_transfers?.allowed,
dxtrade: dxtrade_remaining_transfers?.allowed,
derivez: derivez_remaining_transfers?.allowed,
}}
transfer_fee={transfer_fee}
currency={selected_from.currency}
Expand All @@ -275,8 +250,6 @@ const AccountTransferForm = ({ error, setSideNotes }: TAccountTransferFormProps)
is_dxtrade_allowed={is_dxtrade_allowed}
is_dxtrade_transfer={is_dxtrade_transfer}
is_mt_transfer={is_mt_transfer}
is_from_derivgo={is_from_derivgo}
is_derivez_transfer={is_derivez_transfer}
/>
);
setSideNotes([
Expand All @@ -293,8 +266,6 @@ const AccountTransferForm = ({ error, setSideNotes }: TAccountTransferFormProps)
return mt5_remaining_transfers?.available;
} else if (is_dxtrade_transfer) {
return dxtrade_remaining_transfers?.available;
} else if (is_derivez_transfer) {
return derivez_remaining_transfers?.available;
}
return internal_remaining_transfers?.available;
};
Expand Down Expand Up @@ -553,7 +524,6 @@ const AccountTransferForm = ({ error, setSideNotes }: TAccountTransferFormProps)
internal: internal_remaining_transfers?.allowed,
mt5: mt5_remaining_transfers?.allowed,
dxtrade: dxtrade_remaining_transfers?.allowed,
derivez: derivez_remaining_transfers?.allowed,
}}
transfer_fee={transfer_fee}
currency={selected_from.currency}
Expand All @@ -562,8 +532,6 @@ const AccountTransferForm = ({ error, setSideNotes }: TAccountTransferFormProps)
is_dxtrade_allowed={is_dxtrade_allowed}
is_dxtrade_transfer={is_dxtrade_transfer}
is_mt_transfer={is_mt_transfer}
is_from_derivgo={is_from_derivgo}
is_derivez_transfer={is_derivez_transfer}
/>
</SideNote>
<ErrorDialog error={error} />
Expand Down
Loading

0 comments on commit 3ea7941

Please sign in to comment.