Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move hard coded part and make it more dynamic #48

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Button, Icon, Loading } from '@deriv/components';
import { localize } from '@deriv/translations';
import { getAuthenticationStatusInfo } from '@deriv/shared';
import { getAuthenticationStatusInfo, Jurisdiction } from '@deriv/shared';
import IconMessageContent from 'Components/icon-message-content';

const PoiPoaDocsSubmitted = ({
Expand Down Expand Up @@ -34,7 +34,8 @@ const PoiPoaDocsSubmitted = ({
const { manual_status, poi_verified_for_vanuatu_maltainvest, poi_verified_for_bvi_labuan, poa_pending } =
getAuthenticationStatusInfo(account_status);
const is_vanuatu_or_maltainvest_selected =
jurisdiction_selected_shortcode === 'vanuatu' || jurisdiction_selected_shortcode === 'maltainvest';
jurisdiction_selected_shortcode === Jurisdiction.VANUATU ||
jurisdiction_selected_shortcode === Jurisdiction.MALTA_INVEST;
if (
(is_vanuatu_or_maltainvest_selected && poi_verified_for_vanuatu_maltainvest && poa_pending) ||
(!is_vanuatu_or_maltainvest_selected && poi_verified_for_bvi_labuan && poa_pending) ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react-hooks/exhaustive-deps */
import React from 'react';
import { WS } from '@deriv/shared';
import { WS, Jurisdiction } from '@deriv/shared';
import Unsupported from 'Components/poi/status/unsupported';
import OnfidoUpload from './onfido-sdk-view.jsx';
import { identity_status_codes, submission_status_code, service_code } from './proof-of-identity-utils';
Expand Down Expand Up @@ -30,7 +30,7 @@ const POISubmissionForMT5 = ({
is_idv_supported &&
Number(idv_submissions_left) > 0 &&
!is_idv_disallowed &&
jurisdiction_selected_shortcode !== 'vanuatu'
jurisdiction_selected_shortcode !== Jurisdiction.VANUATU
) {
setSubmissionService(service_code.idv);
} else if (onfido_submissions_left && is_onfido_supported) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Router } from 'react-router';
import { createBrowserHistory } from 'history';
import { WS, validPassword } from '@deriv/shared';
import { WS, validPassword, Jurisdiction } from '@deriv/shared';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import CFDPasswordModal from '../cfd-password-modal';

Expand Down Expand Up @@ -62,7 +62,7 @@ describe('<CFDPasswordModal/>', () => {
is_cfd_success_dialog_enabled: false,
is_dxtrade_allowed: false,
is_pre_appstore: false,
jurisdiction_selected_shortcode: 'svg',
jurisdiction_selected_shortcode: Jurisdiction.SVG,
platform: 'mt5',
has_cfd_error: false,
landing_companies: {},
Expand Down Expand Up @@ -220,7 +220,7 @@ describe('<CFDPasswordModal/>', () => {
account_type: { category: 'real', type: 'financial' },
is_eu: true,
is_fully_authenticated: false,
jurisdiction_selected_shortcode: 'bvi',
jurisdiction_selected_shortcode: Jurisdiction.BVI,
};

render(
Expand Down
6 changes: 3 additions & 3 deletions packages/cfd/src/Containers/cfd-dbvi-onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { localize } from '@deriv/translations';
import RootStore from '../Stores/index';
import { PoiPoaDocsSubmitted } from '@deriv/account';
import { connect } from '../Stores/connect';
import { getAuthenticationStatusInfo, isMobile, WS } from '@deriv/shared';
import { getAuthenticationStatusInfo, isMobile, WS, Jurisdiction } from '@deriv/shared';
import { AccountStatusResponse } from '@deriv/api-types';
import { TCFDDbviOnboardingProps } from './props.types';
import CFDFinancialStpRealAccountSignup from './cfd-financial-stp-real-account-signup';
Expand Down Expand Up @@ -63,13 +63,13 @@ const CFDDbviOnboarding = ({
if (get_account_status?.authentication) {
const { poi_acknowledged_for_vanuatu_maltainvest, poi_acknowledged_for_bvi_labuan, poa_acknowledged } =
getAuthenticationStatusInfo(get_account_status);
if (jurisdiction_selected_shortcode === 'vanuatu') {
if (jurisdiction_selected_shortcode === Jurisdiction.VANUATU) {
setShowSubmittedModal(
poi_acknowledged_for_vanuatu_maltainvest &&
poa_acknowledged &&
has_submitted_cfd_personal_details
);
} else if (jurisdiction_selected_shortcode === 'maltainvest') {
} else if (jurisdiction_selected_shortcode === Jurisdiction.MALTA_INVEST) {
setShowSubmittedModal(poi_acknowledged_for_vanuatu_maltainvest && poa_acknowledged);
} else
setShowSubmittedModal(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Div100vhContainer } from '@deriv/components';
import { isDesktop, getAuthenticationStatusInfo } from '@deriv/shared';
import { isDesktop, getAuthenticationStatusInfo, Jurisdiction } from '@deriv/shared';
import { connect } from '../Stores/connect';
import { LandingCompany, ResidenceList, GetSettings, StatesList, GetAccountStatus } from '@deriv/api-types';
import CFDPOA from '../Components/cfd-poa';
Expand Down Expand Up @@ -112,7 +112,10 @@ const CFDFinancialStpRealAccountSignup = (props: TCFDFinancialStpRealAccountSign
};

const should_show_poi = () => {
if (jurisdiction_selected_shortcode === 'vanuatu' || jurisdiction_selected_shortcode === 'maltainvest') {
if (
jurisdiction_selected_shortcode === Jurisdiction.VANUATU ||
jurisdiction_selected_shortcode === Jurisdiction.MALTA_INVEST
) {
return need_poi_for_vanuatu_maltainvest;
}
return need_poi_for_bvi_labuan;
Expand All @@ -122,7 +125,7 @@ const CFDFinancialStpRealAccountSignup = (props: TCFDFinancialStpRealAccountSign
);

const should_show_personal_details =
!has_submitted_cfd_personal_details && jurisdiction_selected_shortcode !== 'maltainvest';
!has_submitted_cfd_personal_details && jurisdiction_selected_shortcode !== Jurisdiction.MALTA_INVEST;

const verification_configs = [
...(should_show_poi() ? [poi_config] : []),
Expand Down
17 changes: 9 additions & 8 deletions packages/cfd/src/Containers/cfd-password-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
getLegalEntityName,
isDesktop,
isMobile,
Jurisdiction,
routes,
validLength,
validPassword,
Expand Down Expand Up @@ -187,12 +188,12 @@ const ReviewMessageForMT5 = ({
return (
<Localize i18n_default_text='To start trading, top-up funds from your Deriv account into this account.' />
);
} else if (['bvi', 'vanuatu'].includes(jurisdiction_selected_shortcode)) {
} else if ([Jurisdiction.BVI, Jurisdiction.VANUATU].includes(jurisdiction_selected_shortcode)) {
if (manual_status === 'pending') {
return <Localize i18n_default_text='We’re reviewing your documents. This should take about 1 to 3 days.' />;
}
return <Localize i18n_default_text='We’re reviewing your documents. This should take about 5 minutes.' />;
} else if (['labuan', 'maltainvest'].includes(jurisdiction_selected_shortcode)) {
} else if ([Jurisdiction.LABUAN, Jurisdiction.MALTA_INVEST].includes(jurisdiction_selected_shortcode)) {
return <Localize i18n_default_text='We’re reviewing your documents. This should take about 1 to 3 days.' />;
}
return null;
Expand Down Expand Up @@ -663,15 +664,15 @@ const CFDPasswordModal = ({
const [is_selected_mt5_verified, setIsSelectedMT5Verified] = React.useState(false);

const getVerificationStatus = () => {
if (jurisdiction_selected_shortcode === 'svg') {
if (jurisdiction_selected_shortcode === Jurisdiction.SVG) {
setIsSelectedMT5Verified(true);
} else if (jurisdiction_selected_shortcode === 'bvi') {
} else if (jurisdiction_selected_shortcode === Jurisdiction.BVI) {
setIsSelectedMT5Verified(poi_verified_for_bvi_labuan);
} else if (jurisdiction_selected_shortcode === 'vanuatu') {
} else if (jurisdiction_selected_shortcode === Jurisdiction.VANUATU) {
setIsSelectedMT5Verified(poi_verified_for_vanuatu_maltainvest);
} else if (jurisdiction_selected_shortcode === 'labuan') {
} else if (jurisdiction_selected_shortcode === Jurisdiction.LABUAN) {
setIsSelectedMT5Verified(poi_verified_for_bvi_labuan && poa_verified);
} else if (jurisdiction_selected_shortcode === 'maltainvest') {
} else if (jurisdiction_selected_shortcode === Jurisdiction.MALTA_INVEST) {
setIsSelectedMT5Verified(poi_verified_for_vanuatu_maltainvest && poa_verified);
}
};
Expand Down Expand Up @@ -813,7 +814,7 @@ const CFDPasswordModal = ({
].short_title;
const jurisdiction_label =
jurisdiction_selected_shortcode && getFormattedJurisdictionCode(jurisdiction_selected_shortcode);
const mt5_platform_label = jurisdiction_selected_shortcode !== 'maltainvest' ? 'MT5' : '';
const mt5_platform_label = jurisdiction_selected_shortcode !== Jurisdiction.MALTA_INVEST ? 'MT5' : '';

if (category === 'real') {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Checkbox, StaticUrl, Text } from '@deriv/components';
import { isMobile } from '@deriv/shared';
import { isMobile, Jurisdiction } from '@deriv/shared';
import { Localize } from '@deriv/translations';
import { TJurisdictionCheckBoxProps } from '../props.types';

Expand All @@ -16,9 +16,9 @@ const JurisdictionCheckBox = ({
const shouldShowCheckBox = () => {
if (jurisdiction_selected_shortcode) {
if (
jurisdiction_selected_shortcode === 'svg' ||
(jurisdiction_selected_shortcode === 'bvi' && should_restrict_bvi_account_creation) ||
(jurisdiction_selected_shortcode === 'vanuatu' && should_restrict_vanuatu_account_creation)
jurisdiction_selected_shortcode === Jurisdiction.SVG ||
(jurisdiction_selected_shortcode === Jurisdiction.BVI && should_restrict_bvi_account_creation) ||
(jurisdiction_selected_shortcode === Jurisdiction.VANUATU && should_restrict_vanuatu_account_creation)
) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { TJurisdictionModalContentProps } from '../props.types';
import JurisdictionCard from './jurisdiction-card';
import { Jurisdiction } from '@deriv/shared';

const JurisdictionModalContent = ({
account_type,
Expand Down Expand Up @@ -28,7 +29,13 @@ const JurisdictionModalContent = ({
? real_synthetic_accounts_existing_data?.some(account => account.landing_company_short === type_of_card)
: real_financial_accounts_existing_data?.some(account => account.landing_company_short === type_of_card);
};
const jurisdiction_cards_array = ['svg', 'bvi', 'vanuatu', 'labuan', 'maltainvest'];
const jurisdiction_cards_array = [
Jurisdiction.SVG,
Jurisdiction.BVI,
Jurisdiction.VANUATU,
Jurisdiction.LABUAN,
Jurisdiction.MALTA_INVEST,
];
return (
<React.Fragment>
<div className={`${card_classname}__wrapper`}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Text } from '@deriv/components';
import { Localize } from '@deriv/translations';
import { getAuthenticationStatusInfo, isMobile } from '@deriv/shared';
import { getAuthenticationStatusInfo, isMobile, Jurisdiction } from '@deriv/shared';
import { TJurisdictionModalFootNoteProps } from '../props.types';

const FooterNote = ({
Expand All @@ -17,16 +17,16 @@ const FooterNote = ({

const { poa_pending } = getAuthenticationStatusInfo(account_status);

if (jurisdiction_selected_shortcode === 'svg') {
if (jurisdiction_selected_shortcode === Jurisdiction.SVG) {
return (
<Localize
i18n_default_text='Add your Deriv MT5 <0>{{account_type_name}}</0> account under Deriv (SVG) LLC (company no. 273 LLC 2020).'
values={{ account_type_name }}
/>
);
} else if (
(jurisdiction_selected_shortcode === 'bvi' && should_restrict_bvi_account_creation) ||
(jurisdiction_selected_shortcode === 'vanuatu' && should_restrict_vanuatu_account_creation)
(jurisdiction_selected_shortcode === Jurisdiction.BVI && should_restrict_bvi_account_creation) ||
(jurisdiction_selected_shortcode === Jurisdiction.VANUATU && should_restrict_vanuatu_account_creation)
) {
return poa_pending ? (
<Localize
Expand All @@ -36,28 +36,28 @@ const FooterNote = ({
) : (
<Localize i18n_default_text='To create this account first we need you to resubmit your proof of address.' />
);
} else if (jurisdiction_selected_shortcode === 'bvi') {
} else if (jurisdiction_selected_shortcode === Jurisdiction.BVI) {
return (
<Localize
i18n_default_text='Add your Deriv MT5 <0>{{account_type_name}}</0> account under Deriv (BVI) Ltd, regulated by the British Virgin Islands Financial Services Commission (License no. SIBA/L/18/1114).'
values={{ account_type_name }}
/>
);
} else if (jurisdiction_selected_shortcode === 'vanuatu') {
} else if (jurisdiction_selected_shortcode === Jurisdiction.VANUATU) {
return (
<Localize
i18n_default_text='Add Your Deriv MT5 <0>{{account_type_name}}</0> account under Deriv (V) Ltd, regulated by the Vanuatu Financial Services Commission.'
values={{ account_type_name }}
/>
);
} else if (jurisdiction_selected_shortcode === 'labuan') {
} else if (jurisdiction_selected_shortcode === Jurisdiction.LABUAN) {
return (
<Localize
i18n_default_text='Add your Deriv MT5 <0>{{account_type_name}}</0> STP account under Deriv (FX) Ltd regulated by Labuan Financial Services Authority (Licence no. MB/18/0024).'
values={{ account_type_name }}
/>
);
} else if (jurisdiction_selected_shortcode === 'maltainvest') {
} else if (jurisdiction_selected_shortcode === Jurisdiction.MALTA_INVEST) {
return (
<Localize i18n_default_text='Add your Deriv MT5 CFDs account under Deriv Investments (Europe) Limited, regulated by the Malta Financial Services Authority (MFSA) (licence no. IS/70156).' />
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { localize } from '@deriv/translations';
import { connect } from '../../Stores/connect';
import RootStore from '../../Stores/index';
import JurisdictionModalContent from './jurisdiction-modal-content';
import { getAuthenticationStatusInfo, isMobile } from '@deriv/shared';
import { getAuthenticationStatusInfo, isMobile, Jurisdiction } from '@deriv/shared';
import { TJurisdictionModalProps } from '../props.types';
import JurisdictionCheckBox from './jurisdiction-modal-checkbox';
import JurisdictionModalFootNote from './jurisdiction-modal-foot-note';
Expand Down Expand Up @@ -82,11 +82,11 @@ const JurisdictionModal = ({
account_type: account_type.type === 'synthetic' ? 'Derived' : 'Financial',
});

const is_svg_selected = jurisdiction_selected_shortcode === 'svg';
const is_bvi_selected = jurisdiction_selected_shortcode === 'bvi';
const is_vanuatu_selected = jurisdiction_selected_shortcode === 'vanuatu';
const is_labuan_selected = jurisdiction_selected_shortcode === 'labuan';
const is_maltainvest_selected = jurisdiction_selected_shortcode === 'maltainvest';
const is_svg_selected = jurisdiction_selected_shortcode === Jurisdiction.SVG;
const is_bvi_selected = jurisdiction_selected_shortcode === Jurisdiction.BVI;
const is_vanuatu_selected = jurisdiction_selected_shortcode === Jurisdiction.VANUATU;
const is_labuan_selected = jurisdiction_selected_shortcode === Jurisdiction.LABUAN;
const is_maltainvest_selected = jurisdiction_selected_shortcode === Jurisdiction.MALTA_INVEST;

const isNextButtonDisabled = () => {
if (jurisdiction_selected_shortcode) {
Expand Down
12 changes: 6 additions & 6 deletions packages/cfd/src/Containers/mt5-compare-table-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import classNames from 'classnames';
import { Table, Button, Text, Popover } from '@deriv/components';
import { localize } from '@deriv/translations';
import { isDesktop, WS, getAuthenticationStatusInfo, CFD_PLATFORMS, ContentFlag } from '@deriv/shared';
import { isDesktop, WS, getAuthenticationStatusInfo, CFD_PLATFORMS, ContentFlag, Jurisdiction } from '@deriv/shared';
import { connect } from '../Stores/connect';
import RootStore from '../Stores/index';
import {
Expand Down Expand Up @@ -303,13 +303,13 @@ const DMT5CompareModalContent = ({
case 'synthetic_svg':
case 'financial_svg':
setAppstorePlatform(CFD_PLATFORMS.MT5);
setJurisdictionSelectedShortcode('svg');
setJurisdictionSelectedShortcode(Jurisdiction.SVG);
openPasswordModal(type_of_account);
break;
case 'synthetic_bvi':
case 'financial_bvi':
setAppstorePlatform(CFD_PLATFORMS.MT5);
setJurisdictionSelectedShortcode('bvi');
setJurisdictionSelectedShortcode(Jurisdiction.BVI);
if (
poi_acknowledged_for_bvi_labuan &&
!poi_or_poa_not_submitted &&
Expand All @@ -325,7 +325,7 @@ const DMT5CompareModalContent = ({
case 'synthetic_vanuatu':
case 'financial_vanuatu':
setAppstorePlatform(CFD_PLATFORMS.MT5);
setJurisdictionSelectedShortcode('vanuatu');
setJurisdictionSelectedShortcode(Jurisdiction.VANUATU);
if (
poi_acknowledged_for_vanuatu_maltainvest &&
!poi_or_poa_not_submitted &&
Expand All @@ -340,7 +340,7 @@ const DMT5CompareModalContent = ({
break;
case 'financial_labuan':
setAppstorePlatform(CFD_PLATFORMS.MT5);
setJurisdictionSelectedShortcode('labuan');
setJurisdictionSelectedShortcode(Jurisdiction.LABUAN);
if (poi_acknowledged_for_bvi_labuan && poa_acknowledged && has_submitted_personal_details) {
openPasswordModal(type_of_account);
} else {
Expand All @@ -349,7 +349,7 @@ const DMT5CompareModalContent = ({
break;
case 'financial_maltainvest':
setAppstorePlatform(CFD_PLATFORMS.MT5);
setJurisdictionSelectedShortcode('maltainvest');
setJurisdictionSelectedShortcode(Jurisdiction.MALTA_INVEST);
if ((poi_acknowledged_for_vanuatu_maltainvest && poa_acknowledged) || is_demo_tab) {
openPasswordModal(type_of_account);
} else {
Expand Down
9 changes: 5 additions & 4 deletions packages/cfd/src/Stores/Modules/CFD/Helpers/cfd-config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { localize } from '@deriv/translations';
import { Jurisdiction } from '@deriv/shared';

export type TDxCompanies = ReturnType<typeof getDxCompanies>;
export type TMtCompanies = ReturnType<typeof getMtCompanies>;
Expand Down Expand Up @@ -184,16 +185,16 @@ export const getFormattedJurisdictionCode = (jurisdiction_code: string) => {
let formatted_label = '';

switch (jurisdiction_code) {
case 'svg':
case Jurisdiction.SVG:
formatted_label = localize('SVG');
break;
case 'bvi':
case Jurisdiction.BVI:
formatted_label = localize('BVI');
break;
case 'labuan':
case Jurisdiction.LABUAN:
formatted_label = localize('Labuan');
break;
case 'vanuatu':
case Jurisdiction.VANUATU:
formatted_label = localize('Vanuatu');
break;
default:
Expand Down
Loading