Skip to content

Commit

Permalink
fix: fixes for comments
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarsha-deriv committed Oct 27, 2023
1 parent 5101ee0 commit 4302f74
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 53 deletions.
14 changes: 7 additions & 7 deletions packages/account/src/Configs/get-status-badge-config.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { Text } from '@deriv/components';
import { MT5AccountStatus } from '@deriv/shared';
import { MT5_ACCOUNT_STATUS } from '@deriv/shared';
import { Localize } from '@deriv/translations';

const getStatusBadgeConfig = (
account_status: typeof MT5AccountStatus[keyof typeof MT5AccountStatus],
account_status: typeof MT5_ACCOUNT_STATUS[keyof typeof MT5_ACCOUNT_STATUS],
openFailedVerificationModal?: (selected_account_type: string) => void,
selected_account_type?: string
) => {
const BadgeTextComponent = <Text key={0} weight='bold' size='xxxs' color='warning' />;

switch (account_status) {
case MT5AccountStatus.PENDING:
case MT5_ACCOUNT_STATUS.PENDING:
return {
text: (
<Localize
Expand All @@ -22,7 +22,7 @@ const getStatusBadgeConfig = (
),
icon: 'IcAlertWarning',
};
case MT5AccountStatus.FAILED:
case MT5_ACCOUNT_STATUS.FAILED:
return {
text: (
<Localize
Expand All @@ -41,7 +41,7 @@ const getStatusBadgeConfig = (
),
icon: 'IcRedWarning',
};
case MT5AccountStatus.NEEDS_VERIFICATION:
case MT5_ACCOUNT_STATUS.NEEDS_VERIFICATION:
return {
text: (
<Localize
Expand All @@ -54,12 +54,12 @@ const getStatusBadgeConfig = (
),
icon: 'IcAlertInfo',
};
case MT5AccountStatus.MIGRATED_WITH_POSITION:
case MT5_ACCOUNT_STATUS.MIGRATED_WITH_POSITION:
return {
text: <Localize i18n_default_text='<0>No new positions</0>' components={[BadgeTextComponent]} />,
icon: 'IcAlertWarning',
};
case MT5AccountStatus.MIGRATED_WITHOUT_POSITION:
case MT5_ACCOUNT_STATUS.MIGRATED_WITHOUT_POSITION:
return {
text: <Localize i18n_default_text='<0>Account closed</0>' components={[BadgeTextComponent]} />,
icon: 'IcAlertWarning',
Expand Down
10 changes: 5 additions & 5 deletions packages/appstore/src/components/containers/trading-app-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
getStaticUrl,
getUrlSmartTrader,
getUrlBinaryBot,
MT5AccountStatus,
MT5_ACCOUNT_STATUS,
} from '@deriv/shared';
import OpenPositionsSVGModal from '../modals/open-positions-svg-modal';
import './trading-app-card.scss';
Expand Down Expand Up @@ -81,8 +81,8 @@ const TradingAppCard = ({

const handleStatusBadgeClick = (mt5_acc_auth_status: string) => {
switch (mt5_acc_auth_status) {
case MT5AccountStatus.MIGRATED_WITH_POSITION:
case MT5AccountStatus.MIGRATED_WITHOUT_POSITION:
case MT5_ACCOUNT_STATUS.MIGRATED_WITH_POSITION:
case MT5_ACCOUNT_STATUS.MIGRATED_WITHOUT_POSITION:
return setIsOpenPositionSvgModalOpen(!is_open_position_svg_modal_open);
default:
return null;
Expand Down Expand Up @@ -120,8 +120,8 @@ const TradingAppCard = ({
};

const migration_status =
mt5_acc_auth_status === MT5AccountStatus.MIGRATED_WITH_POSITION ||
mt5_acc_auth_status === MT5AccountStatus.MIGRATED_WITHOUT_POSITION;
mt5_acc_auth_status === MT5_ACCOUNT_STATUS.MIGRATED_WITH_POSITION ||
mt5_acc_auth_status === MT5_ACCOUNT_STATUS.MIGRATED_WITHOUT_POSITION;
const is_disabled = !!(mt5_acc_auth_status && !migration_status);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
getFormattedJurisdictionMarketTypes,
Jurisdiction,
JURISDICTION_MARKET_TYPES,
MT5AccountStatus,
MT5_ACCOUNT_STATUS,
} from '@deriv/shared';
import { useStore } from '@deriv/stores';
import { Localize } from '@deriv/translations';
Expand Down Expand Up @@ -42,7 +42,7 @@ const OpenPositionsSVGModal = ({
);
const from_account = getFormattedJurisdictionCode(Jurisdiction.SVG);
const cfd_platform = getCFDPlatformNames(CFD_PLATFORMS.MT5);
const is_migrated_with_position = status === MT5AccountStatus.MIGRATED_WITH_POSITION;
const is_migrated_with_position = status === MT5_ACCOUNT_STATUS.MIGRATED_WITH_POSITION;

const onClick = () => {
setModalOpen(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
getCurrencyName,
getPlatformSettings,
validNumber,
MT5AccountStatus,
MT5_ACCOUNT_STATUS,
routes,
} from '@deriv/shared';
import { localize, Localize } from '@deriv/translations';
Expand Down Expand Up @@ -122,8 +122,8 @@ const AccountTransferForm = observer(
} = crypto_fiat_converter;

const is_migration_status_present =
selected_to.status === MT5AccountStatus.MIGRATED_WITH_POSITION ||
selected_to.status === MT5AccountStatus.MIGRATED_WITHOUT_POSITION;
selected_to.status === MT5_ACCOUNT_STATUS.MIGRATED_WITH_POSITION ||
selected_to.status === MT5_ACCOUNT_STATUS.MIGRATED_WITHOUT_POSITION;

const [from_accounts, setFromAccounts] = React.useState({});
const [to_accounts, setToAccounts] = React.useState({});
Expand Down Expand Up @@ -362,22 +362,7 @@ const AccountTransferForm = observer(
}
setTransferToHint(hint_text);
resetConverter();
}, [
account_limits,
ctrader_remaining_transfers?.available,
derivez_remaining_transfers?.available,
dxtrade_remaining_transfers?.available,
internal_remaining_transfers?.available,
is_ctrader_transfer,
is_derivez_transfer,
is_dxtrade_transfer,
is_migration_status_present,
is_mt_transfer,
mt5_remaining_transfers?.available,
resetConverter,
selected_from,
selected_to,
]);
}, [account_limits, is_migration_status_present, selected_from, selected_to]); // eslint-disable-line react-hooks/exhaustive-deps

const is_mt5_restricted =
selected_from?.is_mt &&
Expand Down
33 changes: 20 additions & 13 deletions packages/cfd/src/Containers/cfd-password-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import ChangePasswordConfirmation from './cfd-change-password-confirmation';
import TradingPlatformIcon from '../Assets/svgs/trading-platform';
import { observer, useStore } from '@deriv/stores';
import { useCfdStore } from '../Stores/Modules/CFD/Helpers/useCfdStores';
import { CATEGORY } from 'src/Helpers/cfd-config';

export type TCFDPasswordFormValues = { password: string };

Expand Down Expand Up @@ -484,25 +485,31 @@ const CFDPasswordForm = ({
}}
/>
);
else if (account_type.category === 'real')
else if (account_type.category === CATEGORY.REAL)
return (
<Localize
i18n_default_text='Enter your {{platform}} password to add a {{platform_name}} {{account}} {{jurisdiction_shortcode}} account.'
values={{
platform: getCFDPlatformLabel(platform),
platform_name: platform === CFD_PLATFORMS.MT5 ? 'MT5' : getCFDPlatformLabel(platform),
platform_name:
platform === CFD_PLATFORMS.MT5
? getCFDPlatformNames(CFD_PLATFORMS.MT5)
: getCFDPlatformLabel(platform),
account: !show_eu_related_content ? accountTitle(account_type.category) : '',
jurisdiction_shortcode: showJuristiction(),
}}
/>
);
else if (account_type.category === 'demo') {
else if (account_type.category === CATEGORY.DEMO) {
return (
<Localize
i18n_default_text='Enter your {{platform}} password to add a {{platform_name}} {{account}} account.'
values={{
platform: getCFDPlatformLabel(platform),
platform_name: platform === CFD_PLATFORMS.MT5 ? 'MT5' : getCFDPlatformLabel(platform),
platform_name:
platform === CFD_PLATFORMS.MT5
? getCFDPlatformNames(CFD_PLATFORMS.MT5)
: getCFDPlatformLabel(platform),
account: accountTitle(account_type.category),
}}
/>
Expand All @@ -529,7 +536,7 @@ const CFDPasswordForm = ({
case 'derivez':
return 'CFD';
case 'dxtrade':
return category === 'real' ? 'Real' : '';
return category === CATEGORY.REAL ? 'Real' : '';
default:
return account_title;
}
Expand Down Expand Up @@ -754,7 +761,7 @@ const CFDPasswordModal = observer(({ form_error, platform }: TCFDPasswordModalPr
const closeOpenSuccess = () => {
disableCFDPasswordModal();
closeDialogs();
if (account_type.category === 'real') {
if (account_type.category === CATEGORY.REAL) {
sessionStorage.setItem('cfd_transfer_to_login_id', new_account_response.login || '');
history.push(routes.cashier_acc_transfer);
}
Expand All @@ -766,9 +773,9 @@ const CFDPasswordModal = observer(({ form_error, platform }: TCFDPasswordModalPr

// if account type is real convert redirect_to from 1 or 2 to 10 or 20
// and if account type is demo convert redirect_to from 1 or 2 to 11 or 21
if (account_type.category === 'real') {
if (account_type.category === CATEGORY.REAL) {
redirect_to = Number(`${redirect_to}0`);
} else if (account_type.category === 'demo') {
} else if (account_type.category === CATEGORY.DEMO) {
redirect_to = Number(`${redirect_to}1`);
}

Expand Down Expand Up @@ -836,7 +843,7 @@ const CFDPasswordModal = observer(({ form_error, platform }: TCFDPasswordModalPr
}, [should_set_trading_password, should_show_password]);

const success_modal_submit_label = React.useMemo(() => {
if (account_type.category === 'real') {
if (account_type.category === CATEGORY.REAL) {
if (platform === CFD_PLATFORMS.MT5) {
return is_selected_mt5_verified ? localize('Transfer now') : localize('OK');
}
Expand All @@ -849,7 +856,7 @@ const CFDPasswordModal = observer(({ form_error, platform }: TCFDPasswordModalPr
const { category, type } = account_type;
if (!category && !type) return '';

const category_label = category === 'real' ? localize('real') : localize('demo');
const category_label = category === CATEGORY.REAL ? localize('real') : localize('demo');
let type_label = '';
switch (platform) {
case CFD_PLATFORMS.MT5:
Expand Down Expand Up @@ -887,7 +894,7 @@ const CFDPasswordModal = observer(({ form_error, platform }: TCFDPasswordModalPr
return type_label;
};

if (category === 'real') {
if (category === CATEGORY.REAL) {
let platformName = '';
switch (platform) {
case CFD_PLATFORMS.MT5:
Expand Down Expand Up @@ -1067,8 +1074,8 @@ const CFDPasswordModal = observer(({ form_error, platform }: TCFDPasswordModalPr
text_submit={success_modal_submit_label}
has_cancel={
platform === CFD_PLATFORMS.MT5
? is_selected_mt5_verified && account_type.category === 'real'
: account_type.category === 'real'
? is_selected_mt5_verified && account_type.category === CATEGORY.REAL
: account_type.category === CATEGORY.REAL
}
has_close_icon={false}
width={isMobile() ? '32.8rem' : 'auto'}
Expand Down
2 changes: 1 addition & 1 deletion packages/cfd/src/sass/cfd-dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,7 @@
margin: 0 2.4rem;
}
&__acc_status_badge {
max-width: fit-content;
max-width: max-content;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Icon from '../icon';
import './status-badge.scss';

type StatusBadgeProps = {
account_status: string;
account_status: string | null;
icon: string;
text: ReactNode;
onClick?: () => void;
Expand Down
8 changes: 4 additions & 4 deletions packages/shared/src/styles/constants.scss
Original file line number Diff line number Diff line change
Expand Up @@ -227,25 +227,25 @@ $gradient-virtual-swap-free: linear-gradient(58.51deg, #061828 28.06%, #1a3c60 9
/* Appstore Banner grandient background */
$mt5-migration-banner-light-desktop: linear-gradient(
90deg,
#fff 0%,
$COLOR_WHITE 0%,
rgba(255, 255, 255, 0.65) 64.58%,
rgba(255, 255, 255, 0) 100%
);
$mt5-migration-banner-dark-desktop: linear-gradient(
90deg,
#0e0e0e 0%,
$COLOR_BLACK_3 0%,
rgba(14, 14, 14, 0.651) 64.58%,
rgba(14, 14, 14, 0) 100%
);
$mt5-migration-banner-light-mobile: linear-gradient(
112.7deg,
#ffffff 35.51%,
$COLOR_WHITE 35.51%,
rgba(255, 255, 255, 0.651) 53.39%,
rgba(255, 255, 255, 0) 77.23%
);
$mt5-migration-banner-dark-mobile: linear-gradient(
113.49deg,
#0e0e0e 21.26%,
$COLOR_BLACK_3 21.26%,
rgba(14, 14, 14, 0.651) 62.3%,
rgba(14, 14, 14, 0) 97.41%
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const MT5AccountStatus = Object.freeze({
export const MT5_ACCOUNT_STATUS = Object.freeze({
FAILED: 'failed',
MIGRATED_WITH_POSITION: 'migrated_with_position',
MIGRATED_WITHOUT_POSITION: 'migrated_without_position',
Expand Down

0 comments on commit 4302f74

Please sign in to comment.