Skip to content

Commit

Permalink
fix: move consts to Helpers/constants file
Browse files Browse the repository at this point in the history
  • Loading branch information
shontzu-deriv committed Apr 28, 2023
1 parent 0de6365 commit 0244cf7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 32 deletions.
9 changes: 2 additions & 7 deletions packages/cfd/src/Containers/trade-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import { Text, Icon, Money } from '@deriv/components';
import { TTradingPlatformAccounts, TCFDDashboardContainer, TCFDsPlatformType } from '../Components/props.types';
import { TTradingPlatformAccounts, TCFDDashboardContainer, TCFDsPlatformType } from 'Components/props.types';
import { DetailsOfEachMT5Loginid } from '@deriv/api-types';
import { CFD_PLATFORMS, getCFDAccountKey, isMobile, capitalizeFirstLetter, mobileOSDetect } from '@deriv/shared';
import { localize, Localize } from '@deriv/translations';
import { getPlatformQRCode, mobileDownloadLink, PlatformsDesktopDownload } from '../Helpers/config';
import { platformsText } from '../Helpers/constants';
import { getTitle, platformsText } from '../Helpers/constants';
import SpecBox from 'Components/specbox';
import PasswordBox from 'Components/passwordbox';

Expand All @@ -25,11 +25,6 @@ type TTradeModalProps = {
platform: TCFDsPlatformType;
};

const getTitle = (market_type: string, is_eu_user: boolean) => {
if (is_eu_user) localize('MT5 CFDs');
return market_type;
};

const PlatformIconsAndDescriptions = (platform: TCFDsPlatformType, is_demo: string) => {
return (
<React.Fragment>
Expand Down
29 changes: 4 additions & 25 deletions packages/cfd/src/Helpers/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,17 @@ import React from 'react';
import { QRCode } from 'react-qrcode';
import { TCFDsPlatformType } from 'Components/props.types';
import {
getPlatformDXTradeDownloadLink,
getPlatformDerivEZDownloadLink,
getDXTradeWebTerminalLink,
platformsText,
DERIVEZ_URL,
platforms_icons,
mobileDownloadLink,
} from './constants';
import { Text, Icon } from '@deriv/components';
import { Localize } from '@deriv/translations';
import { isMobile, OSDetect, isDesktopOs } from '@deriv/shared';
import { TCFDDashboardContainer } from 'Containers/props.types';

export const mobileDownloadLink = (platform: TCFDsPlatformType, type: 'ios' | 'android' | 'huawei') => {
switch (platform) {
case 'dxtrade':
return getPlatformDXTradeDownloadLink(type);
case 'derivez':
return getPlatformDerivEZDownloadLink(type);
default:
return getPlatformDXTradeDownloadLink(type);
}
};

export const getPlatformQRCode = (acc_type: TCFDsPlatformType) => {
const qr_code_mobile = isMobile() ? '100%' : '80%';
const os = OSDetect();
Expand Down Expand Up @@ -67,17 +56,6 @@ export const PlatformsDesktopDownload = ({ platform, dxtrade_tokens, is_demo }:
}
};

const platforms_icons = () => {
switch (platform) {
case 'derivez':
return 'DerivEz';
case 'dxtrade':
return 'Dxtrade';
default:
return '';
}
};

return (
<React.Fragment>
<a
Expand All @@ -88,7 +66,7 @@ export const PlatformsDesktopDownload = ({ platform, dxtrade_tokens, is_demo }:
>
<Icon
className='cfd-trade-modal__dxtrade-button-icon'
icon={`IcBrand${platforms_icons()}Wordmark`}
icon={`IcBrand${platforms_icons(platform)}Wordmark`}
size={36}
/>
<div className='cfd-trade-modal__dxtrade-button-text'>
Expand All @@ -100,3 +78,4 @@ export const PlatformsDesktopDownload = ({ platform, dxtrade_tokens, is_demo }:
</React.Fragment>
);
};
export { mobileDownloadLink };
31 changes: 31 additions & 0 deletions packages/cfd/src/Helpers/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { OSDetect } from '@deriv/shared';
import { localize } from '@deriv/translations';
import { TCFDsPlatformType } from 'Components/props.types';

const platformsText = (platform: TCFDsPlatformType) => {
Expand All @@ -12,6 +13,33 @@ const platformsText = (platform: TCFDsPlatformType) => {
}
};

const platforms_icons = (platform: TCFDsPlatformType) => {
switch (platform) {
case 'derivez':
return 'DerivEz';
case 'dxtrade':
return 'Dxtrade';
default:
return '';
}
};

const mobileDownloadLink = (platform: TCFDsPlatformType, type: 'ios' | 'android' | 'huawei') => {
switch (platform) {
case 'dxtrade':
return getPlatformDXTradeDownloadLink(type);
case 'derivez':
return getPlatformDerivEZDownloadLink(type);
default:
return getPlatformDXTradeDownloadLink(type);
}
};

const getTitle = (market_type: string, is_eu_user: boolean) => {
if (is_eu_user) localize('MT5 CFDs');
return market_type;
};

const REAL_DXTRADE_URL = 'https://dx.deriv.com';
const DEMO_DXTRADE_URL = 'https://dx-demo.deriv.com';

Expand Down Expand Up @@ -105,6 +133,9 @@ export {
DERIVEZ_URL,
getBrokerName,
platformsText,
platforms_icons,
getTitle,
mobileDownloadLink,
getPlatformDXTradeDownloadLink,
getPlatformDerivEZDownloadLink,
getPlatformMt5DownloadLink,
Expand Down

0 comments on commit 0244cf7

Please sign in to comment.