From ea29f9606ceb361dd5bf4808ae70706ddd8aac62 Mon Sep 17 00:00:00 2001 From: Taysuisin Date: Wed, 15 Mar 2023 16:05:29 +0800 Subject: [PATCH 1/7] chore: move hard coded part and make it more dynamic --- .../poi-poa-docs-submitted.jsx | 5 +++-- .../proof-of-identity-submission-for-mt5.jsx | 4 ++-- .../cfd/src/Containers/cfd-dbvi-onboarding.tsx | 6 +++--- .../cfd-financial-stp-real-account-signup.tsx | 9 ++++++--- .../cfd/src/Containers/cfd-password-modal.tsx | 17 +++++++++-------- .../jurisdiction-modal-checkbox.tsx | 8 ++++---- .../jurisdiction-modal-foot-note.tsx | 14 +++++++------- .../jurisdiction-modal/jurisdiction-modal.tsx | 12 ++++++------ .../cfd/src/Stores/Modules/CFD/cfd-store.js | 4 ++-- .../shared/src/utils/constants/jurisdiction.ts | 7 +++++++ 10 files changed, 49 insertions(+), 37 deletions(-) create mode 100644 packages/shared/src/utils/constants/jurisdiction.ts diff --git a/packages/account/src/Components/poi-poa-docs-submitted/poi-poa-docs-submitted.jsx b/packages/account/src/Components/poi-poa-docs-submitted/poi-poa-docs-submitted.jsx index 5989c2f3230d..4744967cbe0c 100644 --- a/packages/account/src/Components/poi-poa-docs-submitted/poi-poa-docs-submitted.jsx +++ b/packages/account/src/Components/poi-poa-docs-submitted/poi-poa-docs-submitted.jsx @@ -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 = ({ @@ -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) || diff --git a/packages/account/src/Sections/Verification/ProofOfIdentity/proof-of-identity-submission-for-mt5.jsx b/packages/account/src/Sections/Verification/ProofOfIdentity/proof-of-identity-submission-for-mt5.jsx index bbd331f78617..31a74bc9996b 100644 --- a/packages/account/src/Sections/Verification/ProofOfIdentity/proof-of-identity-submission-for-mt5.jsx +++ b/packages/account/src/Sections/Verification/ProofOfIdentity/proof-of-identity-submission-for-mt5.jsx @@ -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'; @@ -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) { diff --git a/packages/cfd/src/Containers/cfd-dbvi-onboarding.tsx b/packages/cfd/src/Containers/cfd-dbvi-onboarding.tsx index 6631c4ff3c9b..5e77900cb668 100644 --- a/packages/cfd/src/Containers/cfd-dbvi-onboarding.tsx +++ b/packages/cfd/src/Containers/cfd-dbvi-onboarding.tsx @@ -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'; @@ -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( diff --git a/packages/cfd/src/Containers/cfd-financial-stp-real-account-signup.tsx b/packages/cfd/src/Containers/cfd-financial-stp-real-account-signup.tsx index 06b4a8088b38..46772599ad6b 100644 --- a/packages/cfd/src/Containers/cfd-financial-stp-real-account-signup.tsx +++ b/packages/cfd/src/Containers/cfd-financial-stp-real-account-signup.tsx @@ -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'; @@ -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; @@ -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] : []), diff --git a/packages/cfd/src/Containers/cfd-password-modal.tsx b/packages/cfd/src/Containers/cfd-password-modal.tsx index ecd7c5e1a6d0..f7d0a76a997c 100644 --- a/packages/cfd/src/Containers/cfd-password-modal.tsx +++ b/packages/cfd/src/Containers/cfd-password-modal.tsx @@ -23,6 +23,7 @@ import { getLegalEntityName, isDesktop, isMobile, + Jurisdiction, routes, validLength, validPassword, @@ -187,12 +188,12 @@ const ReviewMessageForMT5 = ({ return ( ); - } else if (['bvi', 'vanuatu'].includes(jurisdiction_selected_shortcode)) { + } else if ([Jurisdiction.BVI, Jurisdiction.VANUATU].includes(jurisdiction_selected_shortcode)) { if (manual_status === 'pending') { return ; } return ; - } else if (['labuan', 'maltainvest'].includes(jurisdiction_selected_shortcode)) { + } else if ([Jurisdiction.LABUAN, Jurisdiction.MALTA_INVEST].includes(jurisdiction_selected_shortcode)) { return ; } return null; @@ -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); } }; @@ -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 ( diff --git a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-checkbox.tsx b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-checkbox.tsx index 6b453405b1e1..1cc3886b63a6 100644 --- a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-checkbox.tsx +++ b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-checkbox.tsx @@ -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'; @@ -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; } diff --git a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-foot-note.tsx b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-foot-note.tsx index a9f4ddec1090..4bcbcd2d61a4 100644 --- a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-foot-note.tsx +++ b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-foot-note.tsx @@ -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 = ({ @@ -17,7 +17,7 @@ const FooterNote = ({ const { poa_pending } = getAuthenticationStatusInfo(account_status); - if (jurisdiction_selected_shortcode === 'svg') { + if (jurisdiction_selected_shortcode === Jurisdiction.SVG) { return ( ); } 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 ? ( ); - } else if (jurisdiction_selected_shortcode === 'vanuatu') { + } else if (jurisdiction_selected_shortcode === Jurisdiction.VANUATU) { return ( ); - } else if (jurisdiction_selected_shortcode === 'labuan') { + } else if (jurisdiction_selected_shortcode === Jurisdiction.LABUAN) { return ( ); - } else if (jurisdiction_selected_shortcode === 'maltainvest') { + } else if (jurisdiction_selected_shortcode === Jurisdiction.MALTA_INVEST) { return ( ); diff --git a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal.tsx b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal.tsx index 60bf787fcf05..ea9b9eb08067 100644 --- a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal.tsx +++ b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal.tsx @@ -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'; @@ -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) { diff --git a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js index 3a7e6e007c41..29b87f03098a 100644 --- a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js +++ b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js @@ -1,5 +1,5 @@ import { action, computed, observable, reaction, runInAction, makeObservable, override } from 'mobx'; -import { getAccountListKey, getAccountTypeFields, CFD_PLATFORMS, WS } from '@deriv/shared'; +import { getAccountListKey, getAccountTypeFields, CFD_PLATFORMS, WS, Jurisdiction } from '@deriv/shared'; import BaseStore from 'Stores/base-store'; import { getDxCompanies, getMtCompanies } from './Helpers/cfd-config'; @@ -280,7 +280,7 @@ export default class CFDStore extends BaseStore { zipCode: address_postcode, ...(values.server ? { server: values.server } : {}), ...(this.jurisdiction_selected_shortcode ? { company: this.jurisdiction_selected_shortcode } : {}), - ...(this.jurisdiction_selected_shortcode !== 'labuan' + ...(this.jurisdiction_selected_shortcode !== Jurisdiction.LABUAN ? type_request : { account_type: 'financial', diff --git a/packages/shared/src/utils/constants/jurisdiction.ts b/packages/shared/src/utils/constants/jurisdiction.ts new file mode 100644 index 000000000000..3030e044221d --- /dev/null +++ b/packages/shared/src/utils/constants/jurisdiction.ts @@ -0,0 +1,7 @@ +export const Jurisdiction = Object.freeze({ + SVG: 'svg', + BVI: 'bvi', + VANUATU: 'vanuatu', + LABUAN: 'labuan', + MALTA_INVEST: 'maltainvest', +}); From 651a1df2af4156fdb57830d0a2d7cb87f6eb726d Mon Sep 17 00:00:00 2001 From: Taysuisin Date: Wed, 22 Mar 2023 13:40:41 +0800 Subject: [PATCH 2/7] chore: move strings to use standard constant jurisdiction object --- packages/cfd/src/Components/cfd-account-card.tsx | 6 ++++-- packages/cfd/src/Containers/cfd-password-modal.tsx | 2 +- .../jurisdiction-modal/jurisdiction-modal-content.tsx | 9 ++++++++- .../cfd/src/Stores/Modules/CFD/Helpers/cfd-config.ts | 9 +++++---- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/cfd/src/Components/cfd-account-card.tsx b/packages/cfd/src/Components/cfd-account-card.tsx index 5d2de82992ed..7d6f395d12b2 100644 --- a/packages/cfd/src/Components/cfd-account-card.tsx +++ b/packages/cfd/src/Components/cfd-account-card.tsx @@ -2,7 +2,7 @@ import classNames from 'classnames'; import React from 'react'; import { CSSTransition } from 'react-transition-group'; import { Icon, Money, Button, Text, DesktopWrapper, MobileWrapper, Popover } from '@deriv/components'; -import { isMobile, mobileOSDetect, getCFDPlatformLabel, CFD_PLATFORMS, isDesktop } from '@deriv/shared'; +import { isMobile, mobileOSDetect, getCFDPlatformLabel, CFD_PLATFORMS, isDesktop, Jurisdiction } from '@deriv/shared'; import { localize, Localize } from '@deriv/translations'; import { connect } from '../Stores/connect'; import RootStore from '../Stores/index'; @@ -545,7 +545,9 @@ const CFDAccountCardComponent = ({ { const [is_password_modal_exited, setPasswordModalExited] = React.useState(true); - const is_bvi = landing_companies?.mt_financial_company?.financial_stp?.shortcode === 'bvi'; + const is_bvi = landing_companies?.mt_financial_company?.financial_stp?.shortcode === Jurisdiction.BVI; const has_mt5_account = Boolean(mt5_login_list?.length); const should_set_trading_password = Array.isArray(account_status?.status) && diff --git a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-content.tsx b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-content.tsx index 800cfc63a5e9..5b821e002d3c 100644 --- a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-content.tsx +++ b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-content.tsx @@ -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, @@ -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 (
diff --git a/packages/cfd/src/Stores/Modules/CFD/Helpers/cfd-config.ts b/packages/cfd/src/Stores/Modules/CFD/Helpers/cfd-config.ts index 0de741e45e0f..0785f3b59305 100644 --- a/packages/cfd/src/Stores/Modules/CFD/Helpers/cfd-config.ts +++ b/packages/cfd/src/Stores/Modules/CFD/Helpers/cfd-config.ts @@ -1,4 +1,5 @@ import { localize } from '@deriv/translations'; +import { Jurisdiction } from '@deriv/shared'; export type TDxCompanies = ReturnType; export type TMtCompanies = ReturnType; @@ -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: From 92c2f78ed3200b453130563cd0743f7731cd3d94 Mon Sep 17 00:00:00 2001 From: Taysuisin Date: Wed, 22 Mar 2023 15:41:52 +0800 Subject: [PATCH 3/7] chore: update all files change string to use same Jurisdiction in constant file --- .../__tests__/currency-selector.spec.tsx | 8 +-- .../personal-details/personal-details.jsx | 15 +++++- .../__tests__/terms-of-use.spec.js | 8 +-- .../terms-of-use/terms-of-use-messages.jsx | 10 ++-- .../account/src/Configs/accept-risk-config.js | 4 +- .../src/Configs/address-details-config.js | 26 +++++---- .../src/Configs/currency-selector-schema.js | 3 +- .../src/Configs/financial-details-config.js | 36 ++++++------- .../src/Configs/personal-details-config.js | 39 ++++++++------ .../src/Configs/terms-of-use-config.js | 6 +-- .../src/Configs/trading-assessment-config.js | 4 +- packages/account/src/Containers/account.jsx | 13 +++-- .../financial-assessment.jsx | 4 +- .../PersonalDetails/personal-details.jsx | 3 +- .../Security/SelfExclusion/self-exclusion.jsx | 4 +- .../add-options-account.tsx | 4 +- .../currency-switcher-container.tsx | 3 +- .../real/real-account-card.tsx | 4 +- .../failed-verification-modal.tsx | 6 +-- .../options-multipliers-listing/index.tsx | 4 +- .../src/services/api/account-limits.js | 4 +- .../cashier/src/pages/deposit/deposit.tsx | 7 ++- .../__tests__/account-transfer-store.spec.ts | 4 +- .../src/stores/account-transfer-store.ts | 5 +- .../__tests__/cfd-account-card.spec.tsx | 7 +-- .../cfd-demo-account-display.spec.js | 15 ++++-- .../cfd-real-account-display.spec.js | 13 ++--- .../cfd/src/Components/cfd-account-card.tsx | 18 ++++--- .../Components/cfd-demo-account-display.tsx | 3 +- .../cfd-mt5-demo-account-display.tsx | 3 +- .../__tests__/cfd-dashboard.spec.tsx | 16 +++--- .../__tests__/cfd-password-modal.spec.js | 6 +-- .../cfd/src/Containers/derivx-trade-modal.tsx | 3 +- .../cfd/src/Containers/dmt5-trade-modal.tsx | 3 +- .../jurisdiction-modal-content.tsx | 2 +- .../jurisdiction-modal-foot-note.tsx | 2 +- .../jurisdiction-modal/jurisdiction-modal.tsx | 8 +-- .../Containers/mt5-compare-table-content.tsx | 16 +++--- .../cfd/src/Stores/Modules/CFD/cfd-store.js | 12 ++--- .../deriv-real-account-required-modal.jsx | 3 +- .../Layout/Footer/regulatory-information.jsx | 6 +-- .../Layout/Header/toggle-menu-drawer.jsx | 6 +-- .../account-switcher-account-list.jsx | 13 +++-- .../AccountSwitcher/account-switcher.jsx | 23 +++++--- .../src/App/Containers/Modals/app-modals.jsx | 4 +- .../exit-traders-hub-modal.jsx | 3 +- .../ready-to-deposit-modal.tsx | 3 +- .../RealAccountSignup/account-wizard-form.js | 6 +-- .../RealAccountSignup/account-wizard.jsx | 4 +- .../RealAccountSignup/helpers/constants.js | 7 +-- .../helpers/dialog-buttons.jsx | 5 +- .../helpers/dialog-message.jsx | 3 +- .../proof-of-address-form.js | 4 +- .../proof-of-identity-form.js | 4 +- .../RealAccountSignup/real-account-signup.jsx | 10 ++-- .../Containers/WelcomeModal/welcome-modal.jsx | 3 +- .../Containers/app-notification-messages.jsx | 4 +- .../Components/complaints-policy-content.jsx | 20 +++---- packages/core/src/Stores/client-store.js | 49 +++++++++-------- .../core/src/Stores/notification-store.js | 9 ++-- packages/core/src/Stores/traders-hub-store.js | 54 +++++++++++-------- .../src/__tests__/useDepositLocked.spec.tsx | 15 +++--- packages/hooks/src/useDepositLocked.ts | 3 +- .../hooks/src/useHasMaltaInvestAccount.ts | 3 +- packages/shared/src/utils/cfd/cfd.ts | 15 +++--- packages/shared/src/utils/constants/index.ts | 1 + packages/stores/src/mockStore.ts | 3 +- .../src/Stores/Modules/Trading/trade-store.js | 3 +- 68 files changed, 368 insertions(+), 269 deletions(-) diff --git a/packages/account/src/Components/currency-selector/__tests__/currency-selector.spec.tsx b/packages/account/src/Components/currency-selector/__tests__/currency-selector.spec.tsx index 9cc96a824245..255df682efcf 100644 --- a/packages/account/src/Components/currency-selector/__tests__/currency-selector.spec.tsx +++ b/packages/account/src/Components/currency-selector/__tests__/currency-selector.spec.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { fireEvent, screen, render, waitFor } from '@testing-library/react'; -import { isDesktop, isMobile, PlatformContext } from '@deriv/shared'; +import { isDesktop, isMobile, PlatformContext, Jurisdiction } from '@deriv/shared'; import CurrencySelector, { TCurrencySelector } from '../currency-selector'; jest.mock('@deriv/shared', () => ({ @@ -269,20 +269,20 @@ describe('', () => { currency: 'USD', is_disabled: 0, is_virtual: 1, - landing_company_shortcode: 'svg', + landing_company_shortcode: Jurisdiction.SVG, trading: {}, token: 'a1-sLGGrhfYPkeEprxEop2T591cLKbuN', email: 'test+qw@deriv.com', session_start: 1651059038, excluded_until: '', - landing_company_name: 'svg', + landing_company_name: Jurisdiction.SVG, residence: 'es', balance: 10000, accepted_bch: 0, }, }, has_real_account: true, - real_account_signup_target: 'svg', + real_account_signup_target: Jurisdiction.SVG, }; render(); diff --git a/packages/account/src/Components/personal-details/personal-details.jsx b/packages/account/src/Components/personal-details/personal-details.jsx index 879855526a6f..4489ef8fe547 100644 --- a/packages/account/src/Components/personal-details/personal-details.jsx +++ b/packages/account/src/Components/personal-details/personal-details.jsx @@ -20,7 +20,16 @@ import { } from '@deriv/components'; import { Link } from 'react-router-dom'; import { localize, Localize } from '@deriv/translations'; -import { getLegalEntityName, isDesktop, isMobile, routes, toMoment, PlatformContext, validPhone } from '@deriv/shared'; +import { + getLegalEntityName, + isDesktop, + isMobile, + routes, + toMoment, + PlatformContext, + validPhone, + Jurisdiction, +} from '@deriv/shared'; import { getEmploymentStatusList } from 'Sections/Assessment/FinancialAssessment/financial-information-list'; import { splitValidationResultTypes } from '../real-account-signup/helpers/utils'; import FormSubHeader from '../form-sub-header'; @@ -671,7 +680,9 @@ const PersonalDetails = ({ label={localize( 'I hereby confirm that the tax information I provided is true and complete. I will also inform {{legal_entity_name}} about any changes to this information.', { - legal_entity_name: getLegalEntityName('maltainvest'), + legal_entity_name: getLegalEntityName( + Jurisdiction.MALTA_INVEST + ), } )} renderlabel={title => ( diff --git a/packages/account/src/Components/terms-of-use/__tests__/terms-of-use.spec.js b/packages/account/src/Components/terms-of-use/__tests__/terms-of-use.spec.js index 629854d40ff6..4a279c0ed0a9 100644 --- a/packages/account/src/Components/terms-of-use/__tests__/terms-of-use.spec.js +++ b/packages/account/src/Components/terms-of-use/__tests__/terms-of-use.spec.js @@ -1,6 +1,6 @@ import React from 'react'; import { fireEvent, render, screen, waitFor } from '@testing-library/react'; -import { isDesktop, isMobile, PlatformContext } from '@deriv/shared'; +import { isDesktop, isMobile, PlatformContext, Jurisdiction } from '@deriv/shared'; import TermsOfUse from '../terms-of-use'; jest.mock('@deriv/shared', () => ({ @@ -48,7 +48,7 @@ describe('', () => { }; it('should render TermsOfUse component for svg accounts', () => { - mock_props.real_account_signup_target = 'svg'; + mock_props.real_account_signup_target = Jurisdiction.SVG; render(); @@ -99,7 +99,7 @@ describe('', () => { }); it('should render TermsOfUse component for maltainvest accounts and show "Add account" button', () => { - mock_props.real_account_signup_target = 'maltainvest'; + mock_props.real_account_signup_target = Jurisdiction.MALTA_INVEST; render(); @@ -122,7 +122,7 @@ describe('', () => { isMobile.mockReturnValue(true); isDesktop.mockReturnValue(false); - mock_props.real_account_signup_target = 'maltainvest'; + mock_props.real_account_signup_target = Jurisdiction.MALTA_INVEST; render(); diff --git a/packages/account/src/Components/terms-of-use/terms-of-use-messages.jsx b/packages/account/src/Components/terms-of-use/terms-of-use-messages.jsx index 08b0d207aaa8..2e5f781cc9a1 100644 --- a/packages/account/src/Components/terms-of-use/terms-of-use-messages.jsx +++ b/packages/account/src/Components/terms-of-use/terms-of-use-messages.jsx @@ -1,16 +1,16 @@ import React from 'react'; import { Localize } from '@deriv/translations'; -import { getLegalEntityName } from '@deriv/shared'; +import { getLegalEntityName, Jurisdiction } from '@deriv/shared'; import { Text } from '@deriv/components'; export const Hr = () =>
; export const BrokerSpecificMessage = ({ target }) => ( - {target === 'svg' && } + {target === Jurisdiction.SVG && } {target === 'iom' && } {target === 'malta' && } - {target === 'maltainvest' && } + {target === Jurisdiction.MALTA_INVEST && } {target === 'samoa' && } ); @@ -26,7 +26,7 @@ export const SVGDescription = () => ( 'Your account will be opened with {{legal_entity_name}}, and will be subject to the laws of Saint Vincent and the Grenadines.' } values={{ - legal_entity_name: getLegalEntityName('svg'), + legal_entity_name: getLegalEntityName(Jurisdiction.SVG), }} />

@@ -91,7 +91,7 @@ export const MaltaInvestDescription = () => ( 'Your account will be opened with {{legal_entity_name}}, regulated by the Malta Financial Services Authority (MFSA), and will be subject to the laws of Malta.' } values={{ - legal_entity_name: getLegalEntityName('maltainvest'), + legal_entity_name: getLegalEntityName(Jurisdiction.MALTA_INVEST), }} />

diff --git a/packages/account/src/Configs/accept-risk-config.js b/packages/account/src/Configs/accept-risk-config.js index 0941fabebf9b..9b7a37c2ab14 100644 --- a/packages/account/src/Configs/accept-risk-config.js +++ b/packages/account/src/Configs/accept-risk-config.js @@ -1,8 +1,8 @@ -import { getDefaultFields } from '@deriv/shared'; +import { getDefaultFields, Jurisdiction } from '@deriv/shared'; const accept_risk_config = { accept_risk: { - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], default_value: 1, }, }; diff --git a/packages/account/src/Configs/address-details-config.js b/packages/account/src/Configs/address-details-config.js index 199aafa40fd6..57b9955952f2 100644 --- a/packages/account/src/Configs/address-details-config.js +++ b/packages/account/src/Configs/address-details-config.js @@ -1,5 +1,11 @@ import { localize } from '@deriv/translations'; -import { generateValidationFunction, getDefaultFields, getErrorMessages, regex_checks } from '@deriv/shared'; +import { + generateValidationFunction, + getDefaultFields, + getErrorMessages, + regex_checks, + Jurisdiction, +} from '@deriv/shared'; const address_details_config = ({ account_settings, is_svg }) => { const is_gb = account_settings.country_code === 'gb'; @@ -9,7 +15,7 @@ const address_details_config = ({ account_settings, is_svg }) => { const base_case = { address_line_1: { - supported_in: ['svg', 'iom', 'malta', 'maltainvest'], + supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], default_value: account_settings.address_line_1 ?? '', rules: [ ['req', localize('First line of address is required')], @@ -25,7 +31,7 @@ const address_details_config = ({ account_settings, is_svg }) => { ].filter(x => (is_svg ? x.indexOf('po_box') !== 0 : x)), }, address_line_2: { - supported_in: ['svg', 'iom', 'malta', 'maltainvest'], + supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], default_value: account_settings.address_line_2 ?? '', rules: [ ['length', localize('Only {{max}} characters, please.', { max: 70 }), { max: 70 }], @@ -40,7 +46,7 @@ const address_details_config = ({ account_settings, is_svg }) => { ].filter(x => (is_svg ? x.indexOf('po_box') !== 0 : x)), }, address_city: { - supported_in: ['svg', 'iom', 'malta', 'maltainvest'], + supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], default_value: account_settings.address_city ?? '', rules: [ ['req', localize('City is required')], @@ -55,7 +61,7 @@ const address_details_config = ({ account_settings, is_svg }) => { ], }, address_state: { - supported_in: ['svg', 'iom', 'malta', 'maltainvest'], + supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], default_value: account_settings.address_state ?? '', rules: [ ['req', localize('State is required')], @@ -69,7 +75,7 @@ const address_details_config = ({ account_settings, is_svg }) => { ], }, address_postcode: { - supported_in: ['svg', 'iom', 'malta', 'maltainvest'], + supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], default_value: account_settings.address_postcode ?? '', rules: [ [ @@ -96,7 +102,7 @@ const address_details_config = ({ account_settings, is_svg }) => { const gb_case = { ...base_case, address_postcode: { - supported_in: ['svg', 'iom', 'malta', 'maltainvest'], + supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], default_value: account_settings.address_postcode ?? '', rules: [ [ @@ -135,9 +141,9 @@ const addressDetailsConfig = ( AddressDetails, is_appstore = false ) => { - const is_svg = upgrade_info?.can_upgrade_to === 'svg'; + const is_svg = upgrade_info?.can_upgrade_to === Jurisdiction.SVG; const config = address_details_config({ account_settings, is_svg }); - const is_mf = real_account_signup_target === 'maltainvest'; + const is_mf = real_account_signup_target === Jurisdiction.MALTA_INVEST; return { header: { @@ -180,7 +186,7 @@ const transformForResidence = (rules, residence) => { const transformConfig = (config, { real_account_signup_target }) => { // Remove required rule for svg clients - if (!real_account_signup_target || real_account_signup_target === 'svg') { + if (!real_account_signup_target || real_account_signup_target === Jurisdiction.SVG) { config.address_state.rules.shift(); } diff --git a/packages/account/src/Configs/currency-selector-schema.js b/packages/account/src/Configs/currency-selector-schema.js index 6b6f882b2246..b5f16b179437 100644 --- a/packages/account/src/Configs/currency-selector-schema.js +++ b/packages/account/src/Configs/currency-selector-schema.js @@ -1,8 +1,9 @@ import { localize } from '@deriv/translations'; +import { Jurisdiction } from '@deriv/shared'; export default { currency: { - supported_in: ['maltainvest', 'malta', 'svg', 'iom'], + supported_in: [Jurisdiction.MALTA_INVEST, 'malta', Jurisdiction.SVG, 'iom'], default_value: '', rules: [['req', localize('Select an item')]], }, diff --git a/packages/account/src/Configs/financial-details-config.js b/packages/account/src/Configs/financial-details-config.js index bc75d64d2d73..8e1bee8485b1 100644 --- a/packages/account/src/Configs/financial-details-config.js +++ b/packages/account/src/Configs/financial-details-config.js @@ -1,91 +1,91 @@ import { localize } from '@deriv/translations'; -import { generateValidationFunction, getDefaultFields } from '@deriv/shared'; +import { generateValidationFunction, getDefaultFields, Jurisdiction } from '@deriv/shared'; const financial_details_config = ({ financial_assessment }) => { return { account_turnover: { - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], default_value: financial_assessment?.account_turnover ?? '', rules: [['req', localize('Please select an option')]], }, binary_options_trading_experience: { - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], default_value: financial_assessment?.binary_options_trading_experience ?? '', rules: [['req', localize('Please select an option')]], }, binary_options_trading_frequency: { - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], default_value: financial_assessment?.binary_options_trading_frequency ?? '', rules: [['req', localize('Please select an option')]], }, cfd_trading_experience: { - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], default_value: financial_assessment?.cfd_trading_experience ?? '', rules: [['req', localize('Please select an option')]], }, cfd_trading_frequency: { - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], default_value: financial_assessment?.cfd_trading_frequency ?? '', rules: [['req', localize('Please select an option')]], }, education_level: { - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], default_value: financial_assessment?.education_level ?? '', rules: [['req', localize('Please select an option')]], }, forex_trading_experience: { - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], default_value: financial_assessment?.forex_trading_experience ?? '', rules: [['req', localize('Please select an option')]], }, forex_trading_frequency: { - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], default_value: financial_assessment?.forex_trading_frequency ?? '', rules: [['req', localize('Please select an option')]], }, employment_industry: { default_value: financial_assessment?.employment_industry ?? '', - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], rules: [['req', localize('Please select an option')]], }, employment_status: { default_value: financial_assessment?.employment_status ?? '', - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], rules: [['req', localize('Please select an option')]], }, estimated_worth: { default_value: financial_assessment?.estimated_worth ?? '', - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], rules: [['req', localize('Please select an option')]], }, income_source: { default_value: financial_assessment?.income_source ?? '', - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], rules: [['req', localize('Please select an option')]], }, net_income: { default_value: financial_assessment?.net_income ?? '', - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], rules: [['req', localize('Please select an option')]], }, occupation: { default_value: financial_assessment?.occupation ?? '', - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], rules: [['req', localize('Please select an option')]], }, other_instruments_trading_experience: { default_value: financial_assessment?.other_instruments_trading_experience ?? '', - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], rules: [['req', localize('Please select an option')]], }, other_instruments_trading_frequency: { default_value: financial_assessment?.other_instruments_trading_frequency ?? '', - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], rules: [['req', localize('Please select an option')]], }, source_of_wealth: { default_value: financial_assessment?.source_of_wealth ?? '', - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], rules: [['req', localize('Please select an option')]], }, }; diff --git a/packages/account/src/Configs/personal-details-config.js b/packages/account/src/Configs/personal-details-config.js index a994b15edf82..9b292d3ebc05 100644 --- a/packages/account/src/Configs/personal-details-config.js +++ b/packages/account/src/Configs/personal-details-config.js @@ -1,4 +1,11 @@ -import { toMoment, getErrorMessages, generateValidationFunction, getDefaultFields, validLength } from '@deriv/shared'; +import { + toMoment, + getErrorMessages, + generateValidationFunction, + getDefaultFields, + validLength, + Jurisdiction, +} from '@deriv/shared'; import { localize } from '@deriv/translations'; const personal_details_config = ({ residence_list, account_settings, is_appstore, real_account_signup_target }) => { @@ -14,17 +21,17 @@ const personal_details_config = ({ residence_list, account_settings, is_appstore const config = { account_opening_reason: { - supported_in: ['iom', 'malta', 'maltainvest'], + supported_in: ['iom', 'malta', Jurisdiction.MALTA_INVEST], default_value: account_settings.account_opening_reason ?? '', rules: [['req', localize('Account opening reason is required.')]], }, salutation: { - supported_in: ['iom', 'malta', 'maltainvest'], + supported_in: ['iom', 'malta', Jurisdiction.MALTA_INVEST], default_value: account_settings.salutation ?? '', rules: [['req', localize('Salutation is required.')]], }, first_name: { - supported_in: ['svg', 'iom', 'malta', 'maltainvest'], + supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], default_value: account_settings.first_name ?? '', rules: [ ['req', localize('First name is required.')], @@ -33,7 +40,7 @@ const personal_details_config = ({ residence_list, account_settings, is_appstore ], }, last_name: { - supported_in: ['svg', 'iom', 'malta', 'maltainvest'], + supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], default_value: account_settings.last_name ?? '', rules: [ ['req', localize('Last name is required.')], @@ -42,7 +49,7 @@ const personal_details_config = ({ residence_list, account_settings, is_appstore ], }, date_of_birth: { - supported_in: ['svg', 'iom', 'malta', 'maltainvest'], + supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], default_value: account_settings.date_of_birth ? toMoment(account_settings.date_of_birth).format('YYYY-MM-DD') : '', @@ -55,21 +62,21 @@ const personal_details_config = ({ residence_list, account_settings, is_appstore ], }, place_of_birth: { - supported_in: ['maltainvest', 'iom', 'malta'], + supported_in: [Jurisdiction.MALTA_INVEST, 'iom', 'malta'], default_value: account_settings.place_of_birth ? residence_list.find(item => item.value === account_settings.place_of_birth)?.text : '', rules: [['req', localize('Place of birth is required.')]], }, citizen: { - supported_in: ['iom', 'malta', 'maltainvest'], + supported_in: ['iom', 'malta', Jurisdiction.MALTA_INVEST], default_value: account_settings.citizen ? residence_list.find(item => item.value === account_settings.citizen)?.text : '', rules: [['req', localize('Citizenship is required')]], }, phone: { - supported_in: ['svg', 'iom', 'malta', 'maltainvest'], + supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], default_value: account_settings.phone ?? '', rules: [ ['req', localize('Phone is required.')], @@ -89,15 +96,15 @@ const personal_details_config = ({ residence_list, account_settings, is_appstore }, tax_residence: { default_value: - real_account_signup_target === 'maltainvest' + real_account_signup_target === Jurisdiction.MALTA_INVEST ? account_settings.residence : residence_list.find(item => item.value === account_settings.tax_residence)?.text || '', - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], rules: [['req', localize('Tax residence is required.')]], }, tax_identification_number: { default_value: account_settings.tax_identification_number ?? '', - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], rules: [ ['req', localize('Tax Identification Number is required.')], [ @@ -135,12 +142,12 @@ const personal_details_config = ({ residence_list, account_settings, is_appstore }, employment_status: { default_value: '', - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], rules: [['req', localize('Employment status is required.')]], }, tax_identification_confirm: { default_value: false, - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], rules: [['confirm', localize('Please confirm your tax information.')]], }, }; @@ -184,8 +191,8 @@ const personalDetailsConfig = ( real_account_signup_target, transformConfig(config, { real_account_signup_target }) ), - is_svg: upgrade_info?.can_upgrade_to === 'svg', - is_mf: real_account_signup_target === 'maltainvest', + is_svg: upgrade_info?.can_upgrade_to === Jurisdiction.SVG, + is_mf: real_account_signup_target === Jurisdiction.MALTA_INVEST, account_opening_reason_list: [ { text: localize('Hedging'), diff --git a/packages/account/src/Configs/terms-of-use-config.js b/packages/account/src/Configs/terms-of-use-config.js index 384e6ffd32ae..0167018646b6 100644 --- a/packages/account/src/Configs/terms-of-use-config.js +++ b/packages/account/src/Configs/terms-of-use-config.js @@ -1,14 +1,14 @@ -import { getDefaultFields, isDesktop } from '@deriv/shared'; +import { getDefaultFields, isDesktop, Jurisdiction } from '@deriv/shared'; import { localize } from '@deriv/translations'; const terms_of_use_config = { agreed_tos: { - supported_in: ['svg', 'maltainvest'], + supported_in: [Jurisdiction.SVG, Jurisdiction.MALTA_INVEST], default_value: false, }, agreed_tnc: { - supported_in: ['svg', 'maltainvest'], + supported_in: [Jurisdiction.SVG, Jurisdiction.MALTA_INVEST], default_value: false, }, }; diff --git a/packages/account/src/Configs/trading-assessment-config.js b/packages/account/src/Configs/trading-assessment-config.js index e526ad205658..ab83aaed286d 100644 --- a/packages/account/src/Configs/trading-assessment-config.js +++ b/packages/account/src/Configs/trading-assessment-config.js @@ -1,4 +1,4 @@ -import { generateValidationFunction, getDefaultFields } from '@deriv/shared'; +import { generateValidationFunction, getDefaultFields, Jurisdiction } from '@deriv/shared'; import { localize } from '@deriv/translations'; export const trading_assessment_questions = () => [ @@ -253,7 +253,7 @@ export const trading_assessment_questions = () => [ ]; const default_form_config = { - supported_in: ['maltainvest'], + supported_in: [Jurisdiction.MALTA_INVEST], default_value: '', }; diff --git a/packages/account/src/Containers/account.jsx b/packages/account/src/Containers/account.jsx index aae57fba274d..0eacea56079e 100644 --- a/packages/account/src/Containers/account.jsx +++ b/packages/account/src/Containers/account.jsx @@ -2,7 +2,14 @@ import PropTypes from 'prop-types'; import React from 'react'; import { withRouter } from 'react-router-dom'; import { VerticalTab, FadeWrapper, PageOverlay, Loading, Text, Icon } from '@deriv/components'; -import { routes as shared_routes, isMobile, matchRoute, getSelectedRoute, PlatformContext } from '@deriv/shared'; +import { + routes as shared_routes, + isMobile, + matchRoute, + getSelectedRoute, + PlatformContext, + Jurisdiction, +} from '@deriv/shared'; import { localize } from '@deriv/translations'; import { connect } from 'Stores/connect'; import { flatten } from '../Helpers/flatten'; @@ -151,11 +158,11 @@ const Account = ({ if (route.path === shared_routes.financial_assessment) { route.is_disabled = - is_virtual || (active_account_landing_company === 'maltainvest' && !is_risky_client); + is_virtual || (active_account_landing_company === Jurisdiction.MALTA_INVEST && !is_risky_client); } if (route.path === shared_routes.trading_assessment) { - route.is_disabled = is_virtual || active_account_landing_company !== 'maltainvest'; + route.is_disabled = is_virtual || active_account_landing_company !== Jurisdiction.MALTA_INVEST; } if (route.path === shared_routes.proof_of_identity || route.path === shared_routes.proof_of_address) { diff --git a/packages/account/src/Sections/Assessment/FinancialAssessment/financial-assessment.jsx b/packages/account/src/Sections/Assessment/FinancialAssessment/financial-assessment.jsx index 931a3ac2b8bd..28c0ec104deb 100644 --- a/packages/account/src/Sections/Assessment/FinancialAssessment/financial-assessment.jsx +++ b/packages/account/src/Sections/Assessment/FinancialAssessment/financial-assessment.jsx @@ -15,7 +15,7 @@ import { SelectNative, Text, } from '@deriv/components'; -import { routes, isMobile, isDesktop, platforms, PlatformContext, WS } from '@deriv/shared'; +import { routes, isMobile, isDesktop, platforms, PlatformContext, WS, Jurisdiction } from '@deriv/shared'; import { localize, Localize } from '@deriv/translations'; import { connect } from 'Stores/connect'; import LeaveConfirm from 'Components/leave-confirm'; @@ -1025,7 +1025,7 @@ FinancialAssessment.propTypes = { export default connect(({ client, common, notifications }) => ({ is_authentication_needed: client.is_authentication_needed, is_financial_account: client.is_financial_account, - is_mf: client.landing_company_shortcode === 'maltainvest', + is_mf: client.landing_company_shortcode === Jurisdiction.MALTA_INVEST, is_svg: client.is_svg, is_financial_information_incomplete: client.is_financial_information_incomplete, is_trading_experience_incomplete: client.is_trading_experience_incomplete, diff --git a/packages/account/src/Sections/Profile/PersonalDetails/personal-details.jsx b/packages/account/src/Sections/Profile/PersonalDetails/personal-details.jsx index b4da912be5b0..7da18a1c91b0 100644 --- a/packages/account/src/Sections/Profile/PersonalDetails/personal-details.jsx +++ b/packages/account/src/Sections/Profile/PersonalDetails/personal-details.jsx @@ -36,6 +36,7 @@ import { WS, useIsMounted, validName, + Jurisdiction, } from '@deriv/shared'; import { Localize, localize } from '@deriv/translations'; import { withRouter } from 'react-router'; @@ -1366,7 +1367,7 @@ export default connect(({ client, notifications, ui, common }) => ({ getChangeableFields: client.getChangeableFields, current_landing_company: client.current_landing_company, is_eu: client.is_eu, - is_mf: client.landing_company_shortcode === 'maltainvest', + is_mf: client.landing_company_shortcode === Jurisdiction.MALTA_INVEST, is_svg: client.is_svg, is_uk: client.is_uk, is_virtual: client.is_virtual, diff --git a/packages/account/src/Sections/Security/SelfExclusion/self-exclusion.jsx b/packages/account/src/Sections/Security/SelfExclusion/self-exclusion.jsx index 481209b29d4c..ad6ba263de61 100644 --- a/packages/account/src/Sections/Security/SelfExclusion/self-exclusion.jsx +++ b/packages/account/src/Sections/Security/SelfExclusion/self-exclusion.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { PlatformContext, WS } from '@deriv/shared'; +import { Jurisdiction, PlatformContext, WS } from '@deriv/shared'; import { connect } from 'Stores/connect'; import SelfExclusionComponent from 'Components/self-exclusion/self-exclusion.jsx'; import 'Components/self-exclusion/self-exclusion.scss'; @@ -17,7 +17,7 @@ export default connect(({ client, ui }) => ({ is_cr: client.standpoint.svg, is_eu: client.is_eu, is_mlt: client.landing_company_shortcode === 'malta', - is_mf: client.landing_company_shortcode === 'maltainvest', + is_mf: client.landing_company_shortcode === Jurisdiction.MALTA_INVEST, is_mx: client.landing_company_shortcode === 'iom', is_uk: client.is_uk, is_wrapper_bypassed: false, diff --git a/packages/appstore/src/components/add-options-account/add-options-account.tsx b/packages/appstore/src/components/add-options-account/add-options-account.tsx index c42cc18b8734..ba74f0a385f6 100644 --- a/packages/appstore/src/components/add-options-account/add-options-account.tsx +++ b/packages/appstore/src/components/add-options-account/add-options-account.tsx @@ -4,7 +4,7 @@ import { Localize, localize } from '@deriv/translations'; import './add-options-account.scss'; import { observer } from 'mobx-react-lite'; import { useStores } from 'Stores'; -import { isMobile, ContentFlag } from '@deriv/shared'; +import { isMobile, ContentFlag, Jurisdiction } from '@deriv/shared'; const AddOptions = () => { const { client, traders_hub, ui } = useStores(); @@ -34,7 +34,7 @@ const AddOptions = () => { if (real_account_creation_unlock_date) { setShouldShowCooldownModal(true); } else { - openRealAccountSignup('maltainvest'); + openRealAccountSignup(Jurisdiction.MALTA_INVEST); } } else { openRealAccountSignup(); diff --git a/packages/appstore/src/components/containers/currency-switcher-container.tsx b/packages/appstore/src/components/containers/currency-switcher-container.tsx index 18f3de364293..67103ce2e579 100644 --- a/packages/appstore/src/components/containers/currency-switcher-container.tsx +++ b/packages/appstore/src/components/containers/currency-switcher-container.tsx @@ -1,6 +1,7 @@ import React, { HTMLAttributes, ReactNode } from 'react'; import classNames from 'classnames'; import { Icon } from '@deriv/components'; +import { Jurisdiction } from '@deriv/shared'; import CurrencyIcon, { Currency } from 'Assets/svgs/currency'; import './currency-switcher-container.scss'; import { useStores } from 'Stores/index'; @@ -32,7 +33,7 @@ const CurrentSwitcherContainer = ({ const has_mf_mt5_account = Object.keys(current_list) .map(key => current_list[key]) - .some(account => account.landing_company_short === 'maltainvest'); + .some(account => account.landing_company_short === Jurisdiction.MALTA_INVEST); const Dropdown = () => { const icon_dropdown = ( diff --git a/packages/appstore/src/components/currency-switcher-card/real/real-account-card.tsx b/packages/appstore/src/components/currency-switcher-card/real/real-account-card.tsx index 1618f61b4c4c..81adbe36ca51 100644 --- a/packages/appstore/src/components/currency-switcher-card/real/real-account-card.tsx +++ b/packages/appstore/src/components/currency-switcher-card/real/real-account-card.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { useHistory } from 'react-router'; import { observer } from 'mobx-react-lite'; import { Button, Text } from '@deriv/components'; -import { formatMoney, getCurrencyName, routes } from '@deriv/shared'; +import { formatMoney, getCurrencyName, routes, Jurisdiction } from '@deriv/shared'; import { localize } from '@deriv/translations'; import BalanceText from 'Components/elements/text/balance-text'; import CurrencySwitcherContainer from 'Components/containers/currency-switcher-container'; @@ -23,7 +23,7 @@ const RealAccountCard = () => { const has_mf_mt5_account = Object.keys(current_list) .map(key => current_list[key]) - .some(account => account.landing_company_short === 'maltainvest'); + .some(account => account.landing_company_short === Jurisdiction.MALTA_INVEST); return ( { const should_resubmit_poi = () => { if ( is_from_multipliers || - open_failed_verification_for === 'vanuatu' || - open_failed_verification_for === 'maltainvest' + open_failed_verification_for === Jurisdiction.VANUATU || + open_failed_verification_for === Jurisdiction.MALTA_INVEST ) { return poi_resubmit_for_vanuatu_maltainvest; } diff --git a/packages/appstore/src/components/options-multipliers-listing/index.tsx b/packages/appstore/src/components/options-multipliers-listing/index.tsx index 2012d60278fc..4b43904c0a4d 100644 --- a/packages/appstore/src/components/options-multipliers-listing/index.tsx +++ b/packages/appstore/src/components/options-multipliers-listing/index.tsx @@ -6,7 +6,7 @@ import ListingContainer from 'Components/containers/listing-container'; import { BrandConfig } from 'Constants/platform-config'; import TradingAppCard from 'Components/containers/trading-app-card'; import { useStores } from 'Stores/index'; -import { isMobile, ContentFlag } from '@deriv/shared'; +import { isMobile, ContentFlag, Jurisdiction } from '@deriv/shared'; import PlatformLoader from 'Components/pre-loader/platform-loader'; import { getHasDivider } from 'Constants/utils'; @@ -83,7 +83,7 @@ const OptionsAndMultipliersListing = () => { if (real_account_creation_unlock_date) { setShouldShowCooldownModal(true); } else { - openRealAccountSignup('maltainvest'); + openRealAccountSignup(Jurisdiction.MALTA_INVEST); } } else { openRealAccountSignup(); diff --git a/packages/bot-skeleton/src/services/api/account-limits.js b/packages/bot-skeleton/src/services/api/account-limits.js index 50ebafa8f07b..009922ec0ba7 100644 --- a/packages/bot-skeleton/src/services/api/account-limits.js +++ b/packages/bot-skeleton/src/services/api/account-limits.js @@ -1,8 +1,10 @@ +import { Jurisdiction } from '@deriv/shared'; + export default class AccountLimits { constructor(store) { this.ws = store.ws; } - getStakePayoutLimits(currency = 'AUD', landing_company_shortcode = 'svg', selected_market) { + getStakePayoutLimits(currency = 'AUD', landing_company_shortcode = Jurisdiction.SVG, selected_market) { return this.ws .send({ landing_company_details: landing_company_shortcode, diff --git a/packages/cashier/src/pages/deposit/deposit.tsx b/packages/cashier/src/pages/deposit/deposit.tsx index 5d359e169527..2216f2356238 100644 --- a/packages/cashier/src/pages/deposit/deposit.tsx +++ b/packages/cashier/src/pages/deposit/deposit.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Loading } from '@deriv/components'; import { useDepositLocked } from '@deriv/hooks'; -import { ContentFlag } from '@deriv/shared'; +import { ContentFlag, Jurisdiction } from '@deriv/shared'; import { useStore, observer } from '@deriv/stores'; import { Real, Virtual } from '../../components/cashier-container'; import { CashierOnboarding, CashierOnboardingSideNote } from '../../components/cashier-onboarding'; @@ -55,7 +55,10 @@ const Deposit = observer(({ setSideNotes }: TDeposit) => { const is_eu = [ContentFlag.LOW_RISK_CR_EU, ContentFlag.EU_REAL].includes(content_flag); const is_fiat_currency_banner_visible_for_MF_clients = - landing_company_shortcode === 'maltainvest' && !is_crypto && !can_change_fiat_currency && !!iframe_height; + landing_company_shortcode === Jurisdiction.MALTA_INVEST && + !is_crypto && + !can_change_fiat_currency && + !!iframe_height; React.useEffect(() => { if (!is_crypto_transactions_visible) { recentTransactionOnMount(); diff --git a/packages/cashier/src/stores/__tests__/account-transfer-store.spec.ts b/packages/cashier/src/stores/__tests__/account-transfer-store.spec.ts index 80b0a0e9afbd..08c86304ea9b 100644 --- a/packages/cashier/src/stores/__tests__/account-transfer-store.spec.ts +++ b/packages/cashier/src/stores/__tests__/account-transfer-store.spec.ts @@ -1,6 +1,6 @@ import AccountTransferStore from '../account-transfer-store'; import type { TransferBetweenAccountsResponse } from '@deriv/api-types'; -import { getCurrencies, validNumber, CFD_PLATFORMS } from '@deriv/shared'; +import { getCurrencies, validNumber, CFD_PLATFORMS, Jurisdiction } from '@deriv/shared'; import { configure } from 'mobx'; import type { TTransferAccount, TRootStore, TWebSocket } from 'Types'; @@ -147,7 +147,7 @@ beforeEach(() => { is_financial_information_incomplete: true, is_logged_in: true, is_trading_experience_incomplete: true, - landing_company_shortcode: 'maltainvest', + landing_company_shortcode: Jurisdiction.MALTA_INVEST, loginid: 'CR90000103', residence: 'pl', responseMt5LoginList: jest.fn(), diff --git a/packages/cashier/src/stores/account-transfer-store.ts b/packages/cashier/src/stores/account-transfer-store.ts index 10b6483374d1..1367a7cbd186 100644 --- a/packages/cashier/src/stores/account-transfer-store.ts +++ b/packages/cashier/src/stores/account-transfer-store.ts @@ -3,6 +3,7 @@ import { formatMoney, isEmptyObject, isCryptocurrency, + Jurisdiction, getCurrencies, getCurrencyDisplayCode, getDecimalPlaces, @@ -391,8 +392,8 @@ export default class AccountTransferStore { })}`; const non_eu_accounts = account.landing_company_short && - account.landing_company_short !== 'svg' && - account.landing_company_short !== 'bvi' + account.landing_company_short !== Jurisdiction.SVG && + account.landing_company_short !== Jurisdiction.BVI ? account.landing_company_short?.charAt(0).toUpperCase() + account.landing_company_short?.slice(1) : account.landing_company_short?.toUpperCase(); diff --git a/packages/cfd/src/Components/__tests__/cfd-account-card.spec.tsx b/packages/cfd/src/Components/__tests__/cfd-account-card.spec.tsx index 20260b408446..0ad649c519d1 100644 --- a/packages/cfd/src/Components/__tests__/cfd-account-card.spec.tsx +++ b/packages/cfd/src/Components/__tests__/cfd-account-card.spec.tsx @@ -1,5 +1,6 @@ import React from 'react'; import { fireEvent, render, screen } from '@testing-library/react'; +import { Jurisdiction } from '@deriv/shared'; import { CFDAccountCard } from '../cfd-account-card'; import { TCFDAccountCard } from '../props.types'; @@ -48,7 +49,7 @@ describe('CFDAccountCard', () => { platform: 'mt5', display_balance: '10000.00', display_login: '20103240', - landing_company_short: 'svg', + landing_company_short: Jurisdiction.SVG, login: 'MTD20103240', market_type: 'financial', }; @@ -59,7 +60,7 @@ describe('CFDAccountCard', () => { platform: 'dxtrade', display_balance: '10000.00', display_login: '20103240', - landing_company_short: 'svg', + landing_company_short: Jurisdiction.SVG, login: 'MTD20103240', market_type: 'financial', }; @@ -70,7 +71,7 @@ describe('CFDAccountCard', () => { platform: 'mt5', display_balance: '10000.00', display_login: '20103240', - landing_company_short: 'labuan', + landing_company_short: Jurisdiction.LABUAN, login: 'MTD20103240', market_type: 'financial', }; diff --git a/packages/cfd/src/Components/__tests__/cfd-demo-account-display.spec.js b/packages/cfd/src/Components/__tests__/cfd-demo-account-display.spec.js index df99caa38f01..58dbfc64606b 100644 --- a/packages/cfd/src/Components/__tests__/cfd-demo-account-display.spec.js +++ b/packages/cfd/src/Components/__tests__/cfd-demo-account-display.spec.js @@ -1,5 +1,6 @@ import { fireEvent, render, screen, within } from '@testing-library/react'; import React from 'react'; +import { Jurisdiction } from '@deriv/shared'; import { CFDDemoAccountDisplay } from '../cfd-demo-account-display'; const mock_connect_props = { @@ -45,8 +46,8 @@ describe('', () => { platform: 'mt5', residence: 'id', standpoint: { - financial_company: 'svg', - gaming_company: 'svg', + financial_company: Jurisdiction.SVG, + gaming_company: Jurisdiction.SVG, iom: false, malta: false, maltainvest: false, @@ -64,7 +65,7 @@ describe('', () => { display_login: '20103240', email: 'name@domain.com', group: 'demo\\p01_ts02\\financial\\svg_std_usd', - landing_company_short: 'svg', + landing_company_short: Jurisdiction.SVG, leverage: 1000, login: 'MTD20103240', market_type: 'financial', @@ -91,7 +92,7 @@ describe('', () => { display_balance: '10000.00', display_login: 'DXD1096', enabled: 1, - landing_company_short: 'svg', + landing_company_short: Jurisdiction.SVG, login: '374', market_type: 'synthetic', platform: 'dxtrade', @@ -155,7 +156,11 @@ describe('', () => { expect(add_demo_account_button).toBeEnabled(); fireEvent.click(add_demo_account_button); - expect(props.openAccountNeededModal).toHaveBeenCalledWith('maltainvest', 'Deriv Multipliers', 'demo CFDs'); + expect(props.openAccountNeededModal).toHaveBeenCalledWith( + Jurisdiction.MALTA_INVEST, + 'Deriv Multipliers', + 'demo CFDs' + ); }); it('should render a CFDs card only without "Add demo account" button on Deriv MT5 when is_logged_in=false & is_eu_country=true (also when redirected from Deriv X platform)', () => { diff --git a/packages/cfd/src/Components/__tests__/cfd-real-account-display.spec.js b/packages/cfd/src/Components/__tests__/cfd-real-account-display.spec.js index b59eda6699ea..42ff120bd9e0 100644 --- a/packages/cfd/src/Components/__tests__/cfd-real-account-display.spec.js +++ b/packages/cfd/src/Components/__tests__/cfd-real-account-display.spec.js @@ -1,5 +1,6 @@ import { fireEvent, render, screen, within } from '@testing-library/react'; import React from 'react'; +import { Jurisdiction } from '@deriv/shared'; import { CFDRealAccountDisplay } from '../cfd-real-account-display'; const mock_connect_props = { @@ -51,8 +52,8 @@ describe('', () => { residence: 'id', should_enable_add_button: false, standpoint: { - financial_company: 'svg', - gaming_company: 'svg', + financial_company: Jurisdiction.SVG, + gaming_company: Jurisdiction.SVG, iom: false, malta: false, maltainvest: false, @@ -120,7 +121,7 @@ describe('', () => { legal_default_currency: 'USD', name: 'Deriv (SVG) LLC', requirements: {}, - shortcode: 'svg', + shortcode: Jurisdiction.SVG, support_professional_client: 0, }; @@ -133,7 +134,7 @@ describe('', () => { display_login: '41165492', email: 'name@domain.com', group: 'real\\p01_ts03\\synthetic\\svg_std_usd\\03', - landing_company_short: 'svg', + landing_company_short: Jurisdiction.SVG, leverage: 500, login: 'MTR41165492', market_type: 'synthetic', @@ -161,7 +162,7 @@ describe('', () => { display_login: '1927245', email: 'name@domain.com', group: 'real\\p01_ts01\\financial\\svg_std-hr_usd', - landing_company_short: 'svg', + landing_company_short: Jurisdiction.SVG, leverage: 1000, login: 'MTR1927245', market_type: 'financial', @@ -188,7 +189,7 @@ describe('', () => { display_balance: '0.00', display_login: 'DXR1095', enabled: 1, - landing_company_short: 'svg', + landing_company_short: Jurisdiction.SVG, login: '374', market_type: 'synthetic', platform: 'dxtrade', diff --git a/packages/cfd/src/Components/cfd-account-card.tsx b/packages/cfd/src/Components/cfd-account-card.tsx index 7d6f395d12b2..49826db48679 100644 --- a/packages/cfd/src/Components/cfd-account-card.tsx +++ b/packages/cfd/src/Components/cfd-account-card.tsx @@ -248,7 +248,7 @@ const CFDAccountCardComponent = ({ const checkMultipleSvgAcc = () => { const all_svg_acc: DetailsOfEachMT5Loginid[] = []; existing_accounts_data?.map(acc => { - if (acc.landing_company_short === 'svg') { + if (acc.landing_company_short === Jurisdiction.SVG) { if (all_svg_acc.length) { all_svg_acc.forEach(svg_acc => { if (svg_acc.server !== acc.server) all_svg_acc.push(acc); @@ -433,15 +433,17 @@ const CFDAccountCardComponent = ({ existing_accounts_data?.length && existing_accounts_data?.map((acc, index) => (
- {acc?.display_balance && is_logged_in && acc.landing_company_short === 'labuan' && ( -
- -
- )} + {acc?.display_balance && + is_logged_in && + acc.landing_company_short === Jurisdiction.LABUAN && ( +
+ +
+ )} {(acc as TTradingPlatformAccounts)?.display_login && (
@@ -573,7 +575,7 @@ const CFDAccountCardComponent = ({ /> {checkMultipleSvgAcc()?.length > 1 && - acc.landing_company_short === 'svg' && ( + acc.landing_company_short === Jurisdiction.SVG && ( { if (is_eu && !has_maltainvest_account && standpoint.iom) { - openAccountNeededModal('maltainvest', localize('Deriv Multipliers'), localize('demo CFDs')); + openAccountNeededModal(Jurisdiction.MALTA_INVEST, localize('Deriv Multipliers'), localize('demo CFDs')); } else { onSelectAccount({ category: 'demo', diff --git a/packages/cfd/src/Components/cfd-mt5-demo-account-display.tsx b/packages/cfd/src/Components/cfd-mt5-demo-account-display.tsx index c09558c30cb1..31c70b684018 100644 --- a/packages/cfd/src/Components/cfd-mt5-demo-account-display.tsx +++ b/packages/cfd/src/Components/cfd-mt5-demo-account-display.tsx @@ -4,6 +4,7 @@ import { CFDAccountCard } from './cfd-account-card'; import { general_messages } from '../Constants/cfd-shared-strings'; import specifications, { TSpecifications } from '../Constants/cfd-specifications'; import Loading from '../templates/_common/components/loading'; +import { Jurisdiction } from '@deriv/shared'; import { DetailsOfEachMT5Loginid, LandingCompany } from '@deriv/api-types'; import { TTradingPlatformAccounts, TCFDPlatform } from './props.types'; import { TObjectCFDAccount } from '../Containers/cfd-dashboard'; @@ -75,7 +76,7 @@ const CFDMT5DemoAccountDisplay = ({ const openCFDAccount = () => { if (is_eu && !has_maltainvest_account && standpoint.iom) { - openAccountNeededModal('maltainvest', localize('Deriv Multipliers'), localize('demo CFDs')); + openAccountNeededModal(Jurisdiction.MALTA_INVEST, localize('Deriv Multipliers'), localize('demo CFDs')); } else { onSelectAccount({ category: 'demo', diff --git a/packages/cfd/src/Containers/__tests__/cfd-dashboard.spec.tsx b/packages/cfd/src/Containers/__tests__/cfd-dashboard.spec.tsx index 72217e8cd065..ee376b4eba1f 100644 --- a/packages/cfd/src/Containers/__tests__/cfd-dashboard.spec.tsx +++ b/packages/cfd/src/Containers/__tests__/cfd-dashboard.spec.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { fireEvent, render, screen } from '@testing-library/react'; import CFDDashboard, { TCFDDashboardProps } from '../cfd-dashboard'; import { BrowserRouter } from 'react-router-dom'; -import { CFD_PLATFORMS, getCFDPlatformLabel, routes } from '@deriv/shared'; +import { CFD_PLATFORMS, getCFDPlatformLabel, routes, Jurisdiction } from '@deriv/shared'; import { DetailsOfEachMT5Loginid, LandingCompany } from '@deriv/api-types'; type TMockConnectProps = { @@ -183,8 +183,8 @@ describe('', () => { setIsAcuityModalOpen: jest.fn(), setCurrentAccount: jest.fn(), standpoint: { - financial_company: 'svg', - gaming_company: 'svg', + financial_company: Jurisdiction.SVG, + gaming_company: Jurisdiction.SVG, iom: false, malta: false, maltainvest: false, @@ -193,7 +193,7 @@ describe('', () => { toggleAccountsDialog: jest.fn(), toggleShouldShowRealAccountsList: jest.fn(), toggleResetTradingPasswordModal: jest.fn(), - upgradeable_landing_companies: ['svg'], + upgradeable_landing_companies: [Jurisdiction.SVG], }; beforeEach(() => { mock_connect_props.landing_companies = { @@ -223,7 +223,7 @@ describe('', () => { display_login: '40005073', email: 'ma+1@deriv.com', group: 'real\\p01_ts03\\synthetic\\svg_std_usd\\02', - landing_company_short: 'svg', + landing_company_short: Jurisdiction.SVG, leverage: 500, login: 'MTR40005073', market_type: 'synthetic', @@ -250,7 +250,7 @@ describe('', () => { display_login: '20104105', email: 'ma+1@deriv.com', group: 'demo\\p01_ts02\\synthetic\\svg_std_usd', - landing_company_short: 'svg', + landing_company_short: Jurisdiction.SVG, leverage: 500, login: 'MTD20104105', market_type: 'synthetic', @@ -276,7 +276,7 @@ describe('', () => { display_balance: '0.00', display_login: 'DXR1000', enabled: 1, - landing_company_short: 'svg', + landing_company_short: Jurisdiction.SVG, login: '9', market_type: 'synthetic', platform: 'dxtrade', @@ -379,7 +379,7 @@ describe('', () => { legal_default_currency: 'EUR', name: 'Deriv Investments (Europe) Limited', requirements: {}, - shortcode: 'maltainvest', + shortcode: Jurisdiction.MALTA_INVEST, support_professional_client: 1, }, }, diff --git a/packages/cfd/src/Containers/__tests__/cfd-password-modal.spec.js b/packages/cfd/src/Containers/__tests__/cfd-password-modal.spec.js index 9acfe73fc22a..582ab53cfcc9 100644 --- a/packages/cfd/src/Containers/__tests__/cfd-password-modal.spec.js +++ b/packages/cfd/src/Containers/__tests__/cfd-password-modal.spec.js @@ -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'; @@ -62,7 +62,7 @@ describe('', () => { 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: {}, @@ -220,7 +220,7 @@ describe('', () => { account_type: { category: 'real', type: 'financial' }, is_eu: true, is_fully_authenticated: false, - jurisdiction_selected_shortcode: 'bvi', + jurisdiction_selected_shortcode: Jurisdiction.BVI, }; render( diff --git a/packages/cfd/src/Containers/derivx-trade-modal.tsx b/packages/cfd/src/Containers/derivx-trade-modal.tsx index 328b02b7bf20..58d0f974fc21 100644 --- a/packages/cfd/src/Containers/derivx-trade-modal.tsx +++ b/packages/cfd/src/Containers/derivx-trade-modal.tsx @@ -9,6 +9,7 @@ import { getCFDAccountKey, getPlatformSettings, isMobile, + Jurisdiction, } from '@deriv/shared'; import { localize, Localize } from '@deriv/translations'; import { CFDAccountCopy } from '../Components/cfd-account-copy'; @@ -138,7 +139,7 @@ const DerivXTradeModal = ({ if ( (mt5_trade_account.account_type === 'demo' && mt5_trade_account.market_type === 'financial' && - mt5_trade_account.landing_company_short === 'labuan') || + mt5_trade_account.landing_company_short === Jurisdiction.LABUAN) || mt5_trade_account.account_type === 'real' ) { return mt5_trade_account.landing_company_short; diff --git a/packages/cfd/src/Containers/dmt5-trade-modal.tsx b/packages/cfd/src/Containers/dmt5-trade-modal.tsx index 577fc681776e..fdd02e9f369b 100644 --- a/packages/cfd/src/Containers/dmt5-trade-modal.tsx +++ b/packages/cfd/src/Containers/dmt5-trade-modal.tsx @@ -10,6 +10,7 @@ import { getPlatformSettings, getUrlBase, getCFDAccountKey, + Jurisdiction, } from '@deriv/shared'; import { Localize, localize } from '@deriv/translations'; import { CFDAccountCopy } from '../Components/cfd-account-copy'; @@ -99,7 +100,7 @@ const DMT5TradeModal = ({ if ( (mt5_trade_account.account_type === 'demo' && mt5_trade_account.market_type === 'financial' && - mt5_trade_account.landing_company_short === 'labuan') || + mt5_trade_account.landing_company_short === Jurisdiction.LABUAN) || mt5_trade_account.account_type === 'real' ) { return mt5_trade_account.landing_company_short; diff --git a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-content.tsx b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-content.tsx index 5b821e002d3c..93a11f716c3e 100644 --- a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-content.tsx +++ b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-content.tsx @@ -22,7 +22,7 @@ const JurisdictionModalContent = ({ : financial_available_accounts?.some(account => account.shortcode === type_of_card); const disableCard = (type_of_card: string) => { - if (is_virtual && type_of_card !== 'svg') { + if (is_virtual && type_of_card !== Jurisdiction.SVG) { return true; } return account_type === 'synthetic' diff --git a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-foot-note.tsx b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-foot-note.tsx index 4bcbcd2d61a4..96b704d67c39 100644 --- a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-foot-note.tsx +++ b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-foot-note.tsx @@ -36,7 +36,7 @@ const FooterNote = ({ ) : ( ); - } else if (jurisdiction_selected_shortcode === 'bvi') { + } else if (jurisdiction_selected_shortcode === Jurisdiction.BVI) { return ( available_account.market_type === 'financial' && (show_eu_related_content - ? available_account.shortcode === 'maltainvest' - : available_account.shortcode !== 'maltainvest') + ? available_account.shortcode === Jurisdiction.MALTA_INVEST + : available_account.shortcode !== Jurisdiction.MALTA_INVEST) ); const synthetic_available_accounts = trading_platform_available_accounts.filter( available_account => available_account.market_type === 'gaming' && (show_eu_related_content - ? available_account.shortcode === 'maltainvest' - : available_account.shortcode !== 'maltainvest') + ? available_account.shortcode === Jurisdiction.MALTA_INVEST + : available_account.shortcode !== Jurisdiction.MALTA_INVEST) ); const modal_title = show_eu_related_content diff --git a/packages/cfd/src/Containers/mt5-compare-table-content.tsx b/packages/cfd/src/Containers/mt5-compare-table-content.tsx index 4521e7889b41..397ae3c77ea8 100644 --- a/packages/cfd/src/Containers/mt5-compare-table-content.tsx +++ b/packages/cfd/src/Containers/mt5-compare-table-content.tsx @@ -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 { @@ -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 && @@ -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 && @@ -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 { @@ -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 { @@ -434,9 +434,9 @@ const DMT5CompareModalContent = ({ return false; } else if (item.action === 'derivx') { return false; - } else if (type === 'bvi' && should_restrict_bvi_account_creation && poa_pending) { + } else if (type === Jurisdiction.BVI && should_restrict_bvi_account_creation && poa_pending) { return true; - } else if (type === 'vanuatu' && should_restrict_vanuatu_account_creation && poa_pending) { + } else if (type === Jurisdiction.VANUATU && should_restrict_vanuatu_account_creation && poa_pending) { return true; } diff --git a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js index 29b87f03098a..121023b0baf6 100644 --- a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js +++ b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js @@ -135,8 +135,8 @@ export default class CFDStore extends BaseStore { this.root_store.client.mt5_login_list .filter(acc => show_eu_related_content - ? acc.landing_company_short === 'maltainvest' - : acc.landing_company_short !== 'maltainvest' + ? acc.landing_company_short === Jurisdiction.MALTA_INVEST + : acc.landing_company_short !== Jurisdiction.MALTA_INVEST ) .forEach(account => { // e.g. mt5.real.financial_stp @@ -233,8 +233,8 @@ export default class CFDStore extends BaseStore { this.toggleJurisdictionModal(); } else { if (this.root_store.traders_hub.show_eu_related_content) { - this.setJurisdictionSelectedShortcode('maltainvest'); - } else this.setJurisdictionSelectedShortcode('svg'); + this.setJurisdictionSelectedShortcode(Jurisdiction.MALTA_INVEST); + } else this.setJurisdictionSelectedShortcode(Jurisdiction.SVG); this.demoCFDSignup(); } } @@ -649,9 +649,9 @@ export default class CFDStore extends BaseStore { return ( financial_available_accounts.length === 1 && - financial_available_accounts.every(acc => acc.shortcode === 'svg') && + financial_available_accounts.every(acc => acc.shortcode === Jurisdiction.SVG) && synthetic_available_accounts.length === 1 && - synthetic_available_accounts.every(acc => acc.shortcode === 'svg') + synthetic_available_accounts.every(acc => acc.shortcode === Jurisdiction.SVG) ); } } diff --git a/packages/core/src/App/Components/Elements/Modals/deriv-real-account-required-modal.jsx b/packages/core/src/App/Components/Elements/Modals/deriv-real-account-required-modal.jsx index 9f556ea86c34..c8553e8e4886 100644 --- a/packages/core/src/App/Components/Elements/Modals/deriv-real-account-required-modal.jsx +++ b/packages/core/src/App/Components/Elements/Modals/deriv-real-account-required-modal.jsx @@ -1,6 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import { Dialog } from '@deriv/components'; +import { Jurisdiction } from '@deriv/shared'; import { localize } from '@deriv/translations'; import { connect } from 'Stores/connect'; import './deriv-real-account-required-modal.scss'; @@ -17,7 +18,7 @@ const DerivRealAccountRequiredModal = ({ const createAccount = () => { if (is_eu_user) { onClose(); - openRealAccountSignup('maltainvest'); + openRealAccountSignup(Jurisdiction.MALTA_INVEST); } else { onClose(); openRealAccountSignup(); diff --git a/packages/core/src/App/Components/Layout/Footer/regulatory-information.jsx b/packages/core/src/App/Components/Layout/Footer/regulatory-information.jsx index ee1e3459ecbd..86fd4b64b28b 100644 --- a/packages/core/src/App/Components/Layout/Footer/regulatory-information.jsx +++ b/packages/core/src/App/Components/Layout/Footer/regulatory-information.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { Icon, Modal, Popover, StaticUrl } from '@deriv/components'; import { localize, Localize } from '@deriv/translations'; -import { deriv_urls, getLegalEntityName } from '@deriv/shared'; +import { deriv_urls, getLegalEntityName, Jurisdiction } from '@deriv/shared'; import MGALogo from 'Assets/SvgComponents/footer/mga.svg'; const MLTRegulatoryInformation = () => ( @@ -84,7 +84,7 @@ const MFRegulatoryInformation = () => ( />, ]} values={{ - legal_entity_name: getLegalEntityName('maltainvest'), + legal_entity_name: getLegalEntityName(Jurisdiction.MALTA_INVEST), }} />

@@ -96,7 +96,7 @@ export const RegulatoryInformation = ({ landing_company, is_eu, show_eu_related_ if (!is_eu || (is_eu && !show_eu_related_content)) return null; const is_mx = landing_company === 'iom'; const is_mlt = landing_company === 'malta'; - const is_mf = landing_company === 'maltainvest'; + const is_mf = landing_company === Jurisdiction.MALTA_INVEST; return (
diff --git a/packages/core/src/App/Components/Layout/Header/toggle-menu-drawer.jsx b/packages/core/src/App/Components/Layout/Header/toggle-menu-drawer.jsx index f74d781c7731..95ea906f7d7a 100644 --- a/packages/core/src/App/Components/Layout/Header/toggle-menu-drawer.jsx +++ b/packages/core/src/App/Components/Layout/Header/toggle-menu-drawer.jsx @@ -2,7 +2,7 @@ import classNames from 'classnames'; import React from 'react'; import { Div100vhContainer, Icon, MobileDrawer, ToggleSwitch, Text, Button } from '@deriv/components'; import { useOnrampVisible, useAccountTransferVisible } from '@deriv/hooks'; -import { routes, PlatformContext, getStaticUrl, whatsapp_url, ContentFlag } from '@deriv/shared'; +import { routes, PlatformContext, getStaticUrl, whatsapp_url, ContentFlag, Jurisdiction } from '@deriv/shared'; import { observer, useStore } from '@deriv/stores'; import { localize, getAllowedLanguages, getLanguage } from '@deriv/translations'; import NetworkStatus from 'App/Components/Layout/Footer'; @@ -260,9 +260,9 @@ const ToggleMenuDrawer = observer(({ platform_config }) => { const disableRoute = route_path => { if (/financial-assessment/.test(route_path)) { - return is_virtual || (active_account_landing_company === 'maltainvest' && !is_risky_client); + return is_virtual || (active_account_landing_company === Jurisdiction.MALTA_INVEST && !is_risky_client); } else if (/trading-assessment/.test(route_path)) { - return is_virtual || active_account_landing_company !== 'maltainvest'; + return is_virtual || active_account_landing_company !== Jurisdiction.MALTA_INVEST; } else if (/proof-of-address/.test(route_path) || /proof-of-identity/.test(route_path)) { return !should_allow_authentication; } else if (/proof-of-ownership/.test(route_path)) { diff --git a/packages/core/src/App/Containers/AccountSwitcher/account-switcher-account-list.jsx b/packages/core/src/App/Containers/AccountSwitcher/account-switcher-account-list.jsx index ffc6abc60afb..6376b5e7ac27 100644 --- a/packages/core/src/App/Containers/AccountSwitcher/account-switcher-account-list.jsx +++ b/packages/core/src/App/Containers/AccountSwitcher/account-switcher-account-list.jsx @@ -1,7 +1,14 @@ import classNames from 'classnames'; import React from 'react'; import { Icon, Money, Button, Text } from '@deriv/components'; -import { formatMoney, getCurrencyName, getCFDAccountDisplay, getCurrencyDisplayCode, isBot } from '@deriv/shared'; +import { + formatMoney, + getCurrencyName, + getCFDAccountDisplay, + getCurrencyDisplayCode, + isBot, + Jurisdiction, +} from '@deriv/shared'; import { Localize, localize } from '@deriv/translations'; const AccountList = ({ @@ -178,7 +185,7 @@ const AccountDisplay = ({ {server?.server_info?.geolocation && should_show_server_name && market_type === 'synthetic' && - shortcode === 'svg' && ( + shortcode === Jurisdiction.SVG && ( {getServerName(server)} @@ -194,7 +201,7 @@ const AccountDisplay = ({ {server?.server_info?.geolocation && should_show_server_name && market_type === 'synthetic' && - shortcode === 'svg' && ( + shortcode === Jurisdiction.SVG && ( { account => !account.is_virtual && account.loginid.startsWith('CR') ); setFilteredRealAccounts(real_accounts); - const remaining_real_accounts = getRemainingRealAccounts().filter(account => account === 'svg'); + const remaining_real_accounts = getRemainingRealAccounts().filter(account => account === Jurisdiction.SVG); setFilteredRemainingRealAccounts(remaining_real_accounts); } else if (props.is_eu) { const real_accounts = getSortedAccountList(props.account_list, props.accounts).filter( account => !account.is_virtual && account.loginid.startsWith('MF') ); setFilteredRealAccounts(real_accounts); - const remaining_real_accounts = getRemainingRealAccounts().filter(account => account === 'maltainvest'); + const remaining_real_accounts = getRemainingRealAccounts().filter( + account => account === Jurisdiction.MALTA_INVEST + ); setFilteredRemainingRealAccounts(remaining_real_accounts); } }, []); @@ -222,7 +225,11 @@ const AccountSwitcher = props => { const openMt5DemoAccount = account_type => { if (props.show_eu_related_content && !props.has_maltainvest_account && props.standpoint.iom) { closeAccountsDialog(); - props.openAccountNeededModal('maltainvest', localize('Deriv Multipliers'), localize('demo CFDs')); + props.openAccountNeededModal( + Jurisdiction.MALTA_INVEST, + localize('Deriv Multipliers'), + localize('demo CFDs') + ); return; } sessionStorage.setItem('open_cfd_account_type', `demo.${CFD_PLATFORMS.MT5}.${account_type}`); @@ -373,7 +380,7 @@ const AccountSwitcher = props => { const low_risk_non_eu = props.content_flag === ContentFlag.LOW_RISK_CR_NON_EU; if (low_risk_non_eu) { return getSortedCFDList(props.mt5_login_list).filter( - account => !isDemo(account) && account.landing_company_short !== 'maltainvest' + account => !isDemo(account) && account.landing_company_short !== Jurisdiction.MALTA_INVEST ); } return getSortedCFDList(props.mt5_login_list).filter(account => !isDemo(account)); @@ -559,7 +566,7 @@ const AccountSwitcher = props => { const checkMultipleSvgAcc = () => { const all_svg_acc = []; getRealMT5().map(acc => { - if (acc.landing_company_short === 'svg' && acc.market_type === 'synthetic') { + if (acc.landing_company_short === Jurisdiction.SVG && acc.market_type === 'synthetic') { if (all_svg_acc.length) { all_svg_acc.forEach(svg_acc => { if (svg_acc.server !== acc.server) all_svg_acc.push(acc); @@ -678,7 +685,7 @@ const AccountSwitcher = props => { platform={CFD_PLATFORMS.MT5} shortcode={ account.market_type === 'financial' && - account.landing_company_short === 'labuan' && + account.landing_company_short === Jurisdiction.LABUAN && account.landing_company_short } /> @@ -1118,7 +1125,7 @@ const AccountSwitcher = props => {
{!has_cr_account && getRemainingRealAccounts() - .filter(account => account === 'svg') + .filter(account => account === Jurisdiction.SVG) .map((account, index) => (
@@ -1190,7 +1197,7 @@ const AccountSwitcher = props => { })}
{getRemainingRealAccounts() - .filter(account => account === 'maltainvest') + .filter(account => account === Jurisdiction.MALTA_INVEST) .map((account, index) => { return (
diff --git a/packages/core/src/App/Containers/Modals/app-modals.jsx b/packages/core/src/App/Containers/Modals/app-modals.jsx index 29d8f7c47553..973461ce9e42 100644 --- a/packages/core/src/App/Containers/Modals/app-modals.jsx +++ b/packages/core/src/App/Containers/Modals/app-modals.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { useLocation } from 'react-router-dom'; -import { ContentFlag, moduleLoader } from '@deriv/shared'; +import { ContentFlag, moduleLoader, Jurisdiction } from '@deriv/shared'; import { connect } from 'Stores/connect'; import MT5AccountNeededModal from 'App/Components/Elements/Modals/mt5-account-needed-modal.jsx'; import RedirectNoticeModal from 'App/Components/Elements/Modals/RedirectNotice'; @@ -125,7 +125,7 @@ const AppModals = ({ if ( is_logged_in && - active_account_landing_company === 'maltainvest' && + active_account_landing_company === Jurisdiction.MALTA_INVEST && !is_trading_assessment_for_new_user_enabled && is_trading_experience_incomplete && content_flag !== ContentFlag.LOW_RISK_CR_EU && diff --git a/packages/core/src/App/Containers/Modals/exit-traders-hub-modal/exit-traders-hub-modal.jsx b/packages/core/src/App/Containers/Modals/exit-traders-hub-modal/exit-traders-hub-modal.jsx index f5e42ce4125b..ddecdb089a2d 100644 --- a/packages/core/src/App/Containers/Modals/exit-traders-hub-modal/exit-traders-hub-modal.jsx +++ b/packages/core/src/App/Containers/Modals/exit-traders-hub-modal/exit-traders-hub-modal.jsx @@ -4,6 +4,7 @@ import { connect } from 'Stores/connect'; import { Button, DesktopWrapper, MobileDialog, MobileWrapper, Modal, Text, UILoader } from '@deriv/components'; import { isMobile, routes, ContentFlag } from '@deriv/shared'; import { localize } from '@deriv/translations'; +import { Jurisdiction } from '@deriv/shared/src/utils/constants/jurisdiction'; const ExitTradersHubModal = ({ disableApp, @@ -46,7 +47,7 @@ const ExitTradersHubModal = ({ const onClickExitButton = async () => { setIsPreAppStore(false); setIsLoggingIn(true); - const cr_account = active_accounts.some(acc => acc.landing_company_shortcode === 'svg'); + const cr_account = active_accounts.some(acc => acc.landing_company_shortcode === Jurisdiction.SVG); toggleExitTradersHubModal(); if (content_flag === ContentFlag.LOW_RISK_CR_EU || content_flag === ContentFlag.LOW_RISK_CR_NON_EU) { diff --git a/packages/core/src/App/Containers/Modals/ready-to-deposit-modal/ready-to-deposit-modal.tsx b/packages/core/src/App/Containers/Modals/ready-to-deposit-modal/ready-to-deposit-modal.tsx index 51defc4af8fe..b7c65e4df42d 100644 --- a/packages/core/src/App/Containers/Modals/ready-to-deposit-modal/ready-to-deposit-modal.tsx +++ b/packages/core/src/App/Containers/Modals/ready-to-deposit-modal/ready-to-deposit-modal.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { Dialog } from '@deriv/components'; import { localize } from '@deriv/translations'; import { useStore, observer } from '@deriv/stores'; +import { Jurisdiction } from '@deriv/shared'; import './ready-to-deposit-modal.scss'; const ReadyToDepositModal = observer(() => { @@ -17,7 +18,7 @@ const ReadyToDepositModal = observer(() => { const createAccount = () => { onClose(); - return is_eu_user ? openRealAccountSignup('maltainvest') : openRealAccountSignup(); + return is_eu_user ? openRealAccountSignup(Jurisdiction.MALTA_INVEST) : openRealAccountSignup(); }; return ( diff --git a/packages/core/src/App/Containers/RealAccountSignup/account-wizard-form.js b/packages/core/src/App/Containers/RealAccountSignup/account-wizard-form.js index dc473cb2881f..a934e3a701ee 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/account-wizard-form.js +++ b/packages/core/src/App/Containers/RealAccountSignup/account-wizard-form.js @@ -10,18 +10,18 @@ import { proofOfIdentityConfig, ProofOfIdentityFormOnSignup, } from '@deriv/account'; - +import { Jurisdiction } from '@deriv/shared'; import AddressDetails from './address-details.jsx'; import CurrencySelector from './currency-selector.jsx'; -const isMaltaAccount = ({ real_account_signup_target }) => real_account_signup_target === 'maltainvest'; +const isMaltaAccount = ({ real_account_signup_target }) => real_account_signup_target === Jurisdiction.MALTA_INVEST; const shouldShowPersonalAndAddressDetailsAndCurrency = ({ real_account_signup_target }) => real_account_signup_target !== 'samoa'; const shouldShowIdentityInformation = ({ account_settings, residence, residence_list, real_account_signup_target }) => { const citizen = account_settings.citizen || residence; const country = residence_list.find(item => item.value === citizen); - const maltainvest = real_account_signup_target === 'maltainvest'; + const maltainvest = real_account_signup_target === Jurisdiction.MALTA_INVEST; return !maltainvest && citizen && country?.identity?.services?.idv?.is_country_supported; }; diff --git a/packages/core/src/App/Containers/RealAccountSignup/account-wizard.jsx b/packages/core/src/App/Containers/RealAccountSignup/account-wizard.jsx index 6136bffcd12f..04d1d53200cc 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/account-wizard.jsx +++ b/packages/core/src/App/Containers/RealAccountSignup/account-wizard.jsx @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import fromEntries from 'object.fromentries'; import React from 'react'; import { DesktopWrapper, MobileWrapper, FormProgress, Wizard, Text } from '@deriv/components'; -import { toMoment, getLocation, makeCancellablePromise, WS } from '@deriv/shared'; +import { toMoment, getLocation, makeCancellablePromise, WS, Jurisdiction } from '@deriv/shared'; import { Localize } from '@deriv/translations'; import { connect } from 'Stores/connect'; import LoadingModal from './real-account-signup-loader.jsx'; @@ -255,7 +255,7 @@ const AccountWizard = props => { submitForm(payload) .then(response => { props.setIsRiskWarningVisible(false); - if (props.real_account_signup_target === 'maltainvest') { + if (props.real_account_signup_target === Jurisdiction.MALTA_INVEST) { props.onFinishSuccess(response.new_account_maltainvest.currency.toLowerCase()); } else if (props.real_account_signup_target === 'samoa') { props.onOpenWelcomeModal(response.new_account_samoa.currency.toLowerCase()); diff --git a/packages/core/src/App/Containers/RealAccountSignup/helpers/constants.js b/packages/core/src/App/Containers/RealAccountSignup/helpers/constants.js index 2698426b6650..07d46bcdaaee 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/helpers/constants.js +++ b/packages/core/src/App/Containers/RealAccountSignup/helpers/constants.js @@ -1,4 +1,5 @@ import { localize } from '@deriv/translations'; +import { Jurisdiction } from '@deriv/shared'; /** * Experian result is defined by client's information validity. @@ -34,7 +35,7 @@ export const getAccountTitle = (landing_company_shortcode, { account_residence = } switch (landing_company_shortcode) { - case 'svg': + case Jurisdiction.SVG: return localize('Options & Multipliers'); case 'iom': if (country_standpoint.is_united_kingdom) { @@ -50,7 +51,7 @@ export const getAccountTitle = (landing_company_shortcode, { account_residence = return localize('Options'); } return localize('Derived'); - case 'maltainvest': + case Jurisdiction.MALTA_INVEST: return localize('Multipliers'); default: return localize('Deriv'); @@ -81,7 +82,7 @@ export const getExperianResult = status => { return EXPERIAN.DANGER; }; - if (landing_company_shortcode === 'svg' || is_isle_of_man_residence || is_belgium_residence) + if (landing_company_shortcode === Jurisdiction.SVG || is_isle_of_man_residence || is_belgium_residence) return EXPERIAN.SUCCESS; if (landing_company_shortcode === 'iom') return getIOMStatus({ is_fully_authenticated, is_age_verified }); diff --git a/packages/core/src/App/Containers/RealAccountSignup/helpers/dialog-buttons.jsx b/packages/core/src/App/Containers/RealAccountSignup/helpers/dialog-buttons.jsx index 2e2d0a01de9d..6d6a8caa7d83 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/helpers/dialog-buttons.jsx +++ b/packages/core/src/App/Containers/RealAccountSignup/helpers/dialog-buttons.jsx @@ -2,6 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import { Button } from '@deriv/components'; import { localize } from '@deriv/translations'; +import { Jurisdiction } from '@deriv/shared'; import { EXPERIAN } from './constants'; const getDismissButton = ({ status, landing_company_shortcode, closeModal, switchToVirtual }) => { @@ -66,7 +67,7 @@ const getActionButton = ({ label: localize('Deposit'), action: closeModalAndOpenCashier, }; - case 'maltainvest': + case Jurisdiction.MALTA_INVEST: if (is_fully_authenticated) { return { label: localize('Deposit'), @@ -77,7 +78,7 @@ const getActionButton = ({ label: localize('Submit proof'), action: closeModalAndOpenPOI, }; - case 'svg': + case Jurisdiction.SVG: case 'malta': default: return { diff --git a/packages/core/src/App/Containers/RealAccountSignup/helpers/dialog-message.jsx b/packages/core/src/App/Containers/RealAccountSignup/helpers/dialog-message.jsx index db56d3fbad5b..dec92b7fa87f 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/helpers/dialog-message.jsx +++ b/packages/core/src/App/Containers/RealAccountSignup/helpers/dialog-message.jsx @@ -2,6 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import { Text } from '@deriv/components'; import { Localize } from '@deriv/translations'; +import { Jurisdiction } from '@deriv/shared'; import { EXPERIAN } from './constants'; /** @@ -16,7 +17,7 @@ export const DialogMessage = ({ status = EXPERIAN.SUCCESS, }) => { let message = ''; - if (landing_company_shortcode === 'maltainvest') { + if (landing_company_shortcode === Jurisdiction.MALTA_INVEST) { if (is_fully_authenticated) { message = [ , diff --git a/packages/core/src/App/Containers/RealAccountSignup/proof-of-address-form.js b/packages/core/src/App/Containers/RealAccountSignup/proof-of-address-form.js index 68ec96526756..b28366db3dbf 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/proof-of-address-form.js +++ b/packages/core/src/App/Containers/RealAccountSignup/proof-of-address-form.js @@ -1,10 +1,10 @@ import { localize } from '@deriv/translations'; import { ProofOfAddressContainer } from '@deriv/account'; -import { generateValidationFunction, getDefaultFields } from '@deriv/shared'; +import { generateValidationFunction, getDefaultFields, Jurisdiction } from '@deriv/shared'; const proof_of_address_config = { poi_state: { - supported_in: ['maltainvest', 'malta', 'svg', 'iom'], + supported_in: [Jurisdiction.MALTA_INVEST, 'malta', Jurisdiction.SVG, 'iom'], default_value: '', rules: [], }, diff --git a/packages/core/src/App/Containers/RealAccountSignup/proof-of-identity-form.js b/packages/core/src/App/Containers/RealAccountSignup/proof-of-identity-form.js index 51d7ca43fe00..66d09da7900c 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/proof-of-identity-form.js +++ b/packages/core/src/App/Containers/RealAccountSignup/proof-of-identity-form.js @@ -1,10 +1,10 @@ import { localize } from '@deriv/translations'; -import { generateValidationFunction, getDefaultFields } from '@deriv/shared'; +import { generateValidationFunction, getDefaultFields, Jurisdiction } from '@deriv/shared'; import ProofOfIdentityForm from './proof-of-identity.jsx'; const proof_of_identity_config = { poi_state: { - supported_in: ['maltainvest', 'malta', 'svg', 'iom'], + supported_in: [Jurisdiction.MALTA_INVEST, 'malta', Jurisdiction.SVG, 'iom'], default_value: '', rules: [], }, diff --git a/packages/core/src/App/Containers/RealAccountSignup/real-account-signup.jsx b/packages/core/src/App/Containers/RealAccountSignup/real-account-signup.jsx index acf73bfab732..eac393e33d66 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/real-account-signup.jsx +++ b/packages/core/src/App/Containers/RealAccountSignup/real-account-signup.jsx @@ -3,7 +3,7 @@ import classNames from 'classnames'; import React from 'react'; import { withRouter } from 'react-router-dom'; import { Button, Text, Modal, DesktopWrapper, MobileDialog, MobileWrapper } from '@deriv/components'; -import { routes } from '@deriv/shared'; +import { routes, Jurisdiction } from '@deriv/shared'; import { RiskToleranceWarningModal, TestWarningModal } from '@deriv/account'; import { localize, Localize } from '@deriv/translations'; import { connect } from 'Stores/connect'; @@ -38,7 +38,7 @@ const WizardHeading = ({ is_pre_appstore, real_account_signup_target, }) => { - const maltainvest_signup = real_account_signup_target === 'maltainvest'; + const maltainvest_signup = real_account_signup_target === Jurisdiction.MALTA_INVEST; const iom_signup = real_account_signup_target === 'iom'; const deposit_cash_signup = real_account_signup_target === 'deposit_cash'; @@ -74,7 +74,7 @@ const WizardHeading = ({ return ; } return ; - case 'maltainvest': + case Jurisdiction.MALTA_INVEST: if ( country_standpoint.is_united_kingdom || country_standpoint.is_france || @@ -425,7 +425,7 @@ const RealAccountSignup = ({ active_modal_index_no = modal_pages_indices.add_or_manage_account; } else { active_modal_index_no = - !currency && real_account_signup_target !== 'maltainvest' + !currency && real_account_signup_target !== Jurisdiction.MALTA_INVEST ? modal_pages_indices.set_currency : modal_pages_indices.account_wizard; } @@ -449,7 +449,7 @@ const RealAccountSignup = ({ try { setShouldShowAppropriatenessWarningModal(false); const response = await realAccountSignup({ ...real_account_form_data, accept_risk: 1 }); - if (real_account_signup_target === 'maltainvest') { + if (real_account_signup_target === Jurisdiction.MALTA_INVEST) { showStatusDialog(response.new_account_maltainvest.currency.toLowerCase()); } } catch (sign_up_error) { diff --git a/packages/core/src/App/Containers/WelcomeModal/welcome-modal.jsx b/packages/core/src/App/Containers/WelcomeModal/welcome-modal.jsx index e82c713789ee..eb45a657a697 100644 --- a/packages/core/src/App/Containers/WelcomeModal/welcome-modal.jsx +++ b/packages/core/src/App/Containers/WelcomeModal/welcome-modal.jsx @@ -1,5 +1,6 @@ import React from 'react'; import { connect } from 'Stores/connect'; +import { Jurisdiction } from '@deriv/shared'; import WelcomeModal1 from './welcome-modal-1.jsx'; import WelcomeModal2 from './welcome-modal-2.jsx'; @@ -7,7 +8,7 @@ const WelcomeModal = ({ is_eu, landing_companies, residence }) => { const is_excluded_from_cr_onboarding = ['au', 'sg', 'no'].includes(residence); const shortcode = landing_companies?.financial_company?.shortcode || landing_companies?.gaming_company?.shortcode; - if ((shortcode === 'svg' && !is_excluded_from_cr_onboarding) || is_eu) { + if ((shortcode === Jurisdiction.SVG && !is_excluded_from_cr_onboarding) || is_eu) { return ; } diff --git a/packages/core/src/App/Containers/app-notification-messages.jsx b/packages/core/src/App/Containers/app-notification-messages.jsx index f6561918d753..1a0703934ef0 100644 --- a/packages/core/src/App/Containers/app-notification-messages.jsx +++ b/packages/core/src/App/Containers/app-notification-messages.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import ReactDOM from 'react-dom'; import { TransitionGroup, CSSTransition } from 'react-transition-group'; -import { isMobile, getPathname, getPlatformSettings, routes } from '@deriv/shared'; +import { isMobile, getPathname, getPlatformSettings, routes, Jurisdiction } from '@deriv/shared'; import { connect } from 'Stores/connect'; import { excluded_notifications } from '../../Stores/Helpers/client-notifications'; import Notification, { @@ -149,7 +149,7 @@ const AppNotificationMessages = ({ const notifications_limit = isMobile() ? max_display_notifications_mobile : max_display_notifications; //TODO (yauheni-kryzhyk): showing pop-up only for specific messages. the rest of notifications are hidden. this logic should be changed in the upcoming new pop-up notifications implementation const filtered_excluded_notifications = notifications.filter(message => - message.key.includes('svg') || message.key.includes('p2p_daily_limit_increase') + message.key.includes(Jurisdiction.SVG) || message.key.includes('p2p_daily_limit_increase') ? message : excluded_notifications.includes(message.key) ); diff --git a/packages/core/src/Modules/ComplaintsPolicy/Components/complaints-policy-content.jsx b/packages/core/src/Modules/ComplaintsPolicy/Components/complaints-policy-content.jsx index d3e985a301c7..d95dd0dda02d 100644 --- a/packages/core/src/Modules/ComplaintsPolicy/Components/complaints-policy-content.jsx +++ b/packages/core/src/Modules/ComplaintsPolicy/Components/complaints-policy-content.jsx @@ -1,14 +1,14 @@ import React from 'react'; import { localize, Localize } from '@deriv/translations'; -import { getLegalEntityName } from '@deriv/shared'; +import { getLegalEntityName, Jurisdiction } from '@deriv/shared'; import { connect } from 'Stores/connect'; import 'Sass/app/modules/complaints-policy.scss'; const getIntroductionText = (landing_company_shortcode, mt5_login_list) => { // * mt5_login_list returns these: // landing_company_short: "svg" | "malta" | "maltainvest" | "vanuatu" | "labuan" | "bvi" - const has_vanuatu = mt5_login_list.some(item => item.landing_company_short === 'vanuatu'); - const has_labuan = mt5_login_list.some(item => item.landing_company_short === 'labuan'); + const has_vanuatu = mt5_login_list.some(item => item.landing_company_short === Jurisdiction.VANUATU); + const has_labuan = mt5_login_list.some(item => item.landing_company_short === Jurisdiction.LABUAN); switch (landing_company_shortcode) { case 'iom': @@ -21,11 +21,11 @@ const getIntroductionText = (landing_company_shortcode, mt5_login_list) => { }} /> ); - case 'maltainvest': + case Jurisdiction.MALTA_INVEST: return localize( 'This complaints policy, which may change from time to time, applies to your account registered with {{legal_entity_name}}.', { - legal_entity_name: getLegalEntityName('maltainvest'), + legal_entity_name: getLegalEntityName(Jurisdiction.MALTA_INVEST), } ); case 'malta': @@ -43,7 +43,7 @@ const getIntroductionText = (landing_company_shortcode, mt5_login_list) => { return localize( 'This complaints policy, which may change from time to time, applies to your account(s) registered with {{legal_entity_name_svg}}, {{legal_entity_name_fx}}, and {{legal_entity_name_v}}.', { - legal_entity_name_svg: getLegalEntityName('svg'), + legal_entity_name_svg: getLegalEntityName(Jurisdiction.SVG), legal_entity_name_fx: getLegalEntityName('fx'), legal_entity_name_v: getLegalEntityName('v'), } @@ -52,7 +52,7 @@ const getIntroductionText = (landing_company_shortcode, mt5_login_list) => { return localize( 'This complaints policy, which may change from time to time, applies to your account(s) registered with {{legal_entity_name_svg}} and {{legal_entity_name_v}}.', { - legal_entity_name_svg: getLegalEntityName('svg'), + legal_entity_name_svg: getLegalEntityName(Jurisdiction.SVG), legal_entity_name_v: getLegalEntityName('v'), } ); @@ -60,7 +60,7 @@ const getIntroductionText = (landing_company_shortcode, mt5_login_list) => { return localize( 'This complaints policy, which may change from time to time, applies to your account(s) registered with {{legal_entity_name_svg}} and {{legal_entity_name_fx}}.', { - legal_entity_name_svg: getLegalEntityName('svg'), + legal_entity_name_svg: getLegalEntityName(Jurisdiction.SVG), legal_entity_name_fx: getLegalEntityName('fx'), } ); @@ -68,7 +68,7 @@ const getIntroductionText = (landing_company_shortcode, mt5_login_list) => { return localize( 'This complaints policy, which may change from time to time, applies to your account(s) registered with {{legal_entity_name_svg}}.', { - legal_entity_name_svg: getLegalEntityName('svg'), + legal_entity_name_svg: getLegalEntityName(Jurisdiction.SVG), } ); } @@ -174,7 +174,7 @@ const getYourDecisionText = (is_uk, landing_company_shortcode) => { ]} /> ); - if (landing_company_shortcode === 'maltainvest') { + if (landing_company_shortcode === Jurisdiction.MALTA_INVEST) { texts.push( acc.landing_company_shortcode === 'maltainvest'); + return this.active_accounts.some(acc => acc.landing_company_shortcode === Jurisdiction.MALTA_INVEST); } get has_malta_account() { @@ -515,7 +516,7 @@ export default class ClientStore extends BaseStore { get first_switchable_real_loginid() { const result = this.active_accounts.find( - acc => acc.is_virtual === 0 && acc.landing_company_shortcode === 'svg' + acc => acc.is_virtual === 0 && acc.landing_company_shortcode === Jurisdiction.SVG ); return result.loginid || undefined; } @@ -553,7 +554,8 @@ export default class ClientStore extends BaseStore { ) { return this.current_landing_company.legal_allowed_currencies; } - const target = this.root_store.ui.real_account_signup_target === 'maltainvest' ? 'financial' : 'gaming'; + const target = + this.root_store.ui.real_account_signup_target === Jurisdiction.MALTA_INVEST ? 'financial' : 'gaming'; if (this.landing_companies[`${target}_company`]) { return this.landing_companies[`${target}_company`].legal_allowed_currencies; @@ -840,13 +842,13 @@ export default class ClientStore extends BaseStore { get should_restrict_bvi_account_creation() { return !!this.mt5_login_list.filter( - item => item?.landing_company_short === 'bvi' && item?.status === 'poa_failed' + item => item?.landing_company_short === Jurisdiction.BVI && item?.status === 'poa_failed' ).length; } get should_restrict_vanuatu_account_creation() { return !!this.mt5_login_list.filter( - item => item?.landing_company_short === 'vanuatu' && item?.status === 'poa_failed' + item => item?.landing_company_short === Jurisdiction.VANUATU && item?.status === 'poa_failed' ).length; } @@ -860,11 +862,11 @@ export default class ClientStore extends BaseStore { const financial_shortcode = financial_company?.shortcode; const gaming_shortcode = gaming_company?.shortcode; const mt_gaming_shortcode = mt_gaming_company?.financial.shortcode || mt_gaming_company?.swap_free.shortcode; - const is_current_mf = this.landing_company_shortcode === 'maltainvest'; + const is_current_mf = this.landing_company_shortcode === Jurisdiction.MALTA_INVEST; return ( is_current_mf || //is_currently logged in mf account via trdaershub (financial_shortcode || gaming_shortcode || mt_gaming_shortcode - ? (eu_shortcode_regex.test(financial_shortcode) && gaming_shortcode !== 'svg') || + ? (eu_shortcode_regex.test(financial_shortcode) && gaming_shortcode !== Jurisdiction.SVG) || eu_shortcode_regex.test(gaming_shortcode) : eu_excluded_regex.test(this.residence)) ); @@ -1015,8 +1017,8 @@ export default class ClientStore extends BaseStore { this.trading_platform_available_accounts.some( account => (market_type === 'synthetic' ? 'gaming' : 'financial') === account.market_type && - account.shortcode === 'svg' - ) && existing_demo_accounts.every(account => !(account.landing_company_short === 'svg')) + account.shortcode === Jurisdiction.SVG + ) && existing_demo_accounts.every(account => !(account.landing_company_short === Jurisdiction.SVG)) ); } @@ -1028,7 +1030,7 @@ export default class ClientStore extends BaseStore { .filter( account => (market_type === 'synthetic' ? 'gaming' : 'financial') === account.market_type && - account.shortcode !== 'maltainvest' + account.shortcode !== Jurisdiction.MALTA_INVEST ) .map(account => account.shortcode); @@ -1072,7 +1074,7 @@ export default class ClientStore extends BaseStore { isBotAllowed = () => { // Stop showing Bot, DBot, DSmartTrader for logged out EU IPs if (!this.is_logged_in && this.is_eu_country) return false; - const is_mf = this.landing_company_shortcode === 'maltainvest'; + const is_mf = this.landing_company_shortcode === Jurisdiction.MALTA_INVEST; return this.is_virtual ? this.is_eu_or_multipliers_only : !is_mf && !this.is_options_blocked; }; @@ -1131,9 +1133,9 @@ export default class ClientStore extends BaseStore { landing_company !== this.accounts[this.loginid].landing_company_shortcode && upgradeable_landing_companies.indexOf(landing_company) !== -1 ); - can_upgrade_to = canUpgrade('svg', 'iom', 'malta', 'maltainvest'); + can_upgrade_to = canUpgrade(Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST); if (can_upgrade_to) { - type = can_upgrade_to === 'maltainvest' ? 'financial' : 'real'; + type = can_upgrade_to === Jurisdiction.MALTA_INVEST ? 'financial' : 'real'; } } @@ -1349,7 +1351,7 @@ export default class ClientStore extends BaseStore { async realAccountSignup(form_values) { const DEFAULT_CRYPTO_ACCOUNT_CURRENCY = 'BTC'; - const is_maltainvest_account = this.root_store.ui.real_account_signup_target === 'maltainvest'; + const is_maltainvest_account = this.root_store.ui.real_account_signup_target === Jurisdiction.MALTA_INVEST; const is_samoa_account = this.root_store.ui.real_account_signup_target === 'samoa'; let currency = ''; form_values.residence = this.residence; @@ -1645,7 +1647,7 @@ export default class ClientStore extends BaseStore { if (!this.is_virtual) { this.setPrevRealAccountLoginid(this.loginid); } - const no_cr_account = this.active_accounts.some(acc => acc.landing_company_shortcode === 'svg'); + const no_cr_account = this.active_accounts.some(acc => acc.landing_company_shortcode === Jurisdiction.SVG); if (!no_cr_account && this.is_low_risk) { this.switchAccount(this.virtual_account_loginid); @@ -2553,21 +2555,24 @@ export default class ClientStore extends BaseStore { // This is a conditional check for countries like Australia/Norway which fulfil one of these following conditions. const restricted_countries = - financial_company?.shortcode === 'svg' || - (gaming_company?.shortcode === 'svg' && financial_company?.shortcode !== 'maltainvest'); + financial_company?.shortcode === Jurisdiction.SVG || + (gaming_company?.shortcode === Jurisdiction.SVG && + financial_company?.shortcode !== Jurisdiction.MALTA_INVEST); - const high_risk_landing_company = financial_company?.shortcode === 'svg' && gaming_company?.shortcode === 'svg'; + const high_risk_landing_company = + financial_company?.shortcode === Jurisdiction.SVG && gaming_company?.shortcode === Jurisdiction.SVG; return high_risk_landing_company || this.account_status.risk_classification === 'high' || restricted_countries; } get is_low_risk() { const { gaming_company, financial_company } = this.landing_companies; const low_risk_landing_company = - financial_company?.shortcode === 'maltainvest' && gaming_company?.shortcode === 'svg'; + financial_company?.shortcode === Jurisdiction.MALTA_INVEST && + gaming_company?.shortcode === Jurisdiction.SVG; return ( low_risk_landing_company || - (this.upgradeable_landing_companies?.includes('svg') && - this.upgradeable_landing_companies?.includes('maltainvest')) + (this.upgradeable_landing_companies?.includes(Jurisdiction.SVG) && + this.upgradeable_landing_companies?.includes(Jurisdiction.MALTA_INVEST)) ); } diff --git a/packages/core/src/Stores/notification-store.js b/packages/core/src/Stores/notification-store.js index 3627f50835c8..57181614e998 100644 --- a/packages/core/src/Stores/notification-store.js +++ b/packages/core/src/Stores/notification-store.js @@ -16,6 +16,7 @@ import { platform_name, routes, unique, + Jurisdiction, } from '@deriv/shared'; import { localize, Localize } from '@deriv/translations'; import { BinaryLink } from 'App/Components/Routes'; @@ -181,7 +182,7 @@ export default class NotificationStore extends BaseStore { this.notification_messages = [...this.notification_messages, notification].sort(sortFn); if ( - (notification.key && notification.key.includes('svg')) || + (notification.key && notification.key.includes(Jurisdiction.SVG)) || notification.key === 'p2p_daily_limit_increase' || (excluded_notifications && !excluded_notifications.includes(notification.key)) ) { @@ -301,9 +302,9 @@ export default class NotificationStore extends BaseStore { const { max_daily_buy, max_daily_sell } = upgradable_daily_limits || {}; const { is_10k_withdrawal_limit_reached } = this.root_store.modules.cashier.withdraw; const { current_language, selected_contract_type } = this.root_store.common; - const malta_account = landing_company_shortcode === 'maltainvest'; + const malta_account = landing_company_shortcode === Jurisdiction.MALTA_INVEST; const virtual_account = landing_company_shortcode === 'virtual'; - const cr_account = landing_company_shortcode === 'svg'; + const cr_account = landing_company_shortcode === Jurisdiction.SVG; const is_website_up = website_status.site_status === 'up'; const has_trustpilot = LocalStore.getObject('notification_messages')[loginid]?.includes( this.client_notifications.trustpilot.key @@ -1500,7 +1501,7 @@ export default class NotificationStore extends BaseStore { updateNotifications(notifications_array) { this.notifications = notifications_array.filter(message => - (message.key && message.key.includes('svg')) || message.key === 'p2p_daily_limit_increase' + (message.key && message.key.includes(Jurisdiction.SVG)) || message.key === 'p2p_daily_limit_increase' ? message : excluded_notifications && !excluded_notifications.includes(message.key) ); diff --git a/packages/core/src/Stores/traders-hub-store.js b/packages/core/src/Stores/traders-hub-store.js index f8c0891fbc3c..8d8f155db077 100644 --- a/packages/core/src/Stores/traders-hub-store.js +++ b/packages/core/src/Stores/traders-hub-store.js @@ -1,5 +1,12 @@ import { action, makeObservable, observable, reaction, computed, runInAction } from 'mobx'; -import { getCFDAvailableAccount, CFD_PLATFORMS, ContentFlag, formatMoney, getAppstorePlatforms } from '@deriv/shared'; +import { + getCFDAvailableAccount, + CFD_PLATFORMS, + ContentFlag, + formatMoney, + getAppstorePlatforms, + Jurisdiction, +} from '@deriv/shared'; import BaseStore from './base-store'; import { localize } from '@deriv/translations'; import { isEuCountry } from '_common/utility'; @@ -194,7 +201,7 @@ export default class TradersHubStore extends BaseStore { get no_CR_account() { const { active_accounts } = this.root_store.client; - const result = active_accounts.some(acc => acc.landing_company_shortcode === 'svg'); + const result = active_accounts.some(acc => acc.landing_company_shortcode === Jurisdiction.SVG); return !result && this.selected_region === 'Non-EU'; } @@ -250,8 +257,8 @@ export default class TradersHubStore extends BaseStore { const { financial_company, gaming_company } = this.root_store.client.landing_companies; return ( this.content_flag === ContentFlag.CR_DEMO && - financial_company?.shortcode === 'maltainvest' && - gaming_company?.shortcode === 'svg' + financial_company?.shortcode === Jurisdiction.MALTA_INVEST && + gaming_company?.shortcode === Jurisdiction.SVG ); } @@ -260,21 +267,23 @@ export default class TradersHubStore extends BaseStore { const { financial_company, gaming_company } = landing_companies; //this is a conditional check for countries like Australia/Norway which fulfiles one of these following conditions - const restricted_countries = financial_company?.shortcode === 'svg' || gaming_company?.shortcode === 'svg'; + const restricted_countries = + financial_company?.shortcode === Jurisdiction.SVG || gaming_company?.shortcode === Jurisdiction.SVG; if (!is_logged_in) return ''; - if (!gaming_company?.shortcode && financial_company?.shortcode === 'maltainvest') { + if (!gaming_company?.shortcode && financial_company?.shortcode === Jurisdiction.MALTA_INVEST) { if (this.is_demo) return ContentFlag.EU_DEMO; return ContentFlag.EU_REAL; } else if ( - financial_company?.shortcode === 'maltainvest' && - gaming_company?.shortcode === 'svg' && + financial_company?.shortcode === Jurisdiction.MALTA_INVEST && + gaming_company?.shortcode === Jurisdiction.SVG && this.is_real ) { if (this.is_eu_user) return ContentFlag.LOW_RISK_CR_EU; return ContentFlag.LOW_RISK_CR_NON_EU; } else if ( - ((financial_company?.shortcode === 'svg' && gaming_company?.shortcode === 'svg') || restricted_countries) && + ((financial_company?.shortcode === Jurisdiction.SVG && gaming_company?.shortcode === Jurisdiction.SVG) || + restricted_countries) && this.is_real ) { return ContentFlag.HIGH_RISK_CR; @@ -330,7 +339,10 @@ export default class TradersHubStore extends BaseStore { ContentFlag.CR_DEMO, ].includes(this.content_flag); const { active_accounts } = this.root_store.client; - return is_low_risk_cr_client && active_accounts.some(acc => acc.landing_company_shortcode === 'maltainvest'); + return ( + is_low_risk_cr_client && + active_accounts.some(acc => acc.landing_company_shortcode === Jurisdiction.MALTA_INVEST) + ); } toggleRegulatorsCompareModal() { @@ -386,7 +398,7 @@ export default class TradersHubStore extends BaseStore { get financial_restricted_countries() { const { financial_company, gaming_company } = this.root_store.client.landing_companies; - return gaming_company?.shortcode === 'svg' && !financial_company; + return gaming_company?.shortcode === Jurisdiction.SVG && !financial_company; } getAvailableMt5Accounts() { @@ -434,7 +446,7 @@ export default class TradersHubStore extends BaseStore { const selected_account_type = this.selected_account_type; const existing_accounts = current_list_keys .filter(key => { - const maltainvest_account = current_list[key].landing_company_short === 'maltainvest'; + const maltainvest_account = current_list[key].landing_company_short === Jurisdiction.MALTA_INVEST; if (platform === CFD_PLATFORMS.MT5 && !this.is_eu_user && !maltainvest_account) { return key.startsWith(`${platform}.${selected_account_type}.${market_type}`); @@ -508,7 +520,7 @@ export default class TradersHubStore extends BaseStore { const { openAccountNeededModal } = ui; const { is_eu } = client; if (is_eu && !has_maltainvest_account && standpoint?.iom) { - openAccountNeededModal('maltainvest', localize('Deriv Multipliers'), localize('demo CFDs')); + openAccountNeededModal(Jurisdiction.MALTA_INVEST, localize('Deriv Multipliers'), localize('demo CFDs')); return; } createCFDAccount({ ...account_type, platform }); @@ -589,7 +601,7 @@ export default class TradersHubStore extends BaseStore { hasMultipleSVGAccounts = () => { const all_svg_acc = []; this.combined_cfd_mt5_accounts.map(acc => { - if (acc.landing_company_short === 'svg' && acc.market_type === 'synthetic') { + if (acc.landing_company_short === Jurisdiction.SVG && acc.market_type === 'synthetic') { if (all_svg_acc.length) { all_svg_acc.forEach(svg_acc => { if (svg_acc.server !== acc.server) all_svg_acc.push(acc); @@ -607,15 +619,15 @@ export default class TradersHubStore extends BaseStore { if (this.is_real && !this.is_eu_user) { const short_code = account.landing_company_short && - account.landing_company_short !== 'svg' && - account.landing_company_short !== 'bvi' + account.landing_company_short !== Jurisdiction.SVG && + account.landing_company_short !== Jurisdiction.BVI ? account.landing_company_short?.charAt(0).toUpperCase() + account.landing_company_short?.slice(1) : account.landing_company_short?.toUpperCase(); let region = ''; if (this.hasMultipleSVGAccounts()) { region = - account.market_type !== 'financial' && account.landing_company_short !== 'bvi' + account.market_type !== 'financial' && account.landing_company_short !== Jurisdiction.BVI ? ` - ${this.getServerName(account)}` : ''; } @@ -688,8 +700,8 @@ export default class TradersHubStore extends BaseStore { account => !account.is_virtual && (this.is_eu_user - ? account.landing_company_shortcode === 'maltainvest' - : account.landing_company_shortcode !== 'maltainvest') + ? account.landing_company_shortcode === Jurisdiction.MALTA_INVEST + : account.landing_company_shortcode !== Jurisdiction.MALTA_INVEST) ); if (platform_real_accounts?.length) { this.platform_real_balance = await this.getTotalBalance( @@ -710,8 +722,8 @@ export default class TradersHubStore extends BaseStore { account => account.account_type === 'real' && (this.is_eu_user - ? account.landing_company_short === 'maltainvest' - : account.landing_company_short !== 'maltainvest') + ? account.landing_company_short === Jurisdiction.MALTA_INVEST + : account.landing_company_short !== Jurisdiction.MALTA_INVEST) ); if (cfd_real_accounts?.length) { this.cfd_real_balance = await this.getTotalBalance(cfd_real_accounts, cfd_real_accounts[0]?.currency); diff --git a/packages/hooks/src/__tests__/useDepositLocked.spec.tsx b/packages/hooks/src/__tests__/useDepositLocked.spec.tsx index 56a4674185e2..401d65a23049 100644 --- a/packages/hooks/src/__tests__/useDepositLocked.spec.tsx +++ b/packages/hooks/src/__tests__/useDepositLocked.spec.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import { StoreProvider } from '@deriv/stores'; import type { TStores } from '@deriv/stores'; +import { Jurisdiction } from '@deriv/shared'; import { renderHook } from '@testing-library/react-hooks'; import useDepositLocked from '../useDepositLocked'; import useNeedAuthentication from '../useNeedAuthentication'; @@ -18,7 +19,7 @@ describe('useDepositLocked', () => { is_financial_account: false, is_financial_information_incomplete: false, is_trading_experience_incomplete: false, - landing_company_shortcode: 'svg', + landing_company_shortcode: Jurisdiction.SVG, mt5_login_list: [ { account_type: 'demo', @@ -46,7 +47,7 @@ describe('useDepositLocked', () => { is_financial_account: false, is_financial_information_incomplete: false, is_trading_experience_incomplete: false, - landing_company_shortcode: 'svg', + landing_company_shortcode: Jurisdiction.SVG, mt5_login_list: [ { account_type: 'demo', @@ -74,7 +75,7 @@ describe('useDepositLocked', () => { is_financial_account: false, is_financial_information_incomplete: false, is_trading_experience_incomplete: false, - landing_company_shortcode: 'svg', + landing_company_shortcode: Jurisdiction.SVG, mt5_login_list: [ { account_type: 'real', @@ -102,7 +103,7 @@ describe('useDepositLocked', () => { is_financial_account: true, is_financial_information_incomplete: true, is_trading_experience_incomplete: false, - landing_company_shortcode: 'svg', + landing_company_shortcode: Jurisdiction.SVG, mt5_login_list: [ { account_type: 'demo', @@ -130,7 +131,7 @@ describe('useDepositLocked', () => { is_financial_account: false, is_financial_information_incomplete: false, is_trading_experience_incomplete: false, - landing_company_shortcode: 'svg', + landing_company_shortcode: Jurisdiction.SVG, mt5_login_list: [ { account_type: 'real', @@ -158,7 +159,7 @@ describe('useDepositLocked', () => { is_financial_account: true, is_financial_information_incomplete: true, is_trading_experience_incomplete: false, - landing_company_shortcode: 'svg', + landing_company_shortcode: Jurisdiction.SVG, mt5_login_list: [ { account_type: 'demo', @@ -186,7 +187,7 @@ describe('useDepositLocked', () => { is_financial_account: false, is_financial_information_incomplete: false, is_trading_experience_incomplete: true, - landing_company_shortcode: 'maltainvest', + landing_company_shortcode: Jurisdiction.MALTA_INVEST, mt5_login_list: [ { account_type: 'demo', diff --git a/packages/hooks/src/useDepositLocked.ts b/packages/hooks/src/useDepositLocked.ts index 3e6c39ae9610..76904763d142 100644 --- a/packages/hooks/src/useDepositLocked.ts +++ b/packages/hooks/src/useDepositLocked.ts @@ -1,4 +1,5 @@ import { useStore } from '@deriv/stores'; +import { Jurisdiction } from '@deriv/shared'; import useNeedAuthentication from './useNeedAuthentication'; import useNeedFinancialAssessment from './useNeedFinancialAssessment'; import useNeedTNC from './useNeedTNC'; @@ -9,7 +10,7 @@ const useDepositLocked = () => { const is_need_authentication = useNeedAuthentication(); const is_need_tnc = useNeedTNC(); const is_need_financial_assessment = useNeedFinancialAssessment(); - const is_malta_invest = landing_company_shortcode === 'maltainvest'; + const is_malta_invest = landing_company_shortcode === Jurisdiction.MALTA_INVEST; const is_trading_experience_incomplete_or_need_financial_assessment = is_malta_invest ? is_trading_experience_incomplete : is_need_financial_assessment; diff --git a/packages/hooks/src/useHasMaltaInvestAccount.ts b/packages/hooks/src/useHasMaltaInvestAccount.ts index 4251c51b2115..3ad3010c373b 100644 --- a/packages/hooks/src/useHasMaltaInvestAccount.ts +++ b/packages/hooks/src/useHasMaltaInvestAccount.ts @@ -1,10 +1,11 @@ import { useStore } from '@deriv/stores'; +import { Jurisdiction } from '@deriv/shared'; const useHasMaltaInvestAccount = () => { const { client } = useStore(); const { active_accounts } = client; const has_malta_invest_account = active_accounts.some( - account => account.landing_company_shortcode === 'maltainvest' + account => account.landing_company_shortcode === Jurisdiction.MALTA_INVEST ); return has_malta_invest_account; diff --git a/packages/shared/src/utils/cfd/cfd.ts b/packages/shared/src/utils/cfd/cfd.ts index dbfcc6cd177e..d9f587aa84fa 100644 --- a/packages/shared/src/utils/cfd/cfd.ts +++ b/packages/shared/src/utils/cfd/cfd.ts @@ -1,5 +1,6 @@ import { CFD_PLATFORMS } from '../platform'; import { LandingCompany, GetAccountStatus, DetailsOfEachMT5Loginid } from '@deriv/api-types'; +import { Jurisdiction } from '../constants/jurisdiction'; import { localize } from '@deriv/translations'; let CFD_text_translated: { [key: string]: () => void }; @@ -46,11 +47,11 @@ export const getCFDAccountKey = ({ market_type, sub_account_type, platform, shor if (market_type === 'gaming' || market_type === 'synthetic') { if (platform === CFD_PLATFORMS.DXTRADE || sub_account_type === 'financial') { switch (shortcode) { - case 'svg': + case Jurisdiction.SVG: return 'synthetic_svg'; - case 'bvi': + case Jurisdiction.BVI: return 'synthetic_bvi'; - case 'vanuatu': + case Jurisdiction.VANUATU: return 'synthetic_v'; default: return 'synthetic'; @@ -64,13 +65,13 @@ export const getCFDAccountKey = ({ market_type, sub_account_type, platform, shor sub_account_type === 'financial_stp' ) { switch (shortcode) { - case 'svg': + case Jurisdiction.SVG: return 'financial_svg'; - case 'bvi': + case Jurisdiction.BVI: return 'financial_bvi'; - case 'labuan': + case Jurisdiction.LABUAN: return 'financial_fx'; - case 'vanuatu': + case Jurisdiction.VANUATU: return 'financial_v'; default: return 'financial'; diff --git a/packages/shared/src/utils/constants/index.ts b/packages/shared/src/utils/constants/index.ts index 5d4931b44ec6..b72f7a0a5ff0 100644 --- a/packages/shared/src/utils/constants/index.ts +++ b/packages/shared/src/utils/constants/index.ts @@ -1,3 +1,4 @@ export * from './barriers'; export * from './contract'; export * from './content_flags'; +export * from './jurisdiction'; diff --git a/packages/stores/src/mockStore.ts b/packages/stores/src/mockStore.ts index 6f433ca96fc4..438bb1d3640b 100644 --- a/packages/stores/src/mockStore.ts +++ b/packages/stores/src/mockStore.ts @@ -1,4 +1,5 @@ import merge from 'lodash.merge'; +import { Jurisdiction } from '../../shared/src/utils/constants'; import type { TRootStore } from '../types'; const mock = (): TRootStore => { @@ -13,7 +14,7 @@ const mock = (): TRootStore => { is_virtual: 0, trading: {}, excluded_until: 0, - landing_company_name: 'svg', + landing_company_name: Jurisdiction.SVG, }, }, active_account_landing_company: '', diff --git a/packages/trader/src/Stores/Modules/Trading/trade-store.js b/packages/trader/src/Stores/Modules/Trading/trade-store.js index 78af860183bb..d4813b1e755f 100644 --- a/packages/trader/src/Stores/Modules/Trading/trade-store.js +++ b/packages/trader/src/Stores/Modules/Trading/trade-store.js @@ -16,6 +16,7 @@ import { isEmptyObject, isMarketClosed, isMobile, + Jurisdiction, pickDefaultSymbol, removeBarrier, resetEndTimeOnVolatilityIndices, @@ -419,7 +420,7 @@ export default class TradeStore extends BaseStore { } async setActiveSymbols() { - const is_on_mf_account = this.root_store.client.landing_company_shortcode === 'maltainvest'; + const is_on_mf_account = this.root_store.client.landing_company_shortcode === Jurisdiction.MALTA_INVEST; const hide_close_mx_mlt_storage_flag = !!parseInt( localStorage.getItem('hide_close_mx_mlt_account_notification') ); From fc9a5c35d603d1381982a1479b01030d7198e324 Mon Sep 17 00:00:00 2001 From: Taysuisin Date: Wed, 22 Mar 2023 16:26:06 +0800 Subject: [PATCH 4/7] Revert "chore: update all files change string to use same Jurisdiction in constant file" This reverts commit 92c2f78ed3200b453130563cd0743f7731cd3d94. --- .../__tests__/currency-selector.spec.tsx | 8 +-- .../personal-details/personal-details.jsx | 15 +----- .../__tests__/terms-of-use.spec.js | 8 +-- .../terms-of-use/terms-of-use-messages.jsx | 10 ++-- .../account/src/Configs/accept-risk-config.js | 4 +- .../src/Configs/address-details-config.js | 26 ++++----- .../src/Configs/currency-selector-schema.js | 3 +- .../src/Configs/financial-details-config.js | 36 ++++++------- .../src/Configs/personal-details-config.js | 39 ++++++-------- .../src/Configs/terms-of-use-config.js | 6 +-- .../src/Configs/trading-assessment-config.js | 4 +- packages/account/src/Containers/account.jsx | 13 ++--- .../financial-assessment.jsx | 4 +- .../PersonalDetails/personal-details.jsx | 3 +- .../Security/SelfExclusion/self-exclusion.jsx | 4 +- .../add-options-account.tsx | 4 +- .../currency-switcher-container.tsx | 3 +- .../real/real-account-card.tsx | 4 +- .../failed-verification-modal.tsx | 6 +-- .../options-multipliers-listing/index.tsx | 4 +- .../src/services/api/account-limits.js | 4 +- .../cashier/src/pages/deposit/deposit.tsx | 7 +-- .../__tests__/account-transfer-store.spec.ts | 4 +- .../src/stores/account-transfer-store.ts | 5 +- .../__tests__/cfd-account-card.spec.tsx | 7 ++- .../cfd-demo-account-display.spec.js | 15 ++---- .../cfd-real-account-display.spec.js | 13 +++-- .../cfd/src/Components/cfd-account-card.tsx | 18 +++---- .../Components/cfd-demo-account-display.tsx | 3 +- .../cfd-mt5-demo-account-display.tsx | 3 +- .../__tests__/cfd-dashboard.spec.tsx | 16 +++--- .../__tests__/cfd-password-modal.spec.js | 6 +-- .../cfd/src/Containers/derivx-trade-modal.tsx | 3 +- .../cfd/src/Containers/dmt5-trade-modal.tsx | 3 +- .../jurisdiction-modal-content.tsx | 2 +- .../jurisdiction-modal-foot-note.tsx | 2 +- .../jurisdiction-modal/jurisdiction-modal.tsx | 8 +-- .../Containers/mt5-compare-table-content.tsx | 16 +++--- .../cfd/src/Stores/Modules/CFD/cfd-store.js | 12 ++--- .../deriv-real-account-required-modal.jsx | 3 +- .../Layout/Footer/regulatory-information.jsx | 6 +-- .../Layout/Header/toggle-menu-drawer.jsx | 6 +-- .../account-switcher-account-list.jsx | 13 ++--- .../AccountSwitcher/account-switcher.jsx | 23 +++----- .../src/App/Containers/Modals/app-modals.jsx | 4 +- .../exit-traders-hub-modal.jsx | 3 +- .../ready-to-deposit-modal.tsx | 3 +- .../RealAccountSignup/account-wizard-form.js | 6 +-- .../RealAccountSignup/account-wizard.jsx | 4 +- .../RealAccountSignup/helpers/constants.js | 7 ++- .../helpers/dialog-buttons.jsx | 5 +- .../helpers/dialog-message.jsx | 3 +- .../proof-of-address-form.js | 4 +- .../proof-of-identity-form.js | 4 +- .../RealAccountSignup/real-account-signup.jsx | 10 ++-- .../Containers/WelcomeModal/welcome-modal.jsx | 3 +- .../Containers/app-notification-messages.jsx | 4 +- .../Components/complaints-policy-content.jsx | 20 +++---- packages/core/src/Stores/client-store.js | 49 ++++++++--------- .../core/src/Stores/notification-store.js | 9 ++-- packages/core/src/Stores/traders-hub-store.js | 54 ++++++++----------- .../src/__tests__/useDepositLocked.spec.tsx | 15 +++--- packages/hooks/src/useDepositLocked.ts | 3 +- .../hooks/src/useHasMaltaInvestAccount.ts | 3 +- packages/shared/src/utils/cfd/cfd.ts | 15 +++--- packages/shared/src/utils/constants/index.ts | 1 - packages/stores/src/mockStore.ts | 3 +- .../src/Stores/Modules/Trading/trade-store.js | 3 +- 68 files changed, 269 insertions(+), 368 deletions(-) diff --git a/packages/account/src/Components/currency-selector/__tests__/currency-selector.spec.tsx b/packages/account/src/Components/currency-selector/__tests__/currency-selector.spec.tsx index 255df682efcf..9cc96a824245 100644 --- a/packages/account/src/Components/currency-selector/__tests__/currency-selector.spec.tsx +++ b/packages/account/src/Components/currency-selector/__tests__/currency-selector.spec.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { fireEvent, screen, render, waitFor } from '@testing-library/react'; -import { isDesktop, isMobile, PlatformContext, Jurisdiction } from '@deriv/shared'; +import { isDesktop, isMobile, PlatformContext } from '@deriv/shared'; import CurrencySelector, { TCurrencySelector } from '../currency-selector'; jest.mock('@deriv/shared', () => ({ @@ -269,20 +269,20 @@ describe('', () => { currency: 'USD', is_disabled: 0, is_virtual: 1, - landing_company_shortcode: Jurisdiction.SVG, + landing_company_shortcode: 'svg', trading: {}, token: 'a1-sLGGrhfYPkeEprxEop2T591cLKbuN', email: 'test+qw@deriv.com', session_start: 1651059038, excluded_until: '', - landing_company_name: Jurisdiction.SVG, + landing_company_name: 'svg', residence: 'es', balance: 10000, accepted_bch: 0, }, }, has_real_account: true, - real_account_signup_target: Jurisdiction.SVG, + real_account_signup_target: 'svg', }; render(); diff --git a/packages/account/src/Components/personal-details/personal-details.jsx b/packages/account/src/Components/personal-details/personal-details.jsx index 4489ef8fe547..879855526a6f 100644 --- a/packages/account/src/Components/personal-details/personal-details.jsx +++ b/packages/account/src/Components/personal-details/personal-details.jsx @@ -20,16 +20,7 @@ import { } from '@deriv/components'; import { Link } from 'react-router-dom'; import { localize, Localize } from '@deriv/translations'; -import { - getLegalEntityName, - isDesktop, - isMobile, - routes, - toMoment, - PlatformContext, - validPhone, - Jurisdiction, -} from '@deriv/shared'; +import { getLegalEntityName, isDesktop, isMobile, routes, toMoment, PlatformContext, validPhone } from '@deriv/shared'; import { getEmploymentStatusList } from 'Sections/Assessment/FinancialAssessment/financial-information-list'; import { splitValidationResultTypes } from '../real-account-signup/helpers/utils'; import FormSubHeader from '../form-sub-header'; @@ -680,9 +671,7 @@ const PersonalDetails = ({ label={localize( 'I hereby confirm that the tax information I provided is true and complete. I will also inform {{legal_entity_name}} about any changes to this information.', { - legal_entity_name: getLegalEntityName( - Jurisdiction.MALTA_INVEST - ), + legal_entity_name: getLegalEntityName('maltainvest'), } )} renderlabel={title => ( diff --git a/packages/account/src/Components/terms-of-use/__tests__/terms-of-use.spec.js b/packages/account/src/Components/terms-of-use/__tests__/terms-of-use.spec.js index 4a279c0ed0a9..629854d40ff6 100644 --- a/packages/account/src/Components/terms-of-use/__tests__/terms-of-use.spec.js +++ b/packages/account/src/Components/terms-of-use/__tests__/terms-of-use.spec.js @@ -1,6 +1,6 @@ import React from 'react'; import { fireEvent, render, screen, waitFor } from '@testing-library/react'; -import { isDesktop, isMobile, PlatformContext, Jurisdiction } from '@deriv/shared'; +import { isDesktop, isMobile, PlatformContext } from '@deriv/shared'; import TermsOfUse from '../terms-of-use'; jest.mock('@deriv/shared', () => ({ @@ -48,7 +48,7 @@ describe('', () => { }; it('should render TermsOfUse component for svg accounts', () => { - mock_props.real_account_signup_target = Jurisdiction.SVG; + mock_props.real_account_signup_target = 'svg'; render(); @@ -99,7 +99,7 @@ describe('', () => { }); it('should render TermsOfUse component for maltainvest accounts and show "Add account" button', () => { - mock_props.real_account_signup_target = Jurisdiction.MALTA_INVEST; + mock_props.real_account_signup_target = 'maltainvest'; render(); @@ -122,7 +122,7 @@ describe('', () => { isMobile.mockReturnValue(true); isDesktop.mockReturnValue(false); - mock_props.real_account_signup_target = Jurisdiction.MALTA_INVEST; + mock_props.real_account_signup_target = 'maltainvest'; render(); diff --git a/packages/account/src/Components/terms-of-use/terms-of-use-messages.jsx b/packages/account/src/Components/terms-of-use/terms-of-use-messages.jsx index 2e5f781cc9a1..08b0d207aaa8 100644 --- a/packages/account/src/Components/terms-of-use/terms-of-use-messages.jsx +++ b/packages/account/src/Components/terms-of-use/terms-of-use-messages.jsx @@ -1,16 +1,16 @@ import React from 'react'; import { Localize } from '@deriv/translations'; -import { getLegalEntityName, Jurisdiction } from '@deriv/shared'; +import { getLegalEntityName } from '@deriv/shared'; import { Text } from '@deriv/components'; export const Hr = () =>
; export const BrokerSpecificMessage = ({ target }) => ( - {target === Jurisdiction.SVG && } + {target === 'svg' && } {target === 'iom' && } {target === 'malta' && } - {target === Jurisdiction.MALTA_INVEST && } + {target === 'maltainvest' && } {target === 'samoa' && } ); @@ -26,7 +26,7 @@ export const SVGDescription = () => ( 'Your account will be opened with {{legal_entity_name}}, and will be subject to the laws of Saint Vincent and the Grenadines.' } values={{ - legal_entity_name: getLegalEntityName(Jurisdiction.SVG), + legal_entity_name: getLegalEntityName('svg'), }} />

@@ -91,7 +91,7 @@ export const MaltaInvestDescription = () => ( 'Your account will be opened with {{legal_entity_name}}, regulated by the Malta Financial Services Authority (MFSA), and will be subject to the laws of Malta.' } values={{ - legal_entity_name: getLegalEntityName(Jurisdiction.MALTA_INVEST), + legal_entity_name: getLegalEntityName('maltainvest'), }} />

diff --git a/packages/account/src/Configs/accept-risk-config.js b/packages/account/src/Configs/accept-risk-config.js index 9b7a37c2ab14..0941fabebf9b 100644 --- a/packages/account/src/Configs/accept-risk-config.js +++ b/packages/account/src/Configs/accept-risk-config.js @@ -1,8 +1,8 @@ -import { getDefaultFields, Jurisdiction } from '@deriv/shared'; +import { getDefaultFields } from '@deriv/shared'; const accept_risk_config = { accept_risk: { - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], default_value: 1, }, }; diff --git a/packages/account/src/Configs/address-details-config.js b/packages/account/src/Configs/address-details-config.js index 57b9955952f2..199aafa40fd6 100644 --- a/packages/account/src/Configs/address-details-config.js +++ b/packages/account/src/Configs/address-details-config.js @@ -1,11 +1,5 @@ import { localize } from '@deriv/translations'; -import { - generateValidationFunction, - getDefaultFields, - getErrorMessages, - regex_checks, - Jurisdiction, -} from '@deriv/shared'; +import { generateValidationFunction, getDefaultFields, getErrorMessages, regex_checks } from '@deriv/shared'; const address_details_config = ({ account_settings, is_svg }) => { const is_gb = account_settings.country_code === 'gb'; @@ -15,7 +9,7 @@ const address_details_config = ({ account_settings, is_svg }) => { const base_case = { address_line_1: { - supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], + supported_in: ['svg', 'iom', 'malta', 'maltainvest'], default_value: account_settings.address_line_1 ?? '', rules: [ ['req', localize('First line of address is required')], @@ -31,7 +25,7 @@ const address_details_config = ({ account_settings, is_svg }) => { ].filter(x => (is_svg ? x.indexOf('po_box') !== 0 : x)), }, address_line_2: { - supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], + supported_in: ['svg', 'iom', 'malta', 'maltainvest'], default_value: account_settings.address_line_2 ?? '', rules: [ ['length', localize('Only {{max}} characters, please.', { max: 70 }), { max: 70 }], @@ -46,7 +40,7 @@ const address_details_config = ({ account_settings, is_svg }) => { ].filter(x => (is_svg ? x.indexOf('po_box') !== 0 : x)), }, address_city: { - supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], + supported_in: ['svg', 'iom', 'malta', 'maltainvest'], default_value: account_settings.address_city ?? '', rules: [ ['req', localize('City is required')], @@ -61,7 +55,7 @@ const address_details_config = ({ account_settings, is_svg }) => { ], }, address_state: { - supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], + supported_in: ['svg', 'iom', 'malta', 'maltainvest'], default_value: account_settings.address_state ?? '', rules: [ ['req', localize('State is required')], @@ -75,7 +69,7 @@ const address_details_config = ({ account_settings, is_svg }) => { ], }, address_postcode: { - supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], + supported_in: ['svg', 'iom', 'malta', 'maltainvest'], default_value: account_settings.address_postcode ?? '', rules: [ [ @@ -102,7 +96,7 @@ const address_details_config = ({ account_settings, is_svg }) => { const gb_case = { ...base_case, address_postcode: { - supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], + supported_in: ['svg', 'iom', 'malta', 'maltainvest'], default_value: account_settings.address_postcode ?? '', rules: [ [ @@ -141,9 +135,9 @@ const addressDetailsConfig = ( AddressDetails, is_appstore = false ) => { - const is_svg = upgrade_info?.can_upgrade_to === Jurisdiction.SVG; + const is_svg = upgrade_info?.can_upgrade_to === 'svg'; const config = address_details_config({ account_settings, is_svg }); - const is_mf = real_account_signup_target === Jurisdiction.MALTA_INVEST; + const is_mf = real_account_signup_target === 'maltainvest'; return { header: { @@ -186,7 +180,7 @@ const transformForResidence = (rules, residence) => { const transformConfig = (config, { real_account_signup_target }) => { // Remove required rule for svg clients - if (!real_account_signup_target || real_account_signup_target === Jurisdiction.SVG) { + if (!real_account_signup_target || real_account_signup_target === 'svg') { config.address_state.rules.shift(); } diff --git a/packages/account/src/Configs/currency-selector-schema.js b/packages/account/src/Configs/currency-selector-schema.js index b5f16b179437..6b6f882b2246 100644 --- a/packages/account/src/Configs/currency-selector-schema.js +++ b/packages/account/src/Configs/currency-selector-schema.js @@ -1,9 +1,8 @@ import { localize } from '@deriv/translations'; -import { Jurisdiction } from '@deriv/shared'; export default { currency: { - supported_in: [Jurisdiction.MALTA_INVEST, 'malta', Jurisdiction.SVG, 'iom'], + supported_in: ['maltainvest', 'malta', 'svg', 'iom'], default_value: '', rules: [['req', localize('Select an item')]], }, diff --git a/packages/account/src/Configs/financial-details-config.js b/packages/account/src/Configs/financial-details-config.js index 8e1bee8485b1..bc75d64d2d73 100644 --- a/packages/account/src/Configs/financial-details-config.js +++ b/packages/account/src/Configs/financial-details-config.js @@ -1,91 +1,91 @@ import { localize } from '@deriv/translations'; -import { generateValidationFunction, getDefaultFields, Jurisdiction } from '@deriv/shared'; +import { generateValidationFunction, getDefaultFields } from '@deriv/shared'; const financial_details_config = ({ financial_assessment }) => { return { account_turnover: { - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], default_value: financial_assessment?.account_turnover ?? '', rules: [['req', localize('Please select an option')]], }, binary_options_trading_experience: { - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], default_value: financial_assessment?.binary_options_trading_experience ?? '', rules: [['req', localize('Please select an option')]], }, binary_options_trading_frequency: { - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], default_value: financial_assessment?.binary_options_trading_frequency ?? '', rules: [['req', localize('Please select an option')]], }, cfd_trading_experience: { - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], default_value: financial_assessment?.cfd_trading_experience ?? '', rules: [['req', localize('Please select an option')]], }, cfd_trading_frequency: { - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], default_value: financial_assessment?.cfd_trading_frequency ?? '', rules: [['req', localize('Please select an option')]], }, education_level: { - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], default_value: financial_assessment?.education_level ?? '', rules: [['req', localize('Please select an option')]], }, forex_trading_experience: { - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], default_value: financial_assessment?.forex_trading_experience ?? '', rules: [['req', localize('Please select an option')]], }, forex_trading_frequency: { - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], default_value: financial_assessment?.forex_trading_frequency ?? '', rules: [['req', localize('Please select an option')]], }, employment_industry: { default_value: financial_assessment?.employment_industry ?? '', - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], rules: [['req', localize('Please select an option')]], }, employment_status: { default_value: financial_assessment?.employment_status ?? '', - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], rules: [['req', localize('Please select an option')]], }, estimated_worth: { default_value: financial_assessment?.estimated_worth ?? '', - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], rules: [['req', localize('Please select an option')]], }, income_source: { default_value: financial_assessment?.income_source ?? '', - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], rules: [['req', localize('Please select an option')]], }, net_income: { default_value: financial_assessment?.net_income ?? '', - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], rules: [['req', localize('Please select an option')]], }, occupation: { default_value: financial_assessment?.occupation ?? '', - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], rules: [['req', localize('Please select an option')]], }, other_instruments_trading_experience: { default_value: financial_assessment?.other_instruments_trading_experience ?? '', - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], rules: [['req', localize('Please select an option')]], }, other_instruments_trading_frequency: { default_value: financial_assessment?.other_instruments_trading_frequency ?? '', - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], rules: [['req', localize('Please select an option')]], }, source_of_wealth: { default_value: financial_assessment?.source_of_wealth ?? '', - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], rules: [['req', localize('Please select an option')]], }, }; diff --git a/packages/account/src/Configs/personal-details-config.js b/packages/account/src/Configs/personal-details-config.js index 9b292d3ebc05..a994b15edf82 100644 --- a/packages/account/src/Configs/personal-details-config.js +++ b/packages/account/src/Configs/personal-details-config.js @@ -1,11 +1,4 @@ -import { - toMoment, - getErrorMessages, - generateValidationFunction, - getDefaultFields, - validLength, - Jurisdiction, -} from '@deriv/shared'; +import { toMoment, getErrorMessages, generateValidationFunction, getDefaultFields, validLength } from '@deriv/shared'; import { localize } from '@deriv/translations'; const personal_details_config = ({ residence_list, account_settings, is_appstore, real_account_signup_target }) => { @@ -21,17 +14,17 @@ const personal_details_config = ({ residence_list, account_settings, is_appstore const config = { account_opening_reason: { - supported_in: ['iom', 'malta', Jurisdiction.MALTA_INVEST], + supported_in: ['iom', 'malta', 'maltainvest'], default_value: account_settings.account_opening_reason ?? '', rules: [['req', localize('Account opening reason is required.')]], }, salutation: { - supported_in: ['iom', 'malta', Jurisdiction.MALTA_INVEST], + supported_in: ['iom', 'malta', 'maltainvest'], default_value: account_settings.salutation ?? '', rules: [['req', localize('Salutation is required.')]], }, first_name: { - supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], + supported_in: ['svg', 'iom', 'malta', 'maltainvest'], default_value: account_settings.first_name ?? '', rules: [ ['req', localize('First name is required.')], @@ -40,7 +33,7 @@ const personal_details_config = ({ residence_list, account_settings, is_appstore ], }, last_name: { - supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], + supported_in: ['svg', 'iom', 'malta', 'maltainvest'], default_value: account_settings.last_name ?? '', rules: [ ['req', localize('Last name is required.')], @@ -49,7 +42,7 @@ const personal_details_config = ({ residence_list, account_settings, is_appstore ], }, date_of_birth: { - supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], + supported_in: ['svg', 'iom', 'malta', 'maltainvest'], default_value: account_settings.date_of_birth ? toMoment(account_settings.date_of_birth).format('YYYY-MM-DD') : '', @@ -62,21 +55,21 @@ const personal_details_config = ({ residence_list, account_settings, is_appstore ], }, place_of_birth: { - supported_in: [Jurisdiction.MALTA_INVEST, 'iom', 'malta'], + supported_in: ['maltainvest', 'iom', 'malta'], default_value: account_settings.place_of_birth ? residence_list.find(item => item.value === account_settings.place_of_birth)?.text : '', rules: [['req', localize('Place of birth is required.')]], }, citizen: { - supported_in: ['iom', 'malta', Jurisdiction.MALTA_INVEST], + supported_in: ['iom', 'malta', 'maltainvest'], default_value: account_settings.citizen ? residence_list.find(item => item.value === account_settings.citizen)?.text : '', rules: [['req', localize('Citizenship is required')]], }, phone: { - supported_in: [Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST], + supported_in: ['svg', 'iom', 'malta', 'maltainvest'], default_value: account_settings.phone ?? '', rules: [ ['req', localize('Phone is required.')], @@ -96,15 +89,15 @@ const personal_details_config = ({ residence_list, account_settings, is_appstore }, tax_residence: { default_value: - real_account_signup_target === Jurisdiction.MALTA_INVEST + real_account_signup_target === 'maltainvest' ? account_settings.residence : residence_list.find(item => item.value === account_settings.tax_residence)?.text || '', - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], rules: [['req', localize('Tax residence is required.')]], }, tax_identification_number: { default_value: account_settings.tax_identification_number ?? '', - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], rules: [ ['req', localize('Tax Identification Number is required.')], [ @@ -142,12 +135,12 @@ const personal_details_config = ({ residence_list, account_settings, is_appstore }, employment_status: { default_value: '', - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], rules: [['req', localize('Employment status is required.')]], }, tax_identification_confirm: { default_value: false, - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], rules: [['confirm', localize('Please confirm your tax information.')]], }, }; @@ -191,8 +184,8 @@ const personalDetailsConfig = ( real_account_signup_target, transformConfig(config, { real_account_signup_target }) ), - is_svg: upgrade_info?.can_upgrade_to === Jurisdiction.SVG, - is_mf: real_account_signup_target === Jurisdiction.MALTA_INVEST, + is_svg: upgrade_info?.can_upgrade_to === 'svg', + is_mf: real_account_signup_target === 'maltainvest', account_opening_reason_list: [ { text: localize('Hedging'), diff --git a/packages/account/src/Configs/terms-of-use-config.js b/packages/account/src/Configs/terms-of-use-config.js index 0167018646b6..384e6ffd32ae 100644 --- a/packages/account/src/Configs/terms-of-use-config.js +++ b/packages/account/src/Configs/terms-of-use-config.js @@ -1,14 +1,14 @@ -import { getDefaultFields, isDesktop, Jurisdiction } from '@deriv/shared'; +import { getDefaultFields, isDesktop } from '@deriv/shared'; import { localize } from '@deriv/translations'; const terms_of_use_config = { agreed_tos: { - supported_in: [Jurisdiction.SVG, Jurisdiction.MALTA_INVEST], + supported_in: ['svg', 'maltainvest'], default_value: false, }, agreed_tnc: { - supported_in: [Jurisdiction.SVG, Jurisdiction.MALTA_INVEST], + supported_in: ['svg', 'maltainvest'], default_value: false, }, }; diff --git a/packages/account/src/Configs/trading-assessment-config.js b/packages/account/src/Configs/trading-assessment-config.js index ab83aaed286d..e526ad205658 100644 --- a/packages/account/src/Configs/trading-assessment-config.js +++ b/packages/account/src/Configs/trading-assessment-config.js @@ -1,4 +1,4 @@ -import { generateValidationFunction, getDefaultFields, Jurisdiction } from '@deriv/shared'; +import { generateValidationFunction, getDefaultFields } from '@deriv/shared'; import { localize } from '@deriv/translations'; export const trading_assessment_questions = () => [ @@ -253,7 +253,7 @@ export const trading_assessment_questions = () => [ ]; const default_form_config = { - supported_in: [Jurisdiction.MALTA_INVEST], + supported_in: ['maltainvest'], default_value: '', }; diff --git a/packages/account/src/Containers/account.jsx b/packages/account/src/Containers/account.jsx index 0eacea56079e..aae57fba274d 100644 --- a/packages/account/src/Containers/account.jsx +++ b/packages/account/src/Containers/account.jsx @@ -2,14 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import { withRouter } from 'react-router-dom'; import { VerticalTab, FadeWrapper, PageOverlay, Loading, Text, Icon } from '@deriv/components'; -import { - routes as shared_routes, - isMobile, - matchRoute, - getSelectedRoute, - PlatformContext, - Jurisdiction, -} from '@deriv/shared'; +import { routes as shared_routes, isMobile, matchRoute, getSelectedRoute, PlatformContext } from '@deriv/shared'; import { localize } from '@deriv/translations'; import { connect } from 'Stores/connect'; import { flatten } from '../Helpers/flatten'; @@ -158,11 +151,11 @@ const Account = ({ if (route.path === shared_routes.financial_assessment) { route.is_disabled = - is_virtual || (active_account_landing_company === Jurisdiction.MALTA_INVEST && !is_risky_client); + is_virtual || (active_account_landing_company === 'maltainvest' && !is_risky_client); } if (route.path === shared_routes.trading_assessment) { - route.is_disabled = is_virtual || active_account_landing_company !== Jurisdiction.MALTA_INVEST; + route.is_disabled = is_virtual || active_account_landing_company !== 'maltainvest'; } if (route.path === shared_routes.proof_of_identity || route.path === shared_routes.proof_of_address) { diff --git a/packages/account/src/Sections/Assessment/FinancialAssessment/financial-assessment.jsx b/packages/account/src/Sections/Assessment/FinancialAssessment/financial-assessment.jsx index 28c0ec104deb..931a3ac2b8bd 100644 --- a/packages/account/src/Sections/Assessment/FinancialAssessment/financial-assessment.jsx +++ b/packages/account/src/Sections/Assessment/FinancialAssessment/financial-assessment.jsx @@ -15,7 +15,7 @@ import { SelectNative, Text, } from '@deriv/components'; -import { routes, isMobile, isDesktop, platforms, PlatformContext, WS, Jurisdiction } from '@deriv/shared'; +import { routes, isMobile, isDesktop, platforms, PlatformContext, WS } from '@deriv/shared'; import { localize, Localize } from '@deriv/translations'; import { connect } from 'Stores/connect'; import LeaveConfirm from 'Components/leave-confirm'; @@ -1025,7 +1025,7 @@ FinancialAssessment.propTypes = { export default connect(({ client, common, notifications }) => ({ is_authentication_needed: client.is_authentication_needed, is_financial_account: client.is_financial_account, - is_mf: client.landing_company_shortcode === Jurisdiction.MALTA_INVEST, + is_mf: client.landing_company_shortcode === 'maltainvest', is_svg: client.is_svg, is_financial_information_incomplete: client.is_financial_information_incomplete, is_trading_experience_incomplete: client.is_trading_experience_incomplete, diff --git a/packages/account/src/Sections/Profile/PersonalDetails/personal-details.jsx b/packages/account/src/Sections/Profile/PersonalDetails/personal-details.jsx index 7da18a1c91b0..b4da912be5b0 100644 --- a/packages/account/src/Sections/Profile/PersonalDetails/personal-details.jsx +++ b/packages/account/src/Sections/Profile/PersonalDetails/personal-details.jsx @@ -36,7 +36,6 @@ import { WS, useIsMounted, validName, - Jurisdiction, } from '@deriv/shared'; import { Localize, localize } from '@deriv/translations'; import { withRouter } from 'react-router'; @@ -1367,7 +1366,7 @@ export default connect(({ client, notifications, ui, common }) => ({ getChangeableFields: client.getChangeableFields, current_landing_company: client.current_landing_company, is_eu: client.is_eu, - is_mf: client.landing_company_shortcode === Jurisdiction.MALTA_INVEST, + is_mf: client.landing_company_shortcode === 'maltainvest', is_svg: client.is_svg, is_uk: client.is_uk, is_virtual: client.is_virtual, diff --git a/packages/account/src/Sections/Security/SelfExclusion/self-exclusion.jsx b/packages/account/src/Sections/Security/SelfExclusion/self-exclusion.jsx index ad6ba263de61..481209b29d4c 100644 --- a/packages/account/src/Sections/Security/SelfExclusion/self-exclusion.jsx +++ b/packages/account/src/Sections/Security/SelfExclusion/self-exclusion.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Jurisdiction, PlatformContext, WS } from '@deriv/shared'; +import { PlatformContext, WS } from '@deriv/shared'; import { connect } from 'Stores/connect'; import SelfExclusionComponent from 'Components/self-exclusion/self-exclusion.jsx'; import 'Components/self-exclusion/self-exclusion.scss'; @@ -17,7 +17,7 @@ export default connect(({ client, ui }) => ({ is_cr: client.standpoint.svg, is_eu: client.is_eu, is_mlt: client.landing_company_shortcode === 'malta', - is_mf: client.landing_company_shortcode === Jurisdiction.MALTA_INVEST, + is_mf: client.landing_company_shortcode === 'maltainvest', is_mx: client.landing_company_shortcode === 'iom', is_uk: client.is_uk, is_wrapper_bypassed: false, diff --git a/packages/appstore/src/components/add-options-account/add-options-account.tsx b/packages/appstore/src/components/add-options-account/add-options-account.tsx index ba74f0a385f6..c42cc18b8734 100644 --- a/packages/appstore/src/components/add-options-account/add-options-account.tsx +++ b/packages/appstore/src/components/add-options-account/add-options-account.tsx @@ -4,7 +4,7 @@ import { Localize, localize } from '@deriv/translations'; import './add-options-account.scss'; import { observer } from 'mobx-react-lite'; import { useStores } from 'Stores'; -import { isMobile, ContentFlag, Jurisdiction } from '@deriv/shared'; +import { isMobile, ContentFlag } from '@deriv/shared'; const AddOptions = () => { const { client, traders_hub, ui } = useStores(); @@ -34,7 +34,7 @@ const AddOptions = () => { if (real_account_creation_unlock_date) { setShouldShowCooldownModal(true); } else { - openRealAccountSignup(Jurisdiction.MALTA_INVEST); + openRealAccountSignup('maltainvest'); } } else { openRealAccountSignup(); diff --git a/packages/appstore/src/components/containers/currency-switcher-container.tsx b/packages/appstore/src/components/containers/currency-switcher-container.tsx index 67103ce2e579..18f3de364293 100644 --- a/packages/appstore/src/components/containers/currency-switcher-container.tsx +++ b/packages/appstore/src/components/containers/currency-switcher-container.tsx @@ -1,7 +1,6 @@ import React, { HTMLAttributes, ReactNode } from 'react'; import classNames from 'classnames'; import { Icon } from '@deriv/components'; -import { Jurisdiction } from '@deriv/shared'; import CurrencyIcon, { Currency } from 'Assets/svgs/currency'; import './currency-switcher-container.scss'; import { useStores } from 'Stores/index'; @@ -33,7 +32,7 @@ const CurrentSwitcherContainer = ({ const has_mf_mt5_account = Object.keys(current_list) .map(key => current_list[key]) - .some(account => account.landing_company_short === Jurisdiction.MALTA_INVEST); + .some(account => account.landing_company_short === 'maltainvest'); const Dropdown = () => { const icon_dropdown = ( diff --git a/packages/appstore/src/components/currency-switcher-card/real/real-account-card.tsx b/packages/appstore/src/components/currency-switcher-card/real/real-account-card.tsx index 81adbe36ca51..1618f61b4c4c 100644 --- a/packages/appstore/src/components/currency-switcher-card/real/real-account-card.tsx +++ b/packages/appstore/src/components/currency-switcher-card/real/real-account-card.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { useHistory } from 'react-router'; import { observer } from 'mobx-react-lite'; import { Button, Text } from '@deriv/components'; -import { formatMoney, getCurrencyName, routes, Jurisdiction } from '@deriv/shared'; +import { formatMoney, getCurrencyName, routes } from '@deriv/shared'; import { localize } from '@deriv/translations'; import BalanceText from 'Components/elements/text/balance-text'; import CurrencySwitcherContainer from 'Components/containers/currency-switcher-container'; @@ -23,7 +23,7 @@ const RealAccountCard = () => { const has_mf_mt5_account = Object.keys(current_list) .map(key => current_list[key]) - .some(account => account.landing_company_short === Jurisdiction.MALTA_INVEST); + .some(account => account.landing_company_short === 'maltainvest'); return ( { const should_resubmit_poi = () => { if ( is_from_multipliers || - open_failed_verification_for === Jurisdiction.VANUATU || - open_failed_verification_for === Jurisdiction.MALTA_INVEST + open_failed_verification_for === 'vanuatu' || + open_failed_verification_for === 'maltainvest' ) { return poi_resubmit_for_vanuatu_maltainvest; } diff --git a/packages/appstore/src/components/options-multipliers-listing/index.tsx b/packages/appstore/src/components/options-multipliers-listing/index.tsx index 4b43904c0a4d..2012d60278fc 100644 --- a/packages/appstore/src/components/options-multipliers-listing/index.tsx +++ b/packages/appstore/src/components/options-multipliers-listing/index.tsx @@ -6,7 +6,7 @@ import ListingContainer from 'Components/containers/listing-container'; import { BrandConfig } from 'Constants/platform-config'; import TradingAppCard from 'Components/containers/trading-app-card'; import { useStores } from 'Stores/index'; -import { isMobile, ContentFlag, Jurisdiction } from '@deriv/shared'; +import { isMobile, ContentFlag } from '@deriv/shared'; import PlatformLoader from 'Components/pre-loader/platform-loader'; import { getHasDivider } from 'Constants/utils'; @@ -83,7 +83,7 @@ const OptionsAndMultipliersListing = () => { if (real_account_creation_unlock_date) { setShouldShowCooldownModal(true); } else { - openRealAccountSignup(Jurisdiction.MALTA_INVEST); + openRealAccountSignup('maltainvest'); } } else { openRealAccountSignup(); diff --git a/packages/bot-skeleton/src/services/api/account-limits.js b/packages/bot-skeleton/src/services/api/account-limits.js index 009922ec0ba7..50ebafa8f07b 100644 --- a/packages/bot-skeleton/src/services/api/account-limits.js +++ b/packages/bot-skeleton/src/services/api/account-limits.js @@ -1,10 +1,8 @@ -import { Jurisdiction } from '@deriv/shared'; - export default class AccountLimits { constructor(store) { this.ws = store.ws; } - getStakePayoutLimits(currency = 'AUD', landing_company_shortcode = Jurisdiction.SVG, selected_market) { + getStakePayoutLimits(currency = 'AUD', landing_company_shortcode = 'svg', selected_market) { return this.ws .send({ landing_company_details: landing_company_shortcode, diff --git a/packages/cashier/src/pages/deposit/deposit.tsx b/packages/cashier/src/pages/deposit/deposit.tsx index 2216f2356238..5d359e169527 100644 --- a/packages/cashier/src/pages/deposit/deposit.tsx +++ b/packages/cashier/src/pages/deposit/deposit.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Loading } from '@deriv/components'; import { useDepositLocked } from '@deriv/hooks'; -import { ContentFlag, Jurisdiction } from '@deriv/shared'; +import { ContentFlag } from '@deriv/shared'; import { useStore, observer } from '@deriv/stores'; import { Real, Virtual } from '../../components/cashier-container'; import { CashierOnboarding, CashierOnboardingSideNote } from '../../components/cashier-onboarding'; @@ -55,10 +55,7 @@ const Deposit = observer(({ setSideNotes }: TDeposit) => { const is_eu = [ContentFlag.LOW_RISK_CR_EU, ContentFlag.EU_REAL].includes(content_flag); const is_fiat_currency_banner_visible_for_MF_clients = - landing_company_shortcode === Jurisdiction.MALTA_INVEST && - !is_crypto && - !can_change_fiat_currency && - !!iframe_height; + landing_company_shortcode === 'maltainvest' && !is_crypto && !can_change_fiat_currency && !!iframe_height; React.useEffect(() => { if (!is_crypto_transactions_visible) { recentTransactionOnMount(); diff --git a/packages/cashier/src/stores/__tests__/account-transfer-store.spec.ts b/packages/cashier/src/stores/__tests__/account-transfer-store.spec.ts index 08c86304ea9b..80b0a0e9afbd 100644 --- a/packages/cashier/src/stores/__tests__/account-transfer-store.spec.ts +++ b/packages/cashier/src/stores/__tests__/account-transfer-store.spec.ts @@ -1,6 +1,6 @@ import AccountTransferStore from '../account-transfer-store'; import type { TransferBetweenAccountsResponse } from '@deriv/api-types'; -import { getCurrencies, validNumber, CFD_PLATFORMS, Jurisdiction } from '@deriv/shared'; +import { getCurrencies, validNumber, CFD_PLATFORMS } from '@deriv/shared'; import { configure } from 'mobx'; import type { TTransferAccount, TRootStore, TWebSocket } from 'Types'; @@ -147,7 +147,7 @@ beforeEach(() => { is_financial_information_incomplete: true, is_logged_in: true, is_trading_experience_incomplete: true, - landing_company_shortcode: Jurisdiction.MALTA_INVEST, + landing_company_shortcode: 'maltainvest', loginid: 'CR90000103', residence: 'pl', responseMt5LoginList: jest.fn(), diff --git a/packages/cashier/src/stores/account-transfer-store.ts b/packages/cashier/src/stores/account-transfer-store.ts index 1367a7cbd186..10b6483374d1 100644 --- a/packages/cashier/src/stores/account-transfer-store.ts +++ b/packages/cashier/src/stores/account-transfer-store.ts @@ -3,7 +3,6 @@ import { formatMoney, isEmptyObject, isCryptocurrency, - Jurisdiction, getCurrencies, getCurrencyDisplayCode, getDecimalPlaces, @@ -392,8 +391,8 @@ export default class AccountTransferStore { })}`; const non_eu_accounts = account.landing_company_short && - account.landing_company_short !== Jurisdiction.SVG && - account.landing_company_short !== Jurisdiction.BVI + account.landing_company_short !== 'svg' && + account.landing_company_short !== 'bvi' ? account.landing_company_short?.charAt(0).toUpperCase() + account.landing_company_short?.slice(1) : account.landing_company_short?.toUpperCase(); diff --git a/packages/cfd/src/Components/__tests__/cfd-account-card.spec.tsx b/packages/cfd/src/Components/__tests__/cfd-account-card.spec.tsx index 0ad649c519d1..20260b408446 100644 --- a/packages/cfd/src/Components/__tests__/cfd-account-card.spec.tsx +++ b/packages/cfd/src/Components/__tests__/cfd-account-card.spec.tsx @@ -1,6 +1,5 @@ import React from 'react'; import { fireEvent, render, screen } from '@testing-library/react'; -import { Jurisdiction } from '@deriv/shared'; import { CFDAccountCard } from '../cfd-account-card'; import { TCFDAccountCard } from '../props.types'; @@ -49,7 +48,7 @@ describe('CFDAccountCard', () => { platform: 'mt5', display_balance: '10000.00', display_login: '20103240', - landing_company_short: Jurisdiction.SVG, + landing_company_short: 'svg', login: 'MTD20103240', market_type: 'financial', }; @@ -60,7 +59,7 @@ describe('CFDAccountCard', () => { platform: 'dxtrade', display_balance: '10000.00', display_login: '20103240', - landing_company_short: Jurisdiction.SVG, + landing_company_short: 'svg', login: 'MTD20103240', market_type: 'financial', }; @@ -71,7 +70,7 @@ describe('CFDAccountCard', () => { platform: 'mt5', display_balance: '10000.00', display_login: '20103240', - landing_company_short: Jurisdiction.LABUAN, + landing_company_short: 'labuan', login: 'MTD20103240', market_type: 'financial', }; diff --git a/packages/cfd/src/Components/__tests__/cfd-demo-account-display.spec.js b/packages/cfd/src/Components/__tests__/cfd-demo-account-display.spec.js index 58dbfc64606b..df99caa38f01 100644 --- a/packages/cfd/src/Components/__tests__/cfd-demo-account-display.spec.js +++ b/packages/cfd/src/Components/__tests__/cfd-demo-account-display.spec.js @@ -1,6 +1,5 @@ import { fireEvent, render, screen, within } from '@testing-library/react'; import React from 'react'; -import { Jurisdiction } from '@deriv/shared'; import { CFDDemoAccountDisplay } from '../cfd-demo-account-display'; const mock_connect_props = { @@ -46,8 +45,8 @@ describe('', () => { platform: 'mt5', residence: 'id', standpoint: { - financial_company: Jurisdiction.SVG, - gaming_company: Jurisdiction.SVG, + financial_company: 'svg', + gaming_company: 'svg', iom: false, malta: false, maltainvest: false, @@ -65,7 +64,7 @@ describe('', () => { display_login: '20103240', email: 'name@domain.com', group: 'demo\\p01_ts02\\financial\\svg_std_usd', - landing_company_short: Jurisdiction.SVG, + landing_company_short: 'svg', leverage: 1000, login: 'MTD20103240', market_type: 'financial', @@ -92,7 +91,7 @@ describe('', () => { display_balance: '10000.00', display_login: 'DXD1096', enabled: 1, - landing_company_short: Jurisdiction.SVG, + landing_company_short: 'svg', login: '374', market_type: 'synthetic', platform: 'dxtrade', @@ -156,11 +155,7 @@ describe('', () => { expect(add_demo_account_button).toBeEnabled(); fireEvent.click(add_demo_account_button); - expect(props.openAccountNeededModal).toHaveBeenCalledWith( - Jurisdiction.MALTA_INVEST, - 'Deriv Multipliers', - 'demo CFDs' - ); + expect(props.openAccountNeededModal).toHaveBeenCalledWith('maltainvest', 'Deriv Multipliers', 'demo CFDs'); }); it('should render a CFDs card only without "Add demo account" button on Deriv MT5 when is_logged_in=false & is_eu_country=true (also when redirected from Deriv X platform)', () => { diff --git a/packages/cfd/src/Components/__tests__/cfd-real-account-display.spec.js b/packages/cfd/src/Components/__tests__/cfd-real-account-display.spec.js index 42ff120bd9e0..b59eda6699ea 100644 --- a/packages/cfd/src/Components/__tests__/cfd-real-account-display.spec.js +++ b/packages/cfd/src/Components/__tests__/cfd-real-account-display.spec.js @@ -1,6 +1,5 @@ import { fireEvent, render, screen, within } from '@testing-library/react'; import React from 'react'; -import { Jurisdiction } from '@deriv/shared'; import { CFDRealAccountDisplay } from '../cfd-real-account-display'; const mock_connect_props = { @@ -52,8 +51,8 @@ describe('', () => { residence: 'id', should_enable_add_button: false, standpoint: { - financial_company: Jurisdiction.SVG, - gaming_company: Jurisdiction.SVG, + financial_company: 'svg', + gaming_company: 'svg', iom: false, malta: false, maltainvest: false, @@ -121,7 +120,7 @@ describe('', () => { legal_default_currency: 'USD', name: 'Deriv (SVG) LLC', requirements: {}, - shortcode: Jurisdiction.SVG, + shortcode: 'svg', support_professional_client: 0, }; @@ -134,7 +133,7 @@ describe('', () => { display_login: '41165492', email: 'name@domain.com', group: 'real\\p01_ts03\\synthetic\\svg_std_usd\\03', - landing_company_short: Jurisdiction.SVG, + landing_company_short: 'svg', leverage: 500, login: 'MTR41165492', market_type: 'synthetic', @@ -162,7 +161,7 @@ describe('', () => { display_login: '1927245', email: 'name@domain.com', group: 'real\\p01_ts01\\financial\\svg_std-hr_usd', - landing_company_short: Jurisdiction.SVG, + landing_company_short: 'svg', leverage: 1000, login: 'MTR1927245', market_type: 'financial', @@ -189,7 +188,7 @@ describe('', () => { display_balance: '0.00', display_login: 'DXR1095', enabled: 1, - landing_company_short: Jurisdiction.SVG, + landing_company_short: 'svg', login: '374', market_type: 'synthetic', platform: 'dxtrade', diff --git a/packages/cfd/src/Components/cfd-account-card.tsx b/packages/cfd/src/Components/cfd-account-card.tsx index 49826db48679..7d6f395d12b2 100644 --- a/packages/cfd/src/Components/cfd-account-card.tsx +++ b/packages/cfd/src/Components/cfd-account-card.tsx @@ -248,7 +248,7 @@ const CFDAccountCardComponent = ({ const checkMultipleSvgAcc = () => { const all_svg_acc: DetailsOfEachMT5Loginid[] = []; existing_accounts_data?.map(acc => { - if (acc.landing_company_short === Jurisdiction.SVG) { + if (acc.landing_company_short === 'svg') { if (all_svg_acc.length) { all_svg_acc.forEach(svg_acc => { if (svg_acc.server !== acc.server) all_svg_acc.push(acc); @@ -433,17 +433,15 @@ const CFDAccountCardComponent = ({ existing_accounts_data?.length && existing_accounts_data?.map((acc, index) => (
- {acc?.display_balance && - is_logged_in && - acc.landing_company_short === Jurisdiction.LABUAN && ( -
- -
- )} + {acc?.display_balance && is_logged_in && acc.landing_company_short === 'labuan' && ( +
+ +
+ )} {(acc as TTradingPlatformAccounts)?.display_login && (
@@ -575,7 +573,7 @@ const CFDAccountCardComponent = ({ /> {checkMultipleSvgAcc()?.length > 1 && - acc.landing_company_short === Jurisdiction.SVG && ( + acc.landing_company_short === 'svg' && ( { if (is_eu && !has_maltainvest_account && standpoint.iom) { - openAccountNeededModal(Jurisdiction.MALTA_INVEST, localize('Deriv Multipliers'), localize('demo CFDs')); + openAccountNeededModal('maltainvest', localize('Deriv Multipliers'), localize('demo CFDs')); } else { onSelectAccount({ category: 'demo', diff --git a/packages/cfd/src/Components/cfd-mt5-demo-account-display.tsx b/packages/cfd/src/Components/cfd-mt5-demo-account-display.tsx index 31c70b684018..c09558c30cb1 100644 --- a/packages/cfd/src/Components/cfd-mt5-demo-account-display.tsx +++ b/packages/cfd/src/Components/cfd-mt5-demo-account-display.tsx @@ -4,7 +4,6 @@ import { CFDAccountCard } from './cfd-account-card'; import { general_messages } from '../Constants/cfd-shared-strings'; import specifications, { TSpecifications } from '../Constants/cfd-specifications'; import Loading from '../templates/_common/components/loading'; -import { Jurisdiction } from '@deriv/shared'; import { DetailsOfEachMT5Loginid, LandingCompany } from '@deriv/api-types'; import { TTradingPlatformAccounts, TCFDPlatform } from './props.types'; import { TObjectCFDAccount } from '../Containers/cfd-dashboard'; @@ -76,7 +75,7 @@ const CFDMT5DemoAccountDisplay = ({ const openCFDAccount = () => { if (is_eu && !has_maltainvest_account && standpoint.iom) { - openAccountNeededModal(Jurisdiction.MALTA_INVEST, localize('Deriv Multipliers'), localize('demo CFDs')); + openAccountNeededModal('maltainvest', localize('Deriv Multipliers'), localize('demo CFDs')); } else { onSelectAccount({ category: 'demo', diff --git a/packages/cfd/src/Containers/__tests__/cfd-dashboard.spec.tsx b/packages/cfd/src/Containers/__tests__/cfd-dashboard.spec.tsx index ee376b4eba1f..72217e8cd065 100644 --- a/packages/cfd/src/Containers/__tests__/cfd-dashboard.spec.tsx +++ b/packages/cfd/src/Containers/__tests__/cfd-dashboard.spec.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { fireEvent, render, screen } from '@testing-library/react'; import CFDDashboard, { TCFDDashboardProps } from '../cfd-dashboard'; import { BrowserRouter } from 'react-router-dom'; -import { CFD_PLATFORMS, getCFDPlatformLabel, routes, Jurisdiction } from '@deriv/shared'; +import { CFD_PLATFORMS, getCFDPlatformLabel, routes } from '@deriv/shared'; import { DetailsOfEachMT5Loginid, LandingCompany } from '@deriv/api-types'; type TMockConnectProps = { @@ -183,8 +183,8 @@ describe('', () => { setIsAcuityModalOpen: jest.fn(), setCurrentAccount: jest.fn(), standpoint: { - financial_company: Jurisdiction.SVG, - gaming_company: Jurisdiction.SVG, + financial_company: 'svg', + gaming_company: 'svg', iom: false, malta: false, maltainvest: false, @@ -193,7 +193,7 @@ describe('', () => { toggleAccountsDialog: jest.fn(), toggleShouldShowRealAccountsList: jest.fn(), toggleResetTradingPasswordModal: jest.fn(), - upgradeable_landing_companies: [Jurisdiction.SVG], + upgradeable_landing_companies: ['svg'], }; beforeEach(() => { mock_connect_props.landing_companies = { @@ -223,7 +223,7 @@ describe('', () => { display_login: '40005073', email: 'ma+1@deriv.com', group: 'real\\p01_ts03\\synthetic\\svg_std_usd\\02', - landing_company_short: Jurisdiction.SVG, + landing_company_short: 'svg', leverage: 500, login: 'MTR40005073', market_type: 'synthetic', @@ -250,7 +250,7 @@ describe('', () => { display_login: '20104105', email: 'ma+1@deriv.com', group: 'demo\\p01_ts02\\synthetic\\svg_std_usd', - landing_company_short: Jurisdiction.SVG, + landing_company_short: 'svg', leverage: 500, login: 'MTD20104105', market_type: 'synthetic', @@ -276,7 +276,7 @@ describe('', () => { display_balance: '0.00', display_login: 'DXR1000', enabled: 1, - landing_company_short: Jurisdiction.SVG, + landing_company_short: 'svg', login: '9', market_type: 'synthetic', platform: 'dxtrade', @@ -379,7 +379,7 @@ describe('', () => { legal_default_currency: 'EUR', name: 'Deriv Investments (Europe) Limited', requirements: {}, - shortcode: Jurisdiction.MALTA_INVEST, + shortcode: 'maltainvest', support_professional_client: 1, }, }, diff --git a/packages/cfd/src/Containers/__tests__/cfd-password-modal.spec.js b/packages/cfd/src/Containers/__tests__/cfd-password-modal.spec.js index 582ab53cfcc9..9acfe73fc22a 100644 --- a/packages/cfd/src/Containers/__tests__/cfd-password-modal.spec.js +++ b/packages/cfd/src/Containers/__tests__/cfd-password-modal.spec.js @@ -1,7 +1,7 @@ import React from 'react'; import { Router } from 'react-router'; import { createBrowserHistory } from 'history'; -import { WS, validPassword, Jurisdiction } from '@deriv/shared'; +import { WS, validPassword } from '@deriv/shared'; import { render, screen, fireEvent, waitFor } from '@testing-library/react'; import CFDPasswordModal from '../cfd-password-modal'; @@ -62,7 +62,7 @@ describe('', () => { is_cfd_success_dialog_enabled: false, is_dxtrade_allowed: false, is_pre_appstore: false, - jurisdiction_selected_shortcode: Jurisdiction.SVG, + jurisdiction_selected_shortcode: 'svg', platform: 'mt5', has_cfd_error: false, landing_companies: {}, @@ -220,7 +220,7 @@ describe('', () => { account_type: { category: 'real', type: 'financial' }, is_eu: true, is_fully_authenticated: false, - jurisdiction_selected_shortcode: Jurisdiction.BVI, + jurisdiction_selected_shortcode: 'bvi', }; render( diff --git a/packages/cfd/src/Containers/derivx-trade-modal.tsx b/packages/cfd/src/Containers/derivx-trade-modal.tsx index 58d0f974fc21..328b02b7bf20 100644 --- a/packages/cfd/src/Containers/derivx-trade-modal.tsx +++ b/packages/cfd/src/Containers/derivx-trade-modal.tsx @@ -9,7 +9,6 @@ import { getCFDAccountKey, getPlatformSettings, isMobile, - Jurisdiction, } from '@deriv/shared'; import { localize, Localize } from '@deriv/translations'; import { CFDAccountCopy } from '../Components/cfd-account-copy'; @@ -139,7 +138,7 @@ const DerivXTradeModal = ({ if ( (mt5_trade_account.account_type === 'demo' && mt5_trade_account.market_type === 'financial' && - mt5_trade_account.landing_company_short === Jurisdiction.LABUAN) || + mt5_trade_account.landing_company_short === 'labuan') || mt5_trade_account.account_type === 'real' ) { return mt5_trade_account.landing_company_short; diff --git a/packages/cfd/src/Containers/dmt5-trade-modal.tsx b/packages/cfd/src/Containers/dmt5-trade-modal.tsx index fdd02e9f369b..577fc681776e 100644 --- a/packages/cfd/src/Containers/dmt5-trade-modal.tsx +++ b/packages/cfd/src/Containers/dmt5-trade-modal.tsx @@ -10,7 +10,6 @@ import { getPlatformSettings, getUrlBase, getCFDAccountKey, - Jurisdiction, } from '@deriv/shared'; import { Localize, localize } from '@deriv/translations'; import { CFDAccountCopy } from '../Components/cfd-account-copy'; @@ -100,7 +99,7 @@ const DMT5TradeModal = ({ if ( (mt5_trade_account.account_type === 'demo' && mt5_trade_account.market_type === 'financial' && - mt5_trade_account.landing_company_short === Jurisdiction.LABUAN) || + mt5_trade_account.landing_company_short === 'labuan') || mt5_trade_account.account_type === 'real' ) { return mt5_trade_account.landing_company_short; diff --git a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-content.tsx b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-content.tsx index 93a11f716c3e..5b821e002d3c 100644 --- a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-content.tsx +++ b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-content.tsx @@ -22,7 +22,7 @@ const JurisdictionModalContent = ({ : financial_available_accounts?.some(account => account.shortcode === type_of_card); const disableCard = (type_of_card: string) => { - if (is_virtual && type_of_card !== Jurisdiction.SVG) { + if (is_virtual && type_of_card !== 'svg') { return true; } return account_type === 'synthetic' diff --git a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-foot-note.tsx b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-foot-note.tsx index 96b704d67c39..4bcbcd2d61a4 100644 --- a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-foot-note.tsx +++ b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-foot-note.tsx @@ -36,7 +36,7 @@ const FooterNote = ({ ) : ( ); - } else if (jurisdiction_selected_shortcode === Jurisdiction.BVI) { + } else if (jurisdiction_selected_shortcode === 'bvi') { return ( available_account.market_type === 'financial' && (show_eu_related_content - ? available_account.shortcode === Jurisdiction.MALTA_INVEST - : available_account.shortcode !== Jurisdiction.MALTA_INVEST) + ? available_account.shortcode === 'maltainvest' + : available_account.shortcode !== 'maltainvest') ); const synthetic_available_accounts = trading_platform_available_accounts.filter( available_account => available_account.market_type === 'gaming' && (show_eu_related_content - ? available_account.shortcode === Jurisdiction.MALTA_INVEST - : available_account.shortcode !== Jurisdiction.MALTA_INVEST) + ? available_account.shortcode === 'maltainvest' + : available_account.shortcode !== 'maltainvest') ); const modal_title = show_eu_related_content diff --git a/packages/cfd/src/Containers/mt5-compare-table-content.tsx b/packages/cfd/src/Containers/mt5-compare-table-content.tsx index 397ae3c77ea8..4521e7889b41 100644 --- a/packages/cfd/src/Containers/mt5-compare-table-content.tsx +++ b/packages/cfd/src/Containers/mt5-compare-table-content.tsx @@ -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, Jurisdiction } from '@deriv/shared'; +import { isDesktop, WS, getAuthenticationStatusInfo, CFD_PLATFORMS, ContentFlag } from '@deriv/shared'; import { connect } from '../Stores/connect'; import RootStore from '../Stores/index'; import { @@ -303,13 +303,13 @@ const DMT5CompareModalContent = ({ case 'synthetic_svg': case 'financial_svg': setAppstorePlatform(CFD_PLATFORMS.MT5); - setJurisdictionSelectedShortcode(Jurisdiction.SVG); + setJurisdictionSelectedShortcode('svg'); openPasswordModal(type_of_account); break; case 'synthetic_bvi': case 'financial_bvi': setAppstorePlatform(CFD_PLATFORMS.MT5); - setJurisdictionSelectedShortcode(Jurisdiction.BVI); + setJurisdictionSelectedShortcode('bvi'); if ( poi_acknowledged_for_bvi_labuan && !poi_or_poa_not_submitted && @@ -325,7 +325,7 @@ const DMT5CompareModalContent = ({ case 'synthetic_vanuatu': case 'financial_vanuatu': setAppstorePlatform(CFD_PLATFORMS.MT5); - setJurisdictionSelectedShortcode(Jurisdiction.VANUATU); + setJurisdictionSelectedShortcode('vanuatu'); if ( poi_acknowledged_for_vanuatu_maltainvest && !poi_or_poa_not_submitted && @@ -340,7 +340,7 @@ const DMT5CompareModalContent = ({ break; case 'financial_labuan': setAppstorePlatform(CFD_PLATFORMS.MT5); - setJurisdictionSelectedShortcode(Jurisdiction.LABUAN); + setJurisdictionSelectedShortcode('labuan'); if (poi_acknowledged_for_bvi_labuan && poa_acknowledged && has_submitted_personal_details) { openPasswordModal(type_of_account); } else { @@ -349,7 +349,7 @@ const DMT5CompareModalContent = ({ break; case 'financial_maltainvest': setAppstorePlatform(CFD_PLATFORMS.MT5); - setJurisdictionSelectedShortcode(Jurisdiction.MALTA_INVEST); + setJurisdictionSelectedShortcode('maltainvest'); if ((poi_acknowledged_for_vanuatu_maltainvest && poa_acknowledged) || is_demo_tab) { openPasswordModal(type_of_account); } else { @@ -434,9 +434,9 @@ const DMT5CompareModalContent = ({ return false; } else if (item.action === 'derivx') { return false; - } else if (type === Jurisdiction.BVI && should_restrict_bvi_account_creation && poa_pending) { + } else if (type === 'bvi' && should_restrict_bvi_account_creation && poa_pending) { return true; - } else if (type === Jurisdiction.VANUATU && should_restrict_vanuatu_account_creation && poa_pending) { + } else if (type === 'vanuatu' && should_restrict_vanuatu_account_creation && poa_pending) { return true; } diff --git a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js index 121023b0baf6..29b87f03098a 100644 --- a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js +++ b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js @@ -135,8 +135,8 @@ export default class CFDStore extends BaseStore { this.root_store.client.mt5_login_list .filter(acc => show_eu_related_content - ? acc.landing_company_short === Jurisdiction.MALTA_INVEST - : acc.landing_company_short !== Jurisdiction.MALTA_INVEST + ? acc.landing_company_short === 'maltainvest' + : acc.landing_company_short !== 'maltainvest' ) .forEach(account => { // e.g. mt5.real.financial_stp @@ -233,8 +233,8 @@ export default class CFDStore extends BaseStore { this.toggleJurisdictionModal(); } else { if (this.root_store.traders_hub.show_eu_related_content) { - this.setJurisdictionSelectedShortcode(Jurisdiction.MALTA_INVEST); - } else this.setJurisdictionSelectedShortcode(Jurisdiction.SVG); + this.setJurisdictionSelectedShortcode('maltainvest'); + } else this.setJurisdictionSelectedShortcode('svg'); this.demoCFDSignup(); } } @@ -649,9 +649,9 @@ export default class CFDStore extends BaseStore { return ( financial_available_accounts.length === 1 && - financial_available_accounts.every(acc => acc.shortcode === Jurisdiction.SVG) && + financial_available_accounts.every(acc => acc.shortcode === 'svg') && synthetic_available_accounts.length === 1 && - synthetic_available_accounts.every(acc => acc.shortcode === Jurisdiction.SVG) + synthetic_available_accounts.every(acc => acc.shortcode === 'svg') ); } } diff --git a/packages/core/src/App/Components/Elements/Modals/deriv-real-account-required-modal.jsx b/packages/core/src/App/Components/Elements/Modals/deriv-real-account-required-modal.jsx index c8553e8e4886..9f556ea86c34 100644 --- a/packages/core/src/App/Components/Elements/Modals/deriv-real-account-required-modal.jsx +++ b/packages/core/src/App/Components/Elements/Modals/deriv-real-account-required-modal.jsx @@ -1,7 +1,6 @@ import PropTypes from 'prop-types'; import React from 'react'; import { Dialog } from '@deriv/components'; -import { Jurisdiction } from '@deriv/shared'; import { localize } from '@deriv/translations'; import { connect } from 'Stores/connect'; import './deriv-real-account-required-modal.scss'; @@ -18,7 +17,7 @@ const DerivRealAccountRequiredModal = ({ const createAccount = () => { if (is_eu_user) { onClose(); - openRealAccountSignup(Jurisdiction.MALTA_INVEST); + openRealAccountSignup('maltainvest'); } else { onClose(); openRealAccountSignup(); diff --git a/packages/core/src/App/Components/Layout/Footer/regulatory-information.jsx b/packages/core/src/App/Components/Layout/Footer/regulatory-information.jsx index 86fd4b64b28b..ee1e3459ecbd 100644 --- a/packages/core/src/App/Components/Layout/Footer/regulatory-information.jsx +++ b/packages/core/src/App/Components/Layout/Footer/regulatory-information.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { Icon, Modal, Popover, StaticUrl } from '@deriv/components'; import { localize, Localize } from '@deriv/translations'; -import { deriv_urls, getLegalEntityName, Jurisdiction } from '@deriv/shared'; +import { deriv_urls, getLegalEntityName } from '@deriv/shared'; import MGALogo from 'Assets/SvgComponents/footer/mga.svg'; const MLTRegulatoryInformation = () => ( @@ -84,7 +84,7 @@ const MFRegulatoryInformation = () => ( />, ]} values={{ - legal_entity_name: getLegalEntityName(Jurisdiction.MALTA_INVEST), + legal_entity_name: getLegalEntityName('maltainvest'), }} />

@@ -96,7 +96,7 @@ export const RegulatoryInformation = ({ landing_company, is_eu, show_eu_related_ if (!is_eu || (is_eu && !show_eu_related_content)) return null; const is_mx = landing_company === 'iom'; const is_mlt = landing_company === 'malta'; - const is_mf = landing_company === Jurisdiction.MALTA_INVEST; + const is_mf = landing_company === 'maltainvest'; return (
diff --git a/packages/core/src/App/Components/Layout/Header/toggle-menu-drawer.jsx b/packages/core/src/App/Components/Layout/Header/toggle-menu-drawer.jsx index 95ea906f7d7a..f74d781c7731 100644 --- a/packages/core/src/App/Components/Layout/Header/toggle-menu-drawer.jsx +++ b/packages/core/src/App/Components/Layout/Header/toggle-menu-drawer.jsx @@ -2,7 +2,7 @@ import classNames from 'classnames'; import React from 'react'; import { Div100vhContainer, Icon, MobileDrawer, ToggleSwitch, Text, Button } from '@deriv/components'; import { useOnrampVisible, useAccountTransferVisible } from '@deriv/hooks'; -import { routes, PlatformContext, getStaticUrl, whatsapp_url, ContentFlag, Jurisdiction } from '@deriv/shared'; +import { routes, PlatformContext, getStaticUrl, whatsapp_url, ContentFlag } from '@deriv/shared'; import { observer, useStore } from '@deriv/stores'; import { localize, getAllowedLanguages, getLanguage } from '@deriv/translations'; import NetworkStatus from 'App/Components/Layout/Footer'; @@ -260,9 +260,9 @@ const ToggleMenuDrawer = observer(({ platform_config }) => { const disableRoute = route_path => { if (/financial-assessment/.test(route_path)) { - return is_virtual || (active_account_landing_company === Jurisdiction.MALTA_INVEST && !is_risky_client); + return is_virtual || (active_account_landing_company === 'maltainvest' && !is_risky_client); } else if (/trading-assessment/.test(route_path)) { - return is_virtual || active_account_landing_company !== Jurisdiction.MALTA_INVEST; + return is_virtual || active_account_landing_company !== 'maltainvest'; } else if (/proof-of-address/.test(route_path) || /proof-of-identity/.test(route_path)) { return !should_allow_authentication; } else if (/proof-of-ownership/.test(route_path)) { diff --git a/packages/core/src/App/Containers/AccountSwitcher/account-switcher-account-list.jsx b/packages/core/src/App/Containers/AccountSwitcher/account-switcher-account-list.jsx index 6376b5e7ac27..ffc6abc60afb 100644 --- a/packages/core/src/App/Containers/AccountSwitcher/account-switcher-account-list.jsx +++ b/packages/core/src/App/Containers/AccountSwitcher/account-switcher-account-list.jsx @@ -1,14 +1,7 @@ import classNames from 'classnames'; import React from 'react'; import { Icon, Money, Button, Text } from '@deriv/components'; -import { - formatMoney, - getCurrencyName, - getCFDAccountDisplay, - getCurrencyDisplayCode, - isBot, - Jurisdiction, -} from '@deriv/shared'; +import { formatMoney, getCurrencyName, getCFDAccountDisplay, getCurrencyDisplayCode, isBot } from '@deriv/shared'; import { Localize, localize } from '@deriv/translations'; const AccountList = ({ @@ -185,7 +178,7 @@ const AccountDisplay = ({ {server?.server_info?.geolocation && should_show_server_name && market_type === 'synthetic' && - shortcode === Jurisdiction.SVG && ( + shortcode === 'svg' && ( {getServerName(server)} @@ -201,7 +194,7 @@ const AccountDisplay = ({ {server?.server_info?.geolocation && should_show_server_name && market_type === 'synthetic' && - shortcode === Jurisdiction.SVG && ( + shortcode === 'svg' && ( { account => !account.is_virtual && account.loginid.startsWith('CR') ); setFilteredRealAccounts(real_accounts); - const remaining_real_accounts = getRemainingRealAccounts().filter(account => account === Jurisdiction.SVG); + const remaining_real_accounts = getRemainingRealAccounts().filter(account => account === 'svg'); setFilteredRemainingRealAccounts(remaining_real_accounts); } else if (props.is_eu) { const real_accounts = getSortedAccountList(props.account_list, props.accounts).filter( account => !account.is_virtual && account.loginid.startsWith('MF') ); setFilteredRealAccounts(real_accounts); - const remaining_real_accounts = getRemainingRealAccounts().filter( - account => account === Jurisdiction.MALTA_INVEST - ); + const remaining_real_accounts = getRemainingRealAccounts().filter(account => account === 'maltainvest'); setFilteredRemainingRealAccounts(remaining_real_accounts); } }, []); @@ -225,11 +222,7 @@ const AccountSwitcher = props => { const openMt5DemoAccount = account_type => { if (props.show_eu_related_content && !props.has_maltainvest_account && props.standpoint.iom) { closeAccountsDialog(); - props.openAccountNeededModal( - Jurisdiction.MALTA_INVEST, - localize('Deriv Multipliers'), - localize('demo CFDs') - ); + props.openAccountNeededModal('maltainvest', localize('Deriv Multipliers'), localize('demo CFDs')); return; } sessionStorage.setItem('open_cfd_account_type', `demo.${CFD_PLATFORMS.MT5}.${account_type}`); @@ -380,7 +373,7 @@ const AccountSwitcher = props => { const low_risk_non_eu = props.content_flag === ContentFlag.LOW_RISK_CR_NON_EU; if (low_risk_non_eu) { return getSortedCFDList(props.mt5_login_list).filter( - account => !isDemo(account) && account.landing_company_short !== Jurisdiction.MALTA_INVEST + account => !isDemo(account) && account.landing_company_short !== 'maltainvest' ); } return getSortedCFDList(props.mt5_login_list).filter(account => !isDemo(account)); @@ -566,7 +559,7 @@ const AccountSwitcher = props => { const checkMultipleSvgAcc = () => { const all_svg_acc = []; getRealMT5().map(acc => { - if (acc.landing_company_short === Jurisdiction.SVG && acc.market_type === 'synthetic') { + if (acc.landing_company_short === 'svg' && acc.market_type === 'synthetic') { if (all_svg_acc.length) { all_svg_acc.forEach(svg_acc => { if (svg_acc.server !== acc.server) all_svg_acc.push(acc); @@ -685,7 +678,7 @@ const AccountSwitcher = props => { platform={CFD_PLATFORMS.MT5} shortcode={ account.market_type === 'financial' && - account.landing_company_short === Jurisdiction.LABUAN && + account.landing_company_short === 'labuan' && account.landing_company_short } /> @@ -1125,7 +1118,7 @@ const AccountSwitcher = props => {
{!has_cr_account && getRemainingRealAccounts() - .filter(account => account === Jurisdiction.SVG) + .filter(account => account === 'svg') .map((account, index) => (
@@ -1197,7 +1190,7 @@ const AccountSwitcher = props => { })}
{getRemainingRealAccounts() - .filter(account => account === Jurisdiction.MALTA_INVEST) + .filter(account => account === 'maltainvest') .map((account, index) => { return (
diff --git a/packages/core/src/App/Containers/Modals/app-modals.jsx b/packages/core/src/App/Containers/Modals/app-modals.jsx index 973461ce9e42..29d8f7c47553 100644 --- a/packages/core/src/App/Containers/Modals/app-modals.jsx +++ b/packages/core/src/App/Containers/Modals/app-modals.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { useLocation } from 'react-router-dom'; -import { ContentFlag, moduleLoader, Jurisdiction } from '@deriv/shared'; +import { ContentFlag, moduleLoader } from '@deriv/shared'; import { connect } from 'Stores/connect'; import MT5AccountNeededModal from 'App/Components/Elements/Modals/mt5-account-needed-modal.jsx'; import RedirectNoticeModal from 'App/Components/Elements/Modals/RedirectNotice'; @@ -125,7 +125,7 @@ const AppModals = ({ if ( is_logged_in && - active_account_landing_company === Jurisdiction.MALTA_INVEST && + active_account_landing_company === 'maltainvest' && !is_trading_assessment_for_new_user_enabled && is_trading_experience_incomplete && content_flag !== ContentFlag.LOW_RISK_CR_EU && diff --git a/packages/core/src/App/Containers/Modals/exit-traders-hub-modal/exit-traders-hub-modal.jsx b/packages/core/src/App/Containers/Modals/exit-traders-hub-modal/exit-traders-hub-modal.jsx index ddecdb089a2d..f5e42ce4125b 100644 --- a/packages/core/src/App/Containers/Modals/exit-traders-hub-modal/exit-traders-hub-modal.jsx +++ b/packages/core/src/App/Containers/Modals/exit-traders-hub-modal/exit-traders-hub-modal.jsx @@ -4,7 +4,6 @@ import { connect } from 'Stores/connect'; import { Button, DesktopWrapper, MobileDialog, MobileWrapper, Modal, Text, UILoader } from '@deriv/components'; import { isMobile, routes, ContentFlag } from '@deriv/shared'; import { localize } from '@deriv/translations'; -import { Jurisdiction } from '@deriv/shared/src/utils/constants/jurisdiction'; const ExitTradersHubModal = ({ disableApp, @@ -47,7 +46,7 @@ const ExitTradersHubModal = ({ const onClickExitButton = async () => { setIsPreAppStore(false); setIsLoggingIn(true); - const cr_account = active_accounts.some(acc => acc.landing_company_shortcode === Jurisdiction.SVG); + const cr_account = active_accounts.some(acc => acc.landing_company_shortcode === 'svg'); toggleExitTradersHubModal(); if (content_flag === ContentFlag.LOW_RISK_CR_EU || content_flag === ContentFlag.LOW_RISK_CR_NON_EU) { diff --git a/packages/core/src/App/Containers/Modals/ready-to-deposit-modal/ready-to-deposit-modal.tsx b/packages/core/src/App/Containers/Modals/ready-to-deposit-modal/ready-to-deposit-modal.tsx index b7c65e4df42d..51defc4af8fe 100644 --- a/packages/core/src/App/Containers/Modals/ready-to-deposit-modal/ready-to-deposit-modal.tsx +++ b/packages/core/src/App/Containers/Modals/ready-to-deposit-modal/ready-to-deposit-modal.tsx @@ -2,7 +2,6 @@ import React from 'react'; import { Dialog } from '@deriv/components'; import { localize } from '@deriv/translations'; import { useStore, observer } from '@deriv/stores'; -import { Jurisdiction } from '@deriv/shared'; import './ready-to-deposit-modal.scss'; const ReadyToDepositModal = observer(() => { @@ -18,7 +17,7 @@ const ReadyToDepositModal = observer(() => { const createAccount = () => { onClose(); - return is_eu_user ? openRealAccountSignup(Jurisdiction.MALTA_INVEST) : openRealAccountSignup(); + return is_eu_user ? openRealAccountSignup('maltainvest') : openRealAccountSignup(); }; return ( diff --git a/packages/core/src/App/Containers/RealAccountSignup/account-wizard-form.js b/packages/core/src/App/Containers/RealAccountSignup/account-wizard-form.js index a934e3a701ee..dc473cb2881f 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/account-wizard-form.js +++ b/packages/core/src/App/Containers/RealAccountSignup/account-wizard-form.js @@ -10,18 +10,18 @@ import { proofOfIdentityConfig, ProofOfIdentityFormOnSignup, } from '@deriv/account'; -import { Jurisdiction } from '@deriv/shared'; + import AddressDetails from './address-details.jsx'; import CurrencySelector from './currency-selector.jsx'; -const isMaltaAccount = ({ real_account_signup_target }) => real_account_signup_target === Jurisdiction.MALTA_INVEST; +const isMaltaAccount = ({ real_account_signup_target }) => real_account_signup_target === 'maltainvest'; const shouldShowPersonalAndAddressDetailsAndCurrency = ({ real_account_signup_target }) => real_account_signup_target !== 'samoa'; const shouldShowIdentityInformation = ({ account_settings, residence, residence_list, real_account_signup_target }) => { const citizen = account_settings.citizen || residence; const country = residence_list.find(item => item.value === citizen); - const maltainvest = real_account_signup_target === Jurisdiction.MALTA_INVEST; + const maltainvest = real_account_signup_target === 'maltainvest'; return !maltainvest && citizen && country?.identity?.services?.idv?.is_country_supported; }; diff --git a/packages/core/src/App/Containers/RealAccountSignup/account-wizard.jsx b/packages/core/src/App/Containers/RealAccountSignup/account-wizard.jsx index 04d1d53200cc..6136bffcd12f 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/account-wizard.jsx +++ b/packages/core/src/App/Containers/RealAccountSignup/account-wizard.jsx @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import fromEntries from 'object.fromentries'; import React from 'react'; import { DesktopWrapper, MobileWrapper, FormProgress, Wizard, Text } from '@deriv/components'; -import { toMoment, getLocation, makeCancellablePromise, WS, Jurisdiction } from '@deriv/shared'; +import { toMoment, getLocation, makeCancellablePromise, WS } from '@deriv/shared'; import { Localize } from '@deriv/translations'; import { connect } from 'Stores/connect'; import LoadingModal from './real-account-signup-loader.jsx'; @@ -255,7 +255,7 @@ const AccountWizard = props => { submitForm(payload) .then(response => { props.setIsRiskWarningVisible(false); - if (props.real_account_signup_target === Jurisdiction.MALTA_INVEST) { + if (props.real_account_signup_target === 'maltainvest') { props.onFinishSuccess(response.new_account_maltainvest.currency.toLowerCase()); } else if (props.real_account_signup_target === 'samoa') { props.onOpenWelcomeModal(response.new_account_samoa.currency.toLowerCase()); diff --git a/packages/core/src/App/Containers/RealAccountSignup/helpers/constants.js b/packages/core/src/App/Containers/RealAccountSignup/helpers/constants.js index 07d46bcdaaee..2698426b6650 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/helpers/constants.js +++ b/packages/core/src/App/Containers/RealAccountSignup/helpers/constants.js @@ -1,5 +1,4 @@ import { localize } from '@deriv/translations'; -import { Jurisdiction } from '@deriv/shared'; /** * Experian result is defined by client's information validity. @@ -35,7 +34,7 @@ export const getAccountTitle = (landing_company_shortcode, { account_residence = } switch (landing_company_shortcode) { - case Jurisdiction.SVG: + case 'svg': return localize('Options & Multipliers'); case 'iom': if (country_standpoint.is_united_kingdom) { @@ -51,7 +50,7 @@ export const getAccountTitle = (landing_company_shortcode, { account_residence = return localize('Options'); } return localize('Derived'); - case Jurisdiction.MALTA_INVEST: + case 'maltainvest': return localize('Multipliers'); default: return localize('Deriv'); @@ -82,7 +81,7 @@ export const getExperianResult = status => { return EXPERIAN.DANGER; }; - if (landing_company_shortcode === Jurisdiction.SVG || is_isle_of_man_residence || is_belgium_residence) + if (landing_company_shortcode === 'svg' || is_isle_of_man_residence || is_belgium_residence) return EXPERIAN.SUCCESS; if (landing_company_shortcode === 'iom') return getIOMStatus({ is_fully_authenticated, is_age_verified }); diff --git a/packages/core/src/App/Containers/RealAccountSignup/helpers/dialog-buttons.jsx b/packages/core/src/App/Containers/RealAccountSignup/helpers/dialog-buttons.jsx index 6d6a8caa7d83..2e2d0a01de9d 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/helpers/dialog-buttons.jsx +++ b/packages/core/src/App/Containers/RealAccountSignup/helpers/dialog-buttons.jsx @@ -2,7 +2,6 @@ import PropTypes from 'prop-types'; import React from 'react'; import { Button } from '@deriv/components'; import { localize } from '@deriv/translations'; -import { Jurisdiction } from '@deriv/shared'; import { EXPERIAN } from './constants'; const getDismissButton = ({ status, landing_company_shortcode, closeModal, switchToVirtual }) => { @@ -67,7 +66,7 @@ const getActionButton = ({ label: localize('Deposit'), action: closeModalAndOpenCashier, }; - case Jurisdiction.MALTA_INVEST: + case 'maltainvest': if (is_fully_authenticated) { return { label: localize('Deposit'), @@ -78,7 +77,7 @@ const getActionButton = ({ label: localize('Submit proof'), action: closeModalAndOpenPOI, }; - case Jurisdiction.SVG: + case 'svg': case 'malta': default: return { diff --git a/packages/core/src/App/Containers/RealAccountSignup/helpers/dialog-message.jsx b/packages/core/src/App/Containers/RealAccountSignup/helpers/dialog-message.jsx index dec92b7fa87f..db56d3fbad5b 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/helpers/dialog-message.jsx +++ b/packages/core/src/App/Containers/RealAccountSignup/helpers/dialog-message.jsx @@ -2,7 +2,6 @@ import PropTypes from 'prop-types'; import React from 'react'; import { Text } from '@deriv/components'; import { Localize } from '@deriv/translations'; -import { Jurisdiction } from '@deriv/shared'; import { EXPERIAN } from './constants'; /** @@ -17,7 +16,7 @@ export const DialogMessage = ({ status = EXPERIAN.SUCCESS, }) => { let message = ''; - if (landing_company_shortcode === Jurisdiction.MALTA_INVEST) { + if (landing_company_shortcode === 'maltainvest') { if (is_fully_authenticated) { message = [ , diff --git a/packages/core/src/App/Containers/RealAccountSignup/proof-of-address-form.js b/packages/core/src/App/Containers/RealAccountSignup/proof-of-address-form.js index b28366db3dbf..68ec96526756 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/proof-of-address-form.js +++ b/packages/core/src/App/Containers/RealAccountSignup/proof-of-address-form.js @@ -1,10 +1,10 @@ import { localize } from '@deriv/translations'; import { ProofOfAddressContainer } from '@deriv/account'; -import { generateValidationFunction, getDefaultFields, Jurisdiction } from '@deriv/shared'; +import { generateValidationFunction, getDefaultFields } from '@deriv/shared'; const proof_of_address_config = { poi_state: { - supported_in: [Jurisdiction.MALTA_INVEST, 'malta', Jurisdiction.SVG, 'iom'], + supported_in: ['maltainvest', 'malta', 'svg', 'iom'], default_value: '', rules: [], }, diff --git a/packages/core/src/App/Containers/RealAccountSignup/proof-of-identity-form.js b/packages/core/src/App/Containers/RealAccountSignup/proof-of-identity-form.js index 66d09da7900c..51d7ca43fe00 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/proof-of-identity-form.js +++ b/packages/core/src/App/Containers/RealAccountSignup/proof-of-identity-form.js @@ -1,10 +1,10 @@ import { localize } from '@deriv/translations'; -import { generateValidationFunction, getDefaultFields, Jurisdiction } from '@deriv/shared'; +import { generateValidationFunction, getDefaultFields } from '@deriv/shared'; import ProofOfIdentityForm from './proof-of-identity.jsx'; const proof_of_identity_config = { poi_state: { - supported_in: [Jurisdiction.MALTA_INVEST, 'malta', Jurisdiction.SVG, 'iom'], + supported_in: ['maltainvest', 'malta', 'svg', 'iom'], default_value: '', rules: [], }, diff --git a/packages/core/src/App/Containers/RealAccountSignup/real-account-signup.jsx b/packages/core/src/App/Containers/RealAccountSignup/real-account-signup.jsx index eac393e33d66..acf73bfab732 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/real-account-signup.jsx +++ b/packages/core/src/App/Containers/RealAccountSignup/real-account-signup.jsx @@ -3,7 +3,7 @@ import classNames from 'classnames'; import React from 'react'; import { withRouter } from 'react-router-dom'; import { Button, Text, Modal, DesktopWrapper, MobileDialog, MobileWrapper } from '@deriv/components'; -import { routes, Jurisdiction } from '@deriv/shared'; +import { routes } from '@deriv/shared'; import { RiskToleranceWarningModal, TestWarningModal } from '@deriv/account'; import { localize, Localize } from '@deriv/translations'; import { connect } from 'Stores/connect'; @@ -38,7 +38,7 @@ const WizardHeading = ({ is_pre_appstore, real_account_signup_target, }) => { - const maltainvest_signup = real_account_signup_target === Jurisdiction.MALTA_INVEST; + const maltainvest_signup = real_account_signup_target === 'maltainvest'; const iom_signup = real_account_signup_target === 'iom'; const deposit_cash_signup = real_account_signup_target === 'deposit_cash'; @@ -74,7 +74,7 @@ const WizardHeading = ({ return ; } return ; - case Jurisdiction.MALTA_INVEST: + case 'maltainvest': if ( country_standpoint.is_united_kingdom || country_standpoint.is_france || @@ -425,7 +425,7 @@ const RealAccountSignup = ({ active_modal_index_no = modal_pages_indices.add_or_manage_account; } else { active_modal_index_no = - !currency && real_account_signup_target !== Jurisdiction.MALTA_INVEST + !currency && real_account_signup_target !== 'maltainvest' ? modal_pages_indices.set_currency : modal_pages_indices.account_wizard; } @@ -449,7 +449,7 @@ const RealAccountSignup = ({ try { setShouldShowAppropriatenessWarningModal(false); const response = await realAccountSignup({ ...real_account_form_data, accept_risk: 1 }); - if (real_account_signup_target === Jurisdiction.MALTA_INVEST) { + if (real_account_signup_target === 'maltainvest') { showStatusDialog(response.new_account_maltainvest.currency.toLowerCase()); } } catch (sign_up_error) { diff --git a/packages/core/src/App/Containers/WelcomeModal/welcome-modal.jsx b/packages/core/src/App/Containers/WelcomeModal/welcome-modal.jsx index eb45a657a697..e82c713789ee 100644 --- a/packages/core/src/App/Containers/WelcomeModal/welcome-modal.jsx +++ b/packages/core/src/App/Containers/WelcomeModal/welcome-modal.jsx @@ -1,6 +1,5 @@ import React from 'react'; import { connect } from 'Stores/connect'; -import { Jurisdiction } from '@deriv/shared'; import WelcomeModal1 from './welcome-modal-1.jsx'; import WelcomeModal2 from './welcome-modal-2.jsx'; @@ -8,7 +7,7 @@ const WelcomeModal = ({ is_eu, landing_companies, residence }) => { const is_excluded_from_cr_onboarding = ['au', 'sg', 'no'].includes(residence); const shortcode = landing_companies?.financial_company?.shortcode || landing_companies?.gaming_company?.shortcode; - if ((shortcode === Jurisdiction.SVG && !is_excluded_from_cr_onboarding) || is_eu) { + if ((shortcode === 'svg' && !is_excluded_from_cr_onboarding) || is_eu) { return ; } diff --git a/packages/core/src/App/Containers/app-notification-messages.jsx b/packages/core/src/App/Containers/app-notification-messages.jsx index 1a0703934ef0..f6561918d753 100644 --- a/packages/core/src/App/Containers/app-notification-messages.jsx +++ b/packages/core/src/App/Containers/app-notification-messages.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import ReactDOM from 'react-dom'; import { TransitionGroup, CSSTransition } from 'react-transition-group'; -import { isMobile, getPathname, getPlatformSettings, routes, Jurisdiction } from '@deriv/shared'; +import { isMobile, getPathname, getPlatformSettings, routes } from '@deriv/shared'; import { connect } from 'Stores/connect'; import { excluded_notifications } from '../../Stores/Helpers/client-notifications'; import Notification, { @@ -149,7 +149,7 @@ const AppNotificationMessages = ({ const notifications_limit = isMobile() ? max_display_notifications_mobile : max_display_notifications; //TODO (yauheni-kryzhyk): showing pop-up only for specific messages. the rest of notifications are hidden. this logic should be changed in the upcoming new pop-up notifications implementation const filtered_excluded_notifications = notifications.filter(message => - message.key.includes(Jurisdiction.SVG) || message.key.includes('p2p_daily_limit_increase') + message.key.includes('svg') || message.key.includes('p2p_daily_limit_increase') ? message : excluded_notifications.includes(message.key) ); diff --git a/packages/core/src/Modules/ComplaintsPolicy/Components/complaints-policy-content.jsx b/packages/core/src/Modules/ComplaintsPolicy/Components/complaints-policy-content.jsx index d95dd0dda02d..d3e985a301c7 100644 --- a/packages/core/src/Modules/ComplaintsPolicy/Components/complaints-policy-content.jsx +++ b/packages/core/src/Modules/ComplaintsPolicy/Components/complaints-policy-content.jsx @@ -1,14 +1,14 @@ import React from 'react'; import { localize, Localize } from '@deriv/translations'; -import { getLegalEntityName, Jurisdiction } from '@deriv/shared'; +import { getLegalEntityName } from '@deriv/shared'; import { connect } from 'Stores/connect'; import 'Sass/app/modules/complaints-policy.scss'; const getIntroductionText = (landing_company_shortcode, mt5_login_list) => { // * mt5_login_list returns these: // landing_company_short: "svg" | "malta" | "maltainvest" | "vanuatu" | "labuan" | "bvi" - const has_vanuatu = mt5_login_list.some(item => item.landing_company_short === Jurisdiction.VANUATU); - const has_labuan = mt5_login_list.some(item => item.landing_company_short === Jurisdiction.LABUAN); + const has_vanuatu = mt5_login_list.some(item => item.landing_company_short === 'vanuatu'); + const has_labuan = mt5_login_list.some(item => item.landing_company_short === 'labuan'); switch (landing_company_shortcode) { case 'iom': @@ -21,11 +21,11 @@ const getIntroductionText = (landing_company_shortcode, mt5_login_list) => { }} /> ); - case Jurisdiction.MALTA_INVEST: + case 'maltainvest': return localize( 'This complaints policy, which may change from time to time, applies to your account registered with {{legal_entity_name}}.', { - legal_entity_name: getLegalEntityName(Jurisdiction.MALTA_INVEST), + legal_entity_name: getLegalEntityName('maltainvest'), } ); case 'malta': @@ -43,7 +43,7 @@ const getIntroductionText = (landing_company_shortcode, mt5_login_list) => { return localize( 'This complaints policy, which may change from time to time, applies to your account(s) registered with {{legal_entity_name_svg}}, {{legal_entity_name_fx}}, and {{legal_entity_name_v}}.', { - legal_entity_name_svg: getLegalEntityName(Jurisdiction.SVG), + legal_entity_name_svg: getLegalEntityName('svg'), legal_entity_name_fx: getLegalEntityName('fx'), legal_entity_name_v: getLegalEntityName('v'), } @@ -52,7 +52,7 @@ const getIntroductionText = (landing_company_shortcode, mt5_login_list) => { return localize( 'This complaints policy, which may change from time to time, applies to your account(s) registered with {{legal_entity_name_svg}} and {{legal_entity_name_v}}.', { - legal_entity_name_svg: getLegalEntityName(Jurisdiction.SVG), + legal_entity_name_svg: getLegalEntityName('svg'), legal_entity_name_v: getLegalEntityName('v'), } ); @@ -60,7 +60,7 @@ const getIntroductionText = (landing_company_shortcode, mt5_login_list) => { return localize( 'This complaints policy, which may change from time to time, applies to your account(s) registered with {{legal_entity_name_svg}} and {{legal_entity_name_fx}}.', { - legal_entity_name_svg: getLegalEntityName(Jurisdiction.SVG), + legal_entity_name_svg: getLegalEntityName('svg'), legal_entity_name_fx: getLegalEntityName('fx'), } ); @@ -68,7 +68,7 @@ const getIntroductionText = (landing_company_shortcode, mt5_login_list) => { return localize( 'This complaints policy, which may change from time to time, applies to your account(s) registered with {{legal_entity_name_svg}}.', { - legal_entity_name_svg: getLegalEntityName(Jurisdiction.SVG), + legal_entity_name_svg: getLegalEntityName('svg'), } ); } @@ -174,7 +174,7 @@ const getYourDecisionText = (is_uk, landing_company_shortcode) => { ]} /> ); - if (landing_company_shortcode === Jurisdiction.MALTA_INVEST) { + if (landing_company_shortcode === 'maltainvest') { texts.push( acc.landing_company_shortcode === Jurisdiction.MALTA_INVEST); + return this.active_accounts.some(acc => acc.landing_company_shortcode === 'maltainvest'); } get has_malta_account() { @@ -516,7 +515,7 @@ export default class ClientStore extends BaseStore { get first_switchable_real_loginid() { const result = this.active_accounts.find( - acc => acc.is_virtual === 0 && acc.landing_company_shortcode === Jurisdiction.SVG + acc => acc.is_virtual === 0 && acc.landing_company_shortcode === 'svg' ); return result.loginid || undefined; } @@ -554,8 +553,7 @@ export default class ClientStore extends BaseStore { ) { return this.current_landing_company.legal_allowed_currencies; } - const target = - this.root_store.ui.real_account_signup_target === Jurisdiction.MALTA_INVEST ? 'financial' : 'gaming'; + const target = this.root_store.ui.real_account_signup_target === 'maltainvest' ? 'financial' : 'gaming'; if (this.landing_companies[`${target}_company`]) { return this.landing_companies[`${target}_company`].legal_allowed_currencies; @@ -842,13 +840,13 @@ export default class ClientStore extends BaseStore { get should_restrict_bvi_account_creation() { return !!this.mt5_login_list.filter( - item => item?.landing_company_short === Jurisdiction.BVI && item?.status === 'poa_failed' + item => item?.landing_company_short === 'bvi' && item?.status === 'poa_failed' ).length; } get should_restrict_vanuatu_account_creation() { return !!this.mt5_login_list.filter( - item => item?.landing_company_short === Jurisdiction.VANUATU && item?.status === 'poa_failed' + item => item?.landing_company_short === 'vanuatu' && item?.status === 'poa_failed' ).length; } @@ -862,11 +860,11 @@ export default class ClientStore extends BaseStore { const financial_shortcode = financial_company?.shortcode; const gaming_shortcode = gaming_company?.shortcode; const mt_gaming_shortcode = mt_gaming_company?.financial.shortcode || mt_gaming_company?.swap_free.shortcode; - const is_current_mf = this.landing_company_shortcode === Jurisdiction.MALTA_INVEST; + const is_current_mf = this.landing_company_shortcode === 'maltainvest'; return ( is_current_mf || //is_currently logged in mf account via trdaershub (financial_shortcode || gaming_shortcode || mt_gaming_shortcode - ? (eu_shortcode_regex.test(financial_shortcode) && gaming_shortcode !== Jurisdiction.SVG) || + ? (eu_shortcode_regex.test(financial_shortcode) && gaming_shortcode !== 'svg') || eu_shortcode_regex.test(gaming_shortcode) : eu_excluded_regex.test(this.residence)) ); @@ -1017,8 +1015,8 @@ export default class ClientStore extends BaseStore { this.trading_platform_available_accounts.some( account => (market_type === 'synthetic' ? 'gaming' : 'financial') === account.market_type && - account.shortcode === Jurisdiction.SVG - ) && existing_demo_accounts.every(account => !(account.landing_company_short === Jurisdiction.SVG)) + account.shortcode === 'svg' + ) && existing_demo_accounts.every(account => !(account.landing_company_short === 'svg')) ); } @@ -1030,7 +1028,7 @@ export default class ClientStore extends BaseStore { .filter( account => (market_type === 'synthetic' ? 'gaming' : 'financial') === account.market_type && - account.shortcode !== Jurisdiction.MALTA_INVEST + account.shortcode !== 'maltainvest' ) .map(account => account.shortcode); @@ -1074,7 +1072,7 @@ export default class ClientStore extends BaseStore { isBotAllowed = () => { // Stop showing Bot, DBot, DSmartTrader for logged out EU IPs if (!this.is_logged_in && this.is_eu_country) return false; - const is_mf = this.landing_company_shortcode === Jurisdiction.MALTA_INVEST; + const is_mf = this.landing_company_shortcode === 'maltainvest'; return this.is_virtual ? this.is_eu_or_multipliers_only : !is_mf && !this.is_options_blocked; }; @@ -1133,9 +1131,9 @@ export default class ClientStore extends BaseStore { landing_company !== this.accounts[this.loginid].landing_company_shortcode && upgradeable_landing_companies.indexOf(landing_company) !== -1 ); - can_upgrade_to = canUpgrade(Jurisdiction.SVG, 'iom', 'malta', Jurisdiction.MALTA_INVEST); + can_upgrade_to = canUpgrade('svg', 'iom', 'malta', 'maltainvest'); if (can_upgrade_to) { - type = can_upgrade_to === Jurisdiction.MALTA_INVEST ? 'financial' : 'real'; + type = can_upgrade_to === 'maltainvest' ? 'financial' : 'real'; } } @@ -1351,7 +1349,7 @@ export default class ClientStore extends BaseStore { async realAccountSignup(form_values) { const DEFAULT_CRYPTO_ACCOUNT_CURRENCY = 'BTC'; - const is_maltainvest_account = this.root_store.ui.real_account_signup_target === Jurisdiction.MALTA_INVEST; + const is_maltainvest_account = this.root_store.ui.real_account_signup_target === 'maltainvest'; const is_samoa_account = this.root_store.ui.real_account_signup_target === 'samoa'; let currency = ''; form_values.residence = this.residence; @@ -1647,7 +1645,7 @@ export default class ClientStore extends BaseStore { if (!this.is_virtual) { this.setPrevRealAccountLoginid(this.loginid); } - const no_cr_account = this.active_accounts.some(acc => acc.landing_company_shortcode === Jurisdiction.SVG); + const no_cr_account = this.active_accounts.some(acc => acc.landing_company_shortcode === 'svg'); if (!no_cr_account && this.is_low_risk) { this.switchAccount(this.virtual_account_loginid); @@ -2555,24 +2553,21 @@ export default class ClientStore extends BaseStore { // This is a conditional check for countries like Australia/Norway which fulfil one of these following conditions. const restricted_countries = - financial_company?.shortcode === Jurisdiction.SVG || - (gaming_company?.shortcode === Jurisdiction.SVG && - financial_company?.shortcode !== Jurisdiction.MALTA_INVEST); + financial_company?.shortcode === 'svg' || + (gaming_company?.shortcode === 'svg' && financial_company?.shortcode !== 'maltainvest'); - const high_risk_landing_company = - financial_company?.shortcode === Jurisdiction.SVG && gaming_company?.shortcode === Jurisdiction.SVG; + const high_risk_landing_company = financial_company?.shortcode === 'svg' && gaming_company?.shortcode === 'svg'; return high_risk_landing_company || this.account_status.risk_classification === 'high' || restricted_countries; } get is_low_risk() { const { gaming_company, financial_company } = this.landing_companies; const low_risk_landing_company = - financial_company?.shortcode === Jurisdiction.MALTA_INVEST && - gaming_company?.shortcode === Jurisdiction.SVG; + financial_company?.shortcode === 'maltainvest' && gaming_company?.shortcode === 'svg'; return ( low_risk_landing_company || - (this.upgradeable_landing_companies?.includes(Jurisdiction.SVG) && - this.upgradeable_landing_companies?.includes(Jurisdiction.MALTA_INVEST)) + (this.upgradeable_landing_companies?.includes('svg') && + this.upgradeable_landing_companies?.includes('maltainvest')) ); } diff --git a/packages/core/src/Stores/notification-store.js b/packages/core/src/Stores/notification-store.js index 57181614e998..3627f50835c8 100644 --- a/packages/core/src/Stores/notification-store.js +++ b/packages/core/src/Stores/notification-store.js @@ -16,7 +16,6 @@ import { platform_name, routes, unique, - Jurisdiction, } from '@deriv/shared'; import { localize, Localize } from '@deriv/translations'; import { BinaryLink } from 'App/Components/Routes'; @@ -182,7 +181,7 @@ export default class NotificationStore extends BaseStore { this.notification_messages = [...this.notification_messages, notification].sort(sortFn); if ( - (notification.key && notification.key.includes(Jurisdiction.SVG)) || + (notification.key && notification.key.includes('svg')) || notification.key === 'p2p_daily_limit_increase' || (excluded_notifications && !excluded_notifications.includes(notification.key)) ) { @@ -302,9 +301,9 @@ export default class NotificationStore extends BaseStore { const { max_daily_buy, max_daily_sell } = upgradable_daily_limits || {}; const { is_10k_withdrawal_limit_reached } = this.root_store.modules.cashier.withdraw; const { current_language, selected_contract_type } = this.root_store.common; - const malta_account = landing_company_shortcode === Jurisdiction.MALTA_INVEST; + const malta_account = landing_company_shortcode === 'maltainvest'; const virtual_account = landing_company_shortcode === 'virtual'; - const cr_account = landing_company_shortcode === Jurisdiction.SVG; + const cr_account = landing_company_shortcode === 'svg'; const is_website_up = website_status.site_status === 'up'; const has_trustpilot = LocalStore.getObject('notification_messages')[loginid]?.includes( this.client_notifications.trustpilot.key @@ -1501,7 +1500,7 @@ export default class NotificationStore extends BaseStore { updateNotifications(notifications_array) { this.notifications = notifications_array.filter(message => - (message.key && message.key.includes(Jurisdiction.SVG)) || message.key === 'p2p_daily_limit_increase' + (message.key && message.key.includes('svg')) || message.key === 'p2p_daily_limit_increase' ? message : excluded_notifications && !excluded_notifications.includes(message.key) ); diff --git a/packages/core/src/Stores/traders-hub-store.js b/packages/core/src/Stores/traders-hub-store.js index 8d8f155db077..f8c0891fbc3c 100644 --- a/packages/core/src/Stores/traders-hub-store.js +++ b/packages/core/src/Stores/traders-hub-store.js @@ -1,12 +1,5 @@ import { action, makeObservable, observable, reaction, computed, runInAction } from 'mobx'; -import { - getCFDAvailableAccount, - CFD_PLATFORMS, - ContentFlag, - formatMoney, - getAppstorePlatforms, - Jurisdiction, -} from '@deriv/shared'; +import { getCFDAvailableAccount, CFD_PLATFORMS, ContentFlag, formatMoney, getAppstorePlatforms } from '@deriv/shared'; import BaseStore from './base-store'; import { localize } from '@deriv/translations'; import { isEuCountry } from '_common/utility'; @@ -201,7 +194,7 @@ export default class TradersHubStore extends BaseStore { get no_CR_account() { const { active_accounts } = this.root_store.client; - const result = active_accounts.some(acc => acc.landing_company_shortcode === Jurisdiction.SVG); + const result = active_accounts.some(acc => acc.landing_company_shortcode === 'svg'); return !result && this.selected_region === 'Non-EU'; } @@ -257,8 +250,8 @@ export default class TradersHubStore extends BaseStore { const { financial_company, gaming_company } = this.root_store.client.landing_companies; return ( this.content_flag === ContentFlag.CR_DEMO && - financial_company?.shortcode === Jurisdiction.MALTA_INVEST && - gaming_company?.shortcode === Jurisdiction.SVG + financial_company?.shortcode === 'maltainvest' && + gaming_company?.shortcode === 'svg' ); } @@ -267,23 +260,21 @@ export default class TradersHubStore extends BaseStore { const { financial_company, gaming_company } = landing_companies; //this is a conditional check for countries like Australia/Norway which fulfiles one of these following conditions - const restricted_countries = - financial_company?.shortcode === Jurisdiction.SVG || gaming_company?.shortcode === Jurisdiction.SVG; + const restricted_countries = financial_company?.shortcode === 'svg' || gaming_company?.shortcode === 'svg'; if (!is_logged_in) return ''; - if (!gaming_company?.shortcode && financial_company?.shortcode === Jurisdiction.MALTA_INVEST) { + if (!gaming_company?.shortcode && financial_company?.shortcode === 'maltainvest') { if (this.is_demo) return ContentFlag.EU_DEMO; return ContentFlag.EU_REAL; } else if ( - financial_company?.shortcode === Jurisdiction.MALTA_INVEST && - gaming_company?.shortcode === Jurisdiction.SVG && + financial_company?.shortcode === 'maltainvest' && + gaming_company?.shortcode === 'svg' && this.is_real ) { if (this.is_eu_user) return ContentFlag.LOW_RISK_CR_EU; return ContentFlag.LOW_RISK_CR_NON_EU; } else if ( - ((financial_company?.shortcode === Jurisdiction.SVG && gaming_company?.shortcode === Jurisdiction.SVG) || - restricted_countries) && + ((financial_company?.shortcode === 'svg' && gaming_company?.shortcode === 'svg') || restricted_countries) && this.is_real ) { return ContentFlag.HIGH_RISK_CR; @@ -339,10 +330,7 @@ export default class TradersHubStore extends BaseStore { ContentFlag.CR_DEMO, ].includes(this.content_flag); const { active_accounts } = this.root_store.client; - return ( - is_low_risk_cr_client && - active_accounts.some(acc => acc.landing_company_shortcode === Jurisdiction.MALTA_INVEST) - ); + return is_low_risk_cr_client && active_accounts.some(acc => acc.landing_company_shortcode === 'maltainvest'); } toggleRegulatorsCompareModal() { @@ -398,7 +386,7 @@ export default class TradersHubStore extends BaseStore { get financial_restricted_countries() { const { financial_company, gaming_company } = this.root_store.client.landing_companies; - return gaming_company?.shortcode === Jurisdiction.SVG && !financial_company; + return gaming_company?.shortcode === 'svg' && !financial_company; } getAvailableMt5Accounts() { @@ -446,7 +434,7 @@ export default class TradersHubStore extends BaseStore { const selected_account_type = this.selected_account_type; const existing_accounts = current_list_keys .filter(key => { - const maltainvest_account = current_list[key].landing_company_short === Jurisdiction.MALTA_INVEST; + const maltainvest_account = current_list[key].landing_company_short === 'maltainvest'; if (platform === CFD_PLATFORMS.MT5 && !this.is_eu_user && !maltainvest_account) { return key.startsWith(`${platform}.${selected_account_type}.${market_type}`); @@ -520,7 +508,7 @@ export default class TradersHubStore extends BaseStore { const { openAccountNeededModal } = ui; const { is_eu } = client; if (is_eu && !has_maltainvest_account && standpoint?.iom) { - openAccountNeededModal(Jurisdiction.MALTA_INVEST, localize('Deriv Multipliers'), localize('demo CFDs')); + openAccountNeededModal('maltainvest', localize('Deriv Multipliers'), localize('demo CFDs')); return; } createCFDAccount({ ...account_type, platform }); @@ -601,7 +589,7 @@ export default class TradersHubStore extends BaseStore { hasMultipleSVGAccounts = () => { const all_svg_acc = []; this.combined_cfd_mt5_accounts.map(acc => { - if (acc.landing_company_short === Jurisdiction.SVG && acc.market_type === 'synthetic') { + if (acc.landing_company_short === 'svg' && acc.market_type === 'synthetic') { if (all_svg_acc.length) { all_svg_acc.forEach(svg_acc => { if (svg_acc.server !== acc.server) all_svg_acc.push(acc); @@ -619,15 +607,15 @@ export default class TradersHubStore extends BaseStore { if (this.is_real && !this.is_eu_user) { const short_code = account.landing_company_short && - account.landing_company_short !== Jurisdiction.SVG && - account.landing_company_short !== Jurisdiction.BVI + account.landing_company_short !== 'svg' && + account.landing_company_short !== 'bvi' ? account.landing_company_short?.charAt(0).toUpperCase() + account.landing_company_short?.slice(1) : account.landing_company_short?.toUpperCase(); let region = ''; if (this.hasMultipleSVGAccounts()) { region = - account.market_type !== 'financial' && account.landing_company_short !== Jurisdiction.BVI + account.market_type !== 'financial' && account.landing_company_short !== 'bvi' ? ` - ${this.getServerName(account)}` : ''; } @@ -700,8 +688,8 @@ export default class TradersHubStore extends BaseStore { account => !account.is_virtual && (this.is_eu_user - ? account.landing_company_shortcode === Jurisdiction.MALTA_INVEST - : account.landing_company_shortcode !== Jurisdiction.MALTA_INVEST) + ? account.landing_company_shortcode === 'maltainvest' + : account.landing_company_shortcode !== 'maltainvest') ); if (platform_real_accounts?.length) { this.platform_real_balance = await this.getTotalBalance( @@ -722,8 +710,8 @@ export default class TradersHubStore extends BaseStore { account => account.account_type === 'real' && (this.is_eu_user - ? account.landing_company_short === Jurisdiction.MALTA_INVEST - : account.landing_company_short !== Jurisdiction.MALTA_INVEST) + ? account.landing_company_short === 'maltainvest' + : account.landing_company_short !== 'maltainvest') ); if (cfd_real_accounts?.length) { this.cfd_real_balance = await this.getTotalBalance(cfd_real_accounts, cfd_real_accounts[0]?.currency); diff --git a/packages/hooks/src/__tests__/useDepositLocked.spec.tsx b/packages/hooks/src/__tests__/useDepositLocked.spec.tsx index 401d65a23049..56a4674185e2 100644 --- a/packages/hooks/src/__tests__/useDepositLocked.spec.tsx +++ b/packages/hooks/src/__tests__/useDepositLocked.spec.tsx @@ -1,7 +1,6 @@ import * as React from 'react'; import { StoreProvider } from '@deriv/stores'; import type { TStores } from '@deriv/stores'; -import { Jurisdiction } from '@deriv/shared'; import { renderHook } from '@testing-library/react-hooks'; import useDepositLocked from '../useDepositLocked'; import useNeedAuthentication from '../useNeedAuthentication'; @@ -19,7 +18,7 @@ describe('useDepositLocked', () => { is_financial_account: false, is_financial_information_incomplete: false, is_trading_experience_incomplete: false, - landing_company_shortcode: Jurisdiction.SVG, + landing_company_shortcode: 'svg', mt5_login_list: [ { account_type: 'demo', @@ -47,7 +46,7 @@ describe('useDepositLocked', () => { is_financial_account: false, is_financial_information_incomplete: false, is_trading_experience_incomplete: false, - landing_company_shortcode: Jurisdiction.SVG, + landing_company_shortcode: 'svg', mt5_login_list: [ { account_type: 'demo', @@ -75,7 +74,7 @@ describe('useDepositLocked', () => { is_financial_account: false, is_financial_information_incomplete: false, is_trading_experience_incomplete: false, - landing_company_shortcode: Jurisdiction.SVG, + landing_company_shortcode: 'svg', mt5_login_list: [ { account_type: 'real', @@ -103,7 +102,7 @@ describe('useDepositLocked', () => { is_financial_account: true, is_financial_information_incomplete: true, is_trading_experience_incomplete: false, - landing_company_shortcode: Jurisdiction.SVG, + landing_company_shortcode: 'svg', mt5_login_list: [ { account_type: 'demo', @@ -131,7 +130,7 @@ describe('useDepositLocked', () => { is_financial_account: false, is_financial_information_incomplete: false, is_trading_experience_incomplete: false, - landing_company_shortcode: Jurisdiction.SVG, + landing_company_shortcode: 'svg', mt5_login_list: [ { account_type: 'real', @@ -159,7 +158,7 @@ describe('useDepositLocked', () => { is_financial_account: true, is_financial_information_incomplete: true, is_trading_experience_incomplete: false, - landing_company_shortcode: Jurisdiction.SVG, + landing_company_shortcode: 'svg', mt5_login_list: [ { account_type: 'demo', @@ -187,7 +186,7 @@ describe('useDepositLocked', () => { is_financial_account: false, is_financial_information_incomplete: false, is_trading_experience_incomplete: true, - landing_company_shortcode: Jurisdiction.MALTA_INVEST, + landing_company_shortcode: 'maltainvest', mt5_login_list: [ { account_type: 'demo', diff --git a/packages/hooks/src/useDepositLocked.ts b/packages/hooks/src/useDepositLocked.ts index 76904763d142..3e6c39ae9610 100644 --- a/packages/hooks/src/useDepositLocked.ts +++ b/packages/hooks/src/useDepositLocked.ts @@ -1,5 +1,4 @@ import { useStore } from '@deriv/stores'; -import { Jurisdiction } from '@deriv/shared'; import useNeedAuthentication from './useNeedAuthentication'; import useNeedFinancialAssessment from './useNeedFinancialAssessment'; import useNeedTNC from './useNeedTNC'; @@ -10,7 +9,7 @@ const useDepositLocked = () => { const is_need_authentication = useNeedAuthentication(); const is_need_tnc = useNeedTNC(); const is_need_financial_assessment = useNeedFinancialAssessment(); - const is_malta_invest = landing_company_shortcode === Jurisdiction.MALTA_INVEST; + const is_malta_invest = landing_company_shortcode === 'maltainvest'; const is_trading_experience_incomplete_or_need_financial_assessment = is_malta_invest ? is_trading_experience_incomplete : is_need_financial_assessment; diff --git a/packages/hooks/src/useHasMaltaInvestAccount.ts b/packages/hooks/src/useHasMaltaInvestAccount.ts index 3ad3010c373b..4251c51b2115 100644 --- a/packages/hooks/src/useHasMaltaInvestAccount.ts +++ b/packages/hooks/src/useHasMaltaInvestAccount.ts @@ -1,11 +1,10 @@ import { useStore } from '@deriv/stores'; -import { Jurisdiction } from '@deriv/shared'; const useHasMaltaInvestAccount = () => { const { client } = useStore(); const { active_accounts } = client; const has_malta_invest_account = active_accounts.some( - account => account.landing_company_shortcode === Jurisdiction.MALTA_INVEST + account => account.landing_company_shortcode === 'maltainvest' ); return has_malta_invest_account; diff --git a/packages/shared/src/utils/cfd/cfd.ts b/packages/shared/src/utils/cfd/cfd.ts index d9f587aa84fa..dbfcc6cd177e 100644 --- a/packages/shared/src/utils/cfd/cfd.ts +++ b/packages/shared/src/utils/cfd/cfd.ts @@ -1,6 +1,5 @@ import { CFD_PLATFORMS } from '../platform'; import { LandingCompany, GetAccountStatus, DetailsOfEachMT5Loginid } from '@deriv/api-types'; -import { Jurisdiction } from '../constants/jurisdiction'; import { localize } from '@deriv/translations'; let CFD_text_translated: { [key: string]: () => void }; @@ -47,11 +46,11 @@ export const getCFDAccountKey = ({ market_type, sub_account_type, platform, shor if (market_type === 'gaming' || market_type === 'synthetic') { if (platform === CFD_PLATFORMS.DXTRADE || sub_account_type === 'financial') { switch (shortcode) { - case Jurisdiction.SVG: + case 'svg': return 'synthetic_svg'; - case Jurisdiction.BVI: + case 'bvi': return 'synthetic_bvi'; - case Jurisdiction.VANUATU: + case 'vanuatu': return 'synthetic_v'; default: return 'synthetic'; @@ -65,13 +64,13 @@ export const getCFDAccountKey = ({ market_type, sub_account_type, platform, shor sub_account_type === 'financial_stp' ) { switch (shortcode) { - case Jurisdiction.SVG: + case 'svg': return 'financial_svg'; - case Jurisdiction.BVI: + case 'bvi': return 'financial_bvi'; - case Jurisdiction.LABUAN: + case 'labuan': return 'financial_fx'; - case Jurisdiction.VANUATU: + case 'vanuatu': return 'financial_v'; default: return 'financial'; diff --git a/packages/shared/src/utils/constants/index.ts b/packages/shared/src/utils/constants/index.ts index b72f7a0a5ff0..5d4931b44ec6 100644 --- a/packages/shared/src/utils/constants/index.ts +++ b/packages/shared/src/utils/constants/index.ts @@ -1,4 +1,3 @@ export * from './barriers'; export * from './contract'; export * from './content_flags'; -export * from './jurisdiction'; diff --git a/packages/stores/src/mockStore.ts b/packages/stores/src/mockStore.ts index 438bb1d3640b..6f433ca96fc4 100644 --- a/packages/stores/src/mockStore.ts +++ b/packages/stores/src/mockStore.ts @@ -1,5 +1,4 @@ import merge from 'lodash.merge'; -import { Jurisdiction } from '../../shared/src/utils/constants'; import type { TRootStore } from '../types'; const mock = (): TRootStore => { @@ -14,7 +13,7 @@ const mock = (): TRootStore => { is_virtual: 0, trading: {}, excluded_until: 0, - landing_company_name: Jurisdiction.SVG, + landing_company_name: 'svg', }, }, active_account_landing_company: '', diff --git a/packages/trader/src/Stores/Modules/Trading/trade-store.js b/packages/trader/src/Stores/Modules/Trading/trade-store.js index d4813b1e755f..78af860183bb 100644 --- a/packages/trader/src/Stores/Modules/Trading/trade-store.js +++ b/packages/trader/src/Stores/Modules/Trading/trade-store.js @@ -16,7 +16,6 @@ import { isEmptyObject, isMarketClosed, isMobile, - Jurisdiction, pickDefaultSymbol, removeBarrier, resetEndTimeOnVolatilityIndices, @@ -420,7 +419,7 @@ export default class TradeStore extends BaseStore { } async setActiveSymbols() { - const is_on_mf_account = this.root_store.client.landing_company_shortcode === Jurisdiction.MALTA_INVEST; + const is_on_mf_account = this.root_store.client.landing_company_shortcode === 'maltainvest'; const hide_close_mx_mlt_storage_flag = !!parseInt( localStorage.getItem('hide_close_mx_mlt_account_notification') ); From a53102d64634a4bb5b53b49e366f7f77adc7aa79 Mon Sep 17 00:00:00 2001 From: Taysuisin Date: Wed, 22 Mar 2023 17:52:04 +0800 Subject: [PATCH 5/7] chore: change all hard coded string to follow constant Jurisdiction object --- .../Containers/__tests__/cfd-password-modal.spec.js | 6 +++--- .../jurisdiction-modal-foot-note.tsx | 2 +- .../cfd/src/Containers/mt5-compare-table-content.tsx | 12 ++++++------ packages/cfd/src/Stores/Modules/CFD/cfd-store.js | 4 ++-- packages/shared/src/utils/constants/index.ts | 1 + 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/cfd/src/Containers/__tests__/cfd-password-modal.spec.js b/packages/cfd/src/Containers/__tests__/cfd-password-modal.spec.js index 9acfe73fc22a..582ab53cfcc9 100644 --- a/packages/cfd/src/Containers/__tests__/cfd-password-modal.spec.js +++ b/packages/cfd/src/Containers/__tests__/cfd-password-modal.spec.js @@ -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'; @@ -62,7 +62,7 @@ describe('', () => { 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: {}, @@ -220,7 +220,7 @@ describe('', () => { account_type: { category: 'real', type: 'financial' }, is_eu: true, is_fully_authenticated: false, - jurisdiction_selected_shortcode: 'bvi', + jurisdiction_selected_shortcode: Jurisdiction.BVI, }; render( diff --git a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-foot-note.tsx b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-foot-note.tsx index 4bcbcd2d61a4..96b704d67c39 100644 --- a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-foot-note.tsx +++ b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-foot-note.tsx @@ -36,7 +36,7 @@ const FooterNote = ({ ) : ( ); - } else if (jurisdiction_selected_shortcode === 'bvi') { + } else if (jurisdiction_selected_shortcode === Jurisdiction.BVI) { return ( Date: Wed, 22 Mar 2023 18:19:12 +0800 Subject: [PATCH 6/7] chore: remove Jurisdiction declaration for not jurisdiction_selected_shortcode --- packages/cfd/src/Components/cfd-account-card.tsx | 6 ++---- packages/cfd/src/Containers/cfd-password-modal.tsx | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/cfd/src/Components/cfd-account-card.tsx b/packages/cfd/src/Components/cfd-account-card.tsx index 7d6f395d12b2..5d2de82992ed 100644 --- a/packages/cfd/src/Components/cfd-account-card.tsx +++ b/packages/cfd/src/Components/cfd-account-card.tsx @@ -2,7 +2,7 @@ import classNames from 'classnames'; import React from 'react'; import { CSSTransition } from 'react-transition-group'; import { Icon, Money, Button, Text, DesktopWrapper, MobileWrapper, Popover } from '@deriv/components'; -import { isMobile, mobileOSDetect, getCFDPlatformLabel, CFD_PLATFORMS, isDesktop, Jurisdiction } from '@deriv/shared'; +import { isMobile, mobileOSDetect, getCFDPlatformLabel, CFD_PLATFORMS, isDesktop } from '@deriv/shared'; import { localize, Localize } from '@deriv/translations'; import { connect } from '../Stores/connect'; import RootStore from '../Stores/index'; @@ -545,9 +545,7 @@ const CFDAccountCardComponent = ({ { const [is_password_modal_exited, setPasswordModalExited] = React.useState(true); - const is_bvi = landing_companies?.mt_financial_company?.financial_stp?.shortcode === Jurisdiction.BVI; + const is_bvi = landing_companies?.mt_financial_company?.financial_stp?.shortcode === 'bvi'; const has_mt5_account = Boolean(mt5_login_list?.length); const should_set_trading_password = Array.isArray(account_status?.status) && From 6bd100e096d23cb88621c62baf72a134cb4a89ae Mon Sep 17 00:00:00 2001 From: Taysuisin Date: Thu, 30 Mar 2023 11:23:14 +0800 Subject: [PATCH 7/7] chore: cahnge file name to jurisdictions-config --- packages/shared/src/utils/constants/index.ts | 2 +- .../constants/{jurisdiction.ts => jurisdictions-config.ts} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename packages/shared/src/utils/constants/{jurisdiction.ts => jurisdictions-config.ts} (100%) diff --git a/packages/shared/src/utils/constants/index.ts b/packages/shared/src/utils/constants/index.ts index b72f7a0a5ff0..093a7a776a48 100644 --- a/packages/shared/src/utils/constants/index.ts +++ b/packages/shared/src/utils/constants/index.ts @@ -1,4 +1,4 @@ export * from './barriers'; export * from './contract'; export * from './content_flags'; -export * from './jurisdiction'; +export * from './jurisdictions-config'; diff --git a/packages/shared/src/utils/constants/jurisdiction.ts b/packages/shared/src/utils/constants/jurisdictions-config.ts similarity index 100% rename from packages/shared/src/utils/constants/jurisdiction.ts rename to packages/shared/src/utils/constants/jurisdictions-config.ts