diff --git a/packages/account/src/Components/poi-poa-docs-submitted/poi-poa-docs-submitted.tsx b/packages/account/src/Components/poi-poa-docs-submitted/poi-poa-docs-submitted.tsx index 8cee4c674c0e..65c6ff92f3b4 100644 --- a/packages/account/src/Components/poi-poa-docs-submitted/poi-poa-docs-submitted.tsx +++ b/packages/account/src/Components/poi-poa-docs-submitted/poi-poa-docs-submitted.tsx @@ -41,14 +41,12 @@ const PoiPoaDocsSubmitted = ({ }; const getDescription = () => { - const { manual_status, poi_verified_for_vanuatu_maltainvest, poi_verified_for_bvi_labuan, poa_pending } = + const { manual_status, poi_verified_for_maltainvest, poi_verified_for_bvi_labuan_vanuatu, poa_pending } = getAuthenticationStatusInfo(account_status); - const is_vanuatu_or_maltainvest_selected = [Jurisdiction.VANUATU, Jurisdiction.MALTA_INVEST].includes( - jurisdiction_selected_shortcode - ); + const is_maltainvest_selected = 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) || + (is_maltainvest_selected && poi_verified_for_maltainvest && poa_pending) || + (!is_maltainvest_selected && poi_verified_for_bvi_labuan_vanuatu && poa_pending) || manual_status === 'pending' ) { return localize('We’ll review your documents and notify you of its status within 1 - 3 working days.'); diff --git a/packages/account/src/Sections/Verification/ProofOfIdentity/proof-of-identity-container-for-mt5.jsx b/packages/account/src/Sections/Verification/ProofOfIdentity/proof-of-identity-container-for-mt5.jsx index eb9da4c642c9..a931df72d4cc 100644 --- a/packages/account/src/Sections/Verification/ProofOfIdentity/proof-of-identity-container-for-mt5.jsx +++ b/packages/account/src/Sections/Verification/ProofOfIdentity/proof-of-identity-container-for-mt5.jsx @@ -20,8 +20,7 @@ const ProofOfIdentityContainerForMt5 = ({ onStateChange, refreshNotifications, citizen_data, - jurisdiction_selected_shortcode, - updateAccountStatus, + is_eu_user, }) => { const [api_error, setAPIError] = React.useState(); const [residence_list, setResidenceList] = React.useState(); @@ -88,9 +87,8 @@ const ProofOfIdentityContainerForMt5 = ({ residence_list={residence_list} citizen_data={citizen_data} has_idv_error={has_idv_error} - jurisdiction_selected_shortcode={jurisdiction_selected_shortcode} getChangeableFields={getChangeableFields} - updateAccountStatus={updateAccountStatus} + is_eu_user={is_eu_user} /> ); }; 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 821e6b2094e3..f724b2988c46 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, Jurisdiction, IDV_NOT_APPLICABLE_OPTION } from '@deriv/shared'; +import { WS, isVerificationServiceSupported, IDV_NOT_APPLICABLE_OPTION } from '@deriv/shared'; import Unsupported from 'Components/poi/status/unsupported'; import OnfidoUpload from './onfido-sdk-view-container'; import { identity_status_codes, submission_status_code, service_code } from './proof-of-identity-utils'; @@ -18,7 +18,8 @@ const POISubmissionForMT5 = ({ refreshNotifications, citizen_data, has_idv_error, - jurisdiction_selected_shortcode, + residence_list, + is_eu_user, }) => { const [submission_status, setSubmissionStatus] = React.useState(); // submitting const [submission_service, setSubmissionService] = React.useState(); @@ -26,14 +27,9 @@ const POISubmissionForMT5 = ({ if (citizen_data) { const { submissions_left: idv_submissions_left } = idv; const { submissions_left: onfido_submissions_left } = onfido; - const is_idv_supported = citizen_data.identity.services.idv.is_country_supported; - const is_onfido_supported = citizen_data.identity.services.onfido.is_country_supported; - if ( - is_idv_supported && - Number(idv_submissions_left) > 0 && - !is_idv_disallowed && - jurisdiction_selected_shortcode !== Jurisdiction.VANUATU - ) { + const is_idv_supported = isVerificationServiceSupported(residence_list, account_settings, 'idv'); + const is_onfido_supported = isVerificationServiceSupported(residence_list, account_settings, 'onfido'); + if (is_idv_supported && Number(idv_submissions_left) > 0 && !is_idv_disallowed && !is_eu_user) { setSubmissionService(service_code.idv); } else if (onfido_submissions_left > 0 && is_onfido_supported) { setSubmissionService(service_code.onfido); diff --git a/packages/appstore/src/components/modals/failed-veriification-modal/failed-verification-modal.tsx b/packages/appstore/src/components/modals/failed-veriification-modal/failed-verification-modal.tsx index 9ec4d31bbcb9..3440bff2c4ef 100644 --- a/packages/appstore/src/components/modals/failed-veriification-modal/failed-verification-modal.tsx +++ b/packages/appstore/src/components/modals/failed-veriification-modal/failed-verification-modal.tsx @@ -66,7 +66,7 @@ const FailedVerificationModal = () => { const { disableApp, enableApp } = ui; const is_from_multipliers = open_failed_verification_for === 'multipliers'; - const { poi_resubmit_for_vanuatu_maltainvest, poi_resubmit_for_bvi_labuan, need_poa_resubmission } = + const { poi_resubmit_for_maltainvest, poi_resubmit_for_bvi_labuan_vanuatu, need_poa_resubmission } = getAuthenticationStatusInfo(account_status); const history = useHistory(); @@ -88,14 +88,10 @@ const FailedVerificationModal = () => { }; const should_resubmit_poi = () => { - if ( - is_from_multipliers || - open_failed_verification_for === 'vanuatu' || - open_failed_verification_for === 'maltainvest' - ) { - return poi_resubmit_for_vanuatu_maltainvest; + if (is_from_multipliers || open_failed_verification_for === 'maltainvest') { + return poi_resubmit_for_maltainvest; } - return poi_resubmit_for_bvi_labuan; + return poi_resubmit_for_bvi_labuan_vanuatu; }; const should_resubmit_poa = need_poa_resubmission; const from_account_label = is_from_multipliers ? localize('Multipliers') : localize('MT5'); diff --git a/packages/cfd/src/Components/__tests__/cfd-poi.spec.js b/packages/cfd/src/Components/__tests__/cfd-poi.spec.js index 5e52132653c7..c9a2f2620cbd 100644 --- a/packages/cfd/src/Components/__tests__/cfd-poi.spec.js +++ b/packages/cfd/src/Components/__tests__/cfd-poi.spec.js @@ -85,6 +85,10 @@ describe('', () => { form_error: undefined, height: 'auto', index: 1, + is_loading: false, + is_switching: false, + is_virtual: false, + is_eu_user: false, onCancel: jest.fn(), onSave: jest.fn(), onSubmit: jest.fn(), diff --git a/packages/cfd/src/Components/cfd-poi.tsx b/packages/cfd/src/Components/cfd-poi.tsx index e37c56bf4c0b..5a021339c8a2 100644 --- a/packages/cfd/src/Components/cfd-poi.tsx +++ b/packages/cfd/src/Components/cfd-poi.tsx @@ -31,7 +31,7 @@ export type TCFDPOIProps = { }; const CFDPOI = observer(({ index, onSave, onSubmit, height, ...props }: TCFDPOIProps) => { - const { client, common, notifications } = useStore(); + const { client, common, notifications, traders_hub } = useStore(); const { account_status, @@ -48,6 +48,7 @@ const CFDPOI = observer(({ index, onSave, onSubmit, height, ...props }: TCFDPOIP } = client; const { routeBackInApp, app_routing_history } = common; const { refreshNotifications } = notifications; + const { is_eu_user } = traders_hub; const poi_props = { account_status, @@ -64,6 +65,7 @@ const CFDPOI = observer(({ index, onSave, onSubmit, height, ...props }: TCFDPOIP refreshNotifications, getChangeableFields, updateAccountStatus, + is_eu_user, ...props, }; diff --git a/packages/cfd/src/Containers/__tests__/cfd-financial-stp-real-account-signup.spec.js b/packages/cfd/src/Containers/__tests__/cfd-financial-stp-real-account-signup.spec.js index 275ef18014de..0014b09aa3d1 100644 --- a/packages/cfd/src/Containers/__tests__/cfd-financial-stp-real-account-signup.spec.js +++ b/packages/cfd/src/Containers/__tests__/cfd-financial-stp-real-account-signup.spec.js @@ -183,6 +183,7 @@ describe('', () => { storeProofOfAddress: jest.fn(), }, }, + jurisdiction_selected_shortcode: 'svg', }; it('should render CFDFinancialStpRealAccountSignup component', () => { @@ -194,7 +195,7 @@ describe('', () => { }); it('should render properly for the first step content', () => { - getAuthenticationStatusInfo.mockReturnValueOnce({ need_poi_for_bvi_labuan: true }); + getAuthenticationStatusInfo.mockReturnValueOnce({ need_poi_for_bvi_labuan_vanuatu: true }); render(, { wrapper: ({ children }) => {children}, }); @@ -223,7 +224,7 @@ describe('', () => { }, }; - getAuthenticationStatusInfo.mockReturnValueOnce({ need_poi_for_vanuatu_maltainvest: true }); + getAuthenticationStatusInfo.mockReturnValueOnce({ need_poi_for_bvi_labuan_vanuatu: true }); render(, { wrapper: ({ children }) => {children}, @@ -243,7 +244,7 @@ describe('', () => { }, }; - getAuthenticationStatusInfo.mockReturnValueOnce({ need_poi_for_vanuatu_maltainvest: true }); + getAuthenticationStatusInfo.mockReturnValueOnce({ need_poi_for_maltainvest: true }); render(, { wrapper: ({ children }) => {children}, diff --git a/packages/cfd/src/Containers/cfd-dbvi-onboarding.tsx b/packages/cfd/src/Containers/cfd-dbvi-onboarding.tsx index 75cbbd09df72..f02387d3d3c6 100644 --- a/packages/cfd/src/Containers/cfd-dbvi-onboarding.tsx +++ b/packages/cfd/src/Containers/cfd-dbvi-onboarding.tsx @@ -60,30 +60,27 @@ const CFDDbviOnboarding = observer(() => { if (get_account_status?.authentication) { const { - poi_acknowledged_for_vanuatu_maltainvest, - poi_acknowledged_for_bvi_labuan, + poi_acknowledged_for_maltainvest, + poi_acknowledged_for_bvi_labuan_vanuatu, poa_acknowledged, poa_resubmit_for_labuan, need_poa_submission, } = getAuthenticationStatusInfo(get_account_status); - - if (jurisdiction_selected_shortcode === Jurisdiction.VANUATU) { - setShowSubmittedModal( - poi_acknowledged_for_vanuatu_maltainvest && - poa_acknowledged && - has_submitted_cfd_personal_details - ); - } else if (jurisdiction_selected_shortcode === Jurisdiction.MALTA_INVEST) { - setShowSubmittedModal(poi_acknowledged_for_vanuatu_maltainvest && poa_acknowledged); + if (jurisdiction_selected_shortcode === Jurisdiction.MALTA_INVEST) { + setShowSubmittedModal(poi_acknowledged_for_maltainvest && poa_acknowledged); } else if (jurisdiction_selected_shortcode === Jurisdiction.LABUAN) { /* When verified with IDV+ Photo ID, POA is auto verified */ const is_poa_submitted = poa_resubmit_for_labuan ? false : !need_poa_submission; setShowSubmittedModal( - poi_acknowledged_for_bvi_labuan && has_submitted_cfd_personal_details && is_poa_submitted + poi_acknowledged_for_bvi_labuan_vanuatu && + has_submitted_cfd_personal_details && + is_poa_submitted ); } else setShowSubmittedModal( - poi_acknowledged_for_bvi_labuan && poa_acknowledged && has_submitted_cfd_personal_details + poi_acknowledged_for_bvi_labuan_vanuatu && + poa_acknowledged && + has_submitted_cfd_personal_details ); } 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 14dd74e08b47..28d3b8f723fe 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 @@ -86,7 +86,7 @@ const CFDFinancialStpRealAccountSignup = observer(({ onFinish }: TCFDFinancialSt const state_index = step; let is_mounted = React.useRef(true).current; - const { need_poi_for_vanuatu_maltainvest, need_poi_for_bvi_labuan } = getAuthenticationStatusInfo(account_status); + const { need_poi_for_maltainvest, need_poi_for_bvi_labuan_vanuatu } = getAuthenticationStatusInfo(account_status); const is_authenticated_with_idv_photoid = useIsAccountStatusPresent('authenticated_with_idv_photoid'); @@ -137,10 +137,10 @@ const CFDFinancialStpRealAccountSignup = observer(({ onFinish }: TCFDFinancialSt }; const should_show_poi = () => { - if ([Jurisdiction.VANUATU, Jurisdiction.MALTA_INVEST].includes(jurisdiction_selected_shortcode)) { - return need_poi_for_vanuatu_maltainvest; + if (jurisdiction_selected_shortcode === Jurisdiction.MALTA_INVEST) { + return need_poi_for_maltainvest; } - return need_poi_for_bvi_labuan; + return need_poi_for_bvi_labuan_vanuatu; }; const shouldShowPOA = () => { diff --git a/packages/cfd/src/Containers/cfd-password-modal.tsx b/packages/cfd/src/Containers/cfd-password-modal.tsx index 6dc0a6e07537..3dbf3f6c213c 100644 --- a/packages/cfd/src/Containers/cfd-password-modal.tsx +++ b/packages/cfd/src/Containers/cfd-password-modal.tsx @@ -638,7 +638,7 @@ const CFDPasswordModal = observer(({ form_error, platform }: TCFDPasswordModalPr const is_password_reset = error_type === 'PasswordReset'; const [is_sent_email_modal_open, setIsSentEmailModalOpen] = React.useState(false); - const { poi_verified_for_bvi_labuan, poi_verified_for_vanuatu_maltainvest, poa_verified, manual_status } = + const { poi_verified_for_bvi_labuan_vanuatu, poi_verified_for_maltainvest, poa_verified, manual_status } = getAuthenticationStatusInfo(account_status); const [is_selected_mt5_verified, setIsSelectedMT5Verified] = React.useState(false); @@ -649,16 +649,14 @@ const CFDPasswordModal = observer(({ form_error, platform }: TCFDPasswordModalPr setIsSelectedMT5Verified(true); break; case Jurisdiction.BVI: - setIsSelectedMT5Verified(poi_verified_for_bvi_labuan); - break; case Jurisdiction.VANUATU: - setIsSelectedMT5Verified(poi_verified_for_vanuatu_maltainvest); + setIsSelectedMT5Verified(poi_verified_for_bvi_labuan_vanuatu); break; case Jurisdiction.LABUAN: - setIsSelectedMT5Verified(poi_verified_for_bvi_labuan && poa_verified); + setIsSelectedMT5Verified(poi_verified_for_bvi_labuan_vanuatu && poa_verified); break; case Jurisdiction.MALTA_INVEST: - setIsSelectedMT5Verified(poi_verified_for_vanuatu_maltainvest && poa_verified); + setIsSelectedMT5Verified(poi_verified_for_maltainvest && poa_verified); break; default: } diff --git a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-content-wrapper.tsx b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-content-wrapper.tsx index a51e32d5a465..aecf6eea4673 100644 --- a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-content-wrapper.tsx +++ b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-modal-content-wrapper.tsx @@ -44,8 +44,8 @@ const JurisdictionModalContentWrapper = observer(({ openPasswordModal }: TJurisd const { poi_or_poa_not_submitted, - poi_acknowledged_for_bvi_labuan, - poi_acknowledged_for_vanuatu_maltainvest, + poi_acknowledged_for_bvi_labuan_vanuatu, + poi_acknowledged_for_maltainvest, poa_acknowledged, need_poa_resubmission, poa_resubmit_for_labuan, @@ -144,7 +144,7 @@ const JurisdictionModalContentWrapper = observer(({ openPasswordModal }: TJurisd openPasswordModal(type_of_account); } else if (is_vanuatu_selected) { if ( - poi_acknowledged_for_vanuatu_maltainvest && + poi_acknowledged_for_bvi_labuan_vanuatu && !poi_or_poa_not_submitted && !should_restrict_vanuatu_account_creation && poa_acknowledged && @@ -156,7 +156,7 @@ const JurisdictionModalContentWrapper = observer(({ openPasswordModal }: TJurisd } } else if (is_bvi_selected) { if ( - poi_acknowledged_for_bvi_labuan && + poi_acknowledged_for_bvi_labuan_vanuatu && !poi_or_poa_not_submitted && !should_restrict_bvi_account_creation && poa_acknowledged && @@ -168,7 +168,7 @@ const JurisdictionModalContentWrapper = observer(({ openPasswordModal }: TJurisd } } else if (is_labuan_selected) { if ( - poi_acknowledged_for_bvi_labuan && + poi_acknowledged_for_bvi_labuan_vanuatu && poa_acknowledged && has_submitted_cfd_personal_details && !poa_resubmit_for_labuan @@ -178,7 +178,7 @@ const JurisdictionModalContentWrapper = observer(({ openPasswordModal }: TJurisd toggleCFDVerificationModal(); } } else if (is_maltainvest_selected) { - if (poi_acknowledged_for_vanuatu_maltainvest && poa_acknowledged) { + if (poi_acknowledged_for_maltainvest && poa_acknowledged) { openPasswordModal(type_of_account); } else { toggleCFDVerificationModal(); diff --git a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-title-indicator.tsx b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-title-indicator.tsx index 5583b06c4806..b36ada1d9689 100644 --- a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-title-indicator.tsx +++ b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-title-indicator.tsx @@ -13,12 +13,12 @@ const JurisdictionTitleIndicator = ({ verification_docs, }: TJurisdictionTitleIndicatorProps) => { const { - poi_pending_for_bvi_labuan, - poi_resubmit_for_bvi_labuan, - poi_verified_for_bvi_labuan, - poi_pending_for_vanuatu_maltainvest, - poi_resubmit_for_vanuatu_maltainvest, - poi_verified_for_vanuatu_maltainvest, + poi_pending_for_bvi_labuan_vanuatu, + poi_resubmit_for_bvi_labuan_vanuatu, + poi_verified_for_bvi_labuan_vanuatu, + poi_pending_for_maltainvest, + poi_resubmit_for_maltainvest, + poi_verified_for_maltainvest, poa_pending, need_poa_resubmission, poa_verified, @@ -26,23 +26,23 @@ const JurisdictionTitleIndicator = ({ const getVerificationIconVariant = (verification_document: TJurisdictionCardItemVerificationItem): string => { let icon_variant: TJurisdictionCardVerificationStatus = 'Default'; - if ([Jurisdiction.BVI, Jurisdiction.LABUAN].includes(type_of_card)) { + if ([Jurisdiction.BVI, Jurisdiction.LABUAN, Jurisdiction.VANUATU].includes(type_of_card)) { if (['document_number', 'selfie', 'identity_document'].includes(verification_document)) { - if (poi_pending_for_bvi_labuan) { + if (poi_pending_for_bvi_labuan_vanuatu) { icon_variant = 'Pending'; - } else if (poi_resubmit_for_bvi_labuan) { + } else if (poi_resubmit_for_bvi_labuan_vanuatu) { icon_variant = 'Failed'; - } else if (poi_verified_for_bvi_labuan) { + } else if (poi_verified_for_bvi_labuan_vanuatu) { icon_variant = 'Verified'; } } - } else if ([Jurisdiction.VANUATU, Jurisdiction.MALTA_INVEST].includes(type_of_card)) { + } else if (Jurisdiction.MALTA_INVEST === type_of_card) { if (['document_number', 'selfie', 'identity_document'].includes(verification_document)) { - if (poi_pending_for_vanuatu_maltainvest) { + if (poi_pending_for_maltainvest) { icon_variant = 'Pending'; - } else if (poi_resubmit_for_vanuatu_maltainvest) { + } else if (poi_resubmit_for_maltainvest) { icon_variant = 'Failed'; - } else if (poi_verified_for_vanuatu_maltainvest) { + } else if (poi_verified_for_maltainvest) { icon_variant = 'Verified'; } } diff --git a/packages/cfd/src/Containers/mt5-compare-table-content.tsx b/packages/cfd/src/Containers/mt5-compare-table-content.tsx index e99f193913b2..bcea6221dcbf 100755 --- a/packages/cfd/src/Containers/mt5-compare-table-content.tsx +++ b/packages/cfd/src/Containers/mt5-compare-table-content.tsx @@ -233,8 +233,8 @@ const DMT5CompareModalContent = observer( const is_high_risk_for_mt5 = synthetic_accounts_count === 1 && financial_accounts_count === 1; const { poi_or_poa_not_submitted, - poi_acknowledged_for_vanuatu_maltainvest, - poi_acknowledged_for_bvi_labuan, + poi_acknowledged_for_maltainvest, + poi_acknowledged_for_bvi_labuan_vanuatu, poa_acknowledged, poa_pending, } = getAuthenticationStatusInfo(account_status); @@ -346,7 +346,7 @@ const DMT5CompareModalContent = observer( setAppstorePlatform(CFD_PLATFORMS.MT5); setJurisdictionSelectedShortcode(Jurisdiction.BVI); if ( - poi_acknowledged_for_bvi_labuan && + poi_acknowledged_for_bvi_labuan_vanuatu && !poi_or_poa_not_submitted && !should_restrict_bvi_account_creation && has_submitted_personal_details && @@ -362,7 +362,7 @@ const DMT5CompareModalContent = observer( setAppstorePlatform(CFD_PLATFORMS.MT5); setJurisdictionSelectedShortcode(Jurisdiction.VANUATU); if ( - poi_acknowledged_for_vanuatu_maltainvest && + poi_acknowledged_for_bvi_labuan_vanuatu && !poi_or_poa_not_submitted && !should_restrict_vanuatu_account_creation && has_submitted_personal_details && @@ -376,7 +376,7 @@ const DMT5CompareModalContent = observer( case 'financial_labuan': setAppstorePlatform(CFD_PLATFORMS.MT5); setJurisdictionSelectedShortcode(Jurisdiction.LABUAN); - if (poi_acknowledged_for_bvi_labuan && poa_acknowledged && has_submitted_personal_details) { + if (poi_acknowledged_for_bvi_labuan_vanuatu && poa_acknowledged && has_submitted_personal_details) { openPasswordModal(type_of_account); } else { toggleCFDVerificationModal(); @@ -385,7 +385,7 @@ const DMT5CompareModalContent = observer( case 'financial_maltainvest': setAppstorePlatform(CFD_PLATFORMS.MT5); setJurisdictionSelectedShortcode(Jurisdiction.MALTA_INVEST); - if ((poi_acknowledged_for_vanuatu_maltainvest && poa_acknowledged) || is_demo_tab) { + if ((poi_acknowledged_for_maltainvest && poa_acknowledged) || is_demo_tab) { openPasswordModal(type_of_account); } else { toggleCFDVerificationModal(); diff --git a/packages/cfd/src/Containers/props.types.ts b/packages/cfd/src/Containers/props.types.ts index 156d289a0a0e..d86bd26f8f4a 100644 --- a/packages/cfd/src/Containers/props.types.ts +++ b/packages/cfd/src/Containers/props.types.ts @@ -1,5 +1,11 @@ import React from 'react'; -import { DetailsOfEachMT5Loginid, GetAccountStatus, VerifyEmailResponse } from '@deriv/api-types'; +import { + DetailsOfEachMT5Loginid, + GetAccountStatus, + GetSettings, + ResidenceList, + VerifyEmailResponse, +} from '@deriv/api-types'; import { FormikHelpers as FormikActions } from 'formik'; import { TCFDPasswordFormValues } from './cfd-password-modal'; import { @@ -194,6 +200,8 @@ export type TJurisdictionCardSectionProps = { export type TJurisdictionCardType = 'svg' | 'bvi' | 'vanuatu' | 'labuan' | 'maltainvest'; export type TVerificationStatusBannerProps = { + account_status: GetAccountStatus; + account_settings: GetSettings; account_type: string; card_classname: string; disabled: boolean; @@ -203,6 +211,7 @@ export type TVerificationStatusBannerProps = { real_swapfree_accounts_existing_data: TExistingData; should_restrict_bvi_account_creation: boolean; should_restrict_vanuatu_account_creation: boolean; + residence_list: ResidenceList; }; export type TJurisdictionCheckBoxProps = { diff --git a/packages/shared/src/utils/cfd/cfd.ts b/packages/shared/src/utils/cfd/cfd.ts index ed40356091ef..6d8241df2bdf 100644 --- a/packages/shared/src/utils/cfd/cfd.ts +++ b/packages/shared/src/utils/cfd/cfd.ts @@ -255,86 +255,123 @@ export const isLandingCompanyEnabled = ({ landing_companies, platform, type }: T return false; }; -export const getAuthenticationStatusInfo = (account_status: GetAccountStatus) => { +// Define the AuthenticationStatusInfo type +type TAuthenticationStatusInfo = { + poa_status?: string; + poi_status?: string; + idv_status?: string; + onfido_status?: string; + manual_status?: string; + acknowledged_status: string[]; + poi_acknowledged_for_maltainvest: boolean; + poi_poa_verified_for_bvi_labuan_vanuatu: boolean; + poa_acknowledged: boolean; + poi_poa_verified_for_maltainvest: boolean; + need_poa_submission: boolean; + poi_verified_for_maltainvest: boolean; + poi_acknowledged_for_bvi_labuan_vanuatu: boolean; + poi_verified_for_bvi_labuan_vanuatu: boolean; + poa_verified: boolean; + poi_or_poa_not_submitted: boolean; + need_poa_resubmission: boolean; + poi_and_poa_not_submitted: boolean; + poa_not_submitted: boolean; + poi_not_submitted: boolean; + need_poi_for_maltainvest: boolean; + need_poi_for_bvi_labuan_vanuatu: boolean; + poi_not_submitted_for_maltainvest: boolean; + poi_pending_for_bvi_labuan_vanuatu: boolean; + poi_pending_for_maltainvest: boolean; + poi_resubmit_for_maltainvest: boolean; + poi_resubmit_for_bvi_labuan_vanuatu: boolean; + poa_pending: boolean; + poa_resubmit_for_labuan: boolean; + is_idv_revoked: boolean; +}; + +export const getAuthenticationStatusInfo = (account_status: GetAccountStatus): TAuthenticationStatusInfo => { const risk_classification = account_status.risk_classification; - const poa_status = account_status?.authentication?.document?.status || ''; - const poi_status = account_status?.authentication?.identity?.status || ''; + const poa_status: string = account_status?.authentication?.document?.status || ''; + const poi_status: string = account_status?.authentication?.identity?.status || ''; - const idv_status = account_status?.authentication?.identity?.services?.idv?.status; - const onfido_status = account_status?.authentication?.identity?.services?.onfido?.status; - const manual_status = account_status?.authentication?.identity?.services?.manual?.status; + const services = account_status?.authentication?.identity?.services ?? {}; + const { + idv: { status: idv_status } = {}, + onfido: { status: onfido_status } = {}, + manual: { status: manual_status } = {}, + } = services; const is_authenticated_with_idv_photoid = account_status?.status?.includes('authenticated_with_idv_photoid'); const is_idv_revoked = account_status?.status?.includes('idv_revoked'); - const acknowledged_status = ['pending', 'verified']; - const failed_cases = ['rejected', 'expired', 'suspected']; - - const poa_not_submitted = poa_status === 'none'; - const poa_acknowledged = acknowledged_status.includes(poa_status); - const need_poa_submission = !poa_acknowledged; - const need_poa_resubmission = failed_cases.includes(poa_status); - const poa_verified = poa_status === 'verified'; - const poa_pending = poa_status === 'pending'; - - const poi_not_submitted = poi_status === 'none'; - const poi_or_poa_not_submitted = poa_not_submitted || poi_not_submitted; - const poi_and_poa_not_submitted = poa_not_submitted && poi_not_submitted; - - //vanuatu-maltainvest - - const poi_verified_for_vanuatu_maltainvest = [onfido_status, manual_status].includes('verified'); - const poi_acknowledged_for_vanuatu_maltainvest = - (onfido_status && acknowledged_status.includes(onfido_status)) || - (manual_status && acknowledged_status.includes(manual_status)); - - const poi_pending_for_vanuatu_maltainvest = - onfido_status && - manual_status && - [onfido_status, manual_status].includes('pending') && - !poi_verified_for_vanuatu_maltainvest; - - const need_poi_for_vanuatu_maltainvest = !poi_acknowledged_for_vanuatu_maltainvest; - const poi_not_submitted_for_vanuatu_maltainvest = - onfido_status && manual_status && [onfido_status, manual_status].every(status => status === 'none'); - const poi_resubmit_for_vanuatu_maltainvest = - !poi_pending_for_vanuatu_maltainvest && - !poi_not_submitted_for_vanuatu_maltainvest && - !poi_verified_for_vanuatu_maltainvest; - - const poi_poa_verified_for_vanuatu_maltainvest = poi_verified_for_vanuatu_maltainvest && poa_verified; - - //bvi-labuan - let poi_acknowledged_for_bvi_labuan; + const acknowledged_status: string[] = ['pending', 'verified']; + const failed_cases: string[] = ['rejected', 'expired', 'suspected']; + + const poa_not_submitted: boolean = poa_status === 'none'; + const need_poa_submission = !acknowledged_status.includes(poa_status); + const need_poa_resubmission: boolean = failed_cases.includes(poa_status); + const poa_verified: boolean = poa_status === 'verified'; + const poa_pending: boolean = poa_status === 'pending'; + const poa_acknowledged: boolean = acknowledged_status.includes(poa_status); + + const poi_not_submitted: boolean = poi_status === 'none'; + const poi_or_poa_not_submitted: boolean = poa_not_submitted || poi_not_submitted; + const poi_and_poa_not_submitted: boolean = poa_not_submitted && poi_not_submitted; + + //maltainvest + + // mf = maltainvest: only require onfido and manual + const mf_jurisdiction_statuses: string[] = [onfido_status, manual_status].filter( + (status: string | undefined) => status + ) as string[]; + // bvi_labuan_vanuatu jurisdictions: require idv, onfido and manual + const bvi_labuan_vanuatu_jurisdiction_statuses: string[] = [idv_status, onfido_status, manual_status].filter( + status => status + ) as string[]; + + const poi_verified_for_maltainvest: boolean = mf_jurisdiction_statuses.includes('verified'); + const poi_acknowledged_for_maltainvest: boolean = mf_jurisdiction_statuses.some(status => + acknowledged_status.includes(status) + ); + const poi_pending_for_maltainvest: boolean = + mf_jurisdiction_statuses.some(status => status === 'pending') && !poi_verified_for_maltainvest; + + const need_poi_for_maltainvest = !poi_acknowledged_for_maltainvest; + const poi_not_submitted_for_maltainvest: boolean = mf_jurisdiction_statuses.every(status => status === 'none'); + + const poi_resubmit_for_maltainvest: boolean = + !poi_pending_for_maltainvest && !poi_not_submitted_for_maltainvest && !poi_verified_for_maltainvest; + + const poi_poa_verified_for_maltainvest = poi_verified_for_maltainvest && poa_verified; + + //bvi-labuan-vanuatu + let poi_acknowledged_for_bvi_labuan_vanuatu: boolean = bvi_labuan_vanuatu_jurisdiction_statuses.some(status => + acknowledged_status.includes(status) + ); if (risk_classification === 'high') { - poi_acknowledged_for_bvi_labuan = onfido_status && acknowledged_status.includes(onfido_status); + poi_acknowledged_for_bvi_labuan_vanuatu = Boolean(onfido_status && acknowledged_status.includes(onfido_status)); } else { - poi_acknowledged_for_bvi_labuan = - (idv_status && acknowledged_status.includes(idv_status)) || - (onfido_status && acknowledged_status.includes(onfido_status)) || - (manual_status && acknowledged_status.includes(manual_status)); + poi_acknowledged_for_bvi_labuan_vanuatu = bvi_labuan_vanuatu_jurisdiction_statuses.some(status => + acknowledged_status.includes(status) + ); } + const need_poi_for_bvi_labuan_vanuatu = !poi_acknowledged_for_bvi_labuan_vanuatu; + const poi_not_submitted_for_bvi_labuan_vanuatu: boolean = bvi_labuan_vanuatu_jurisdiction_statuses.every( + status => status === 'none' + ); + + const poi_verified_for_bvi_labuan_vanuatu: boolean = bvi_labuan_vanuatu_jurisdiction_statuses.includes('verified'); + + const poi_pending_for_bvi_labuan_vanuatu: boolean = + bvi_labuan_vanuatu_jurisdiction_statuses.includes('pending') && !poi_verified_for_bvi_labuan_vanuatu; + + const poi_resubmit_for_bvi_labuan_vanuatu: boolean = + !poi_pending_for_bvi_labuan_vanuatu && + !poi_not_submitted_for_bvi_labuan_vanuatu && + !poi_verified_for_bvi_labuan_vanuatu; - const need_poi_for_bvi_labuan = !poi_acknowledged_for_bvi_labuan; - const poi_not_submitted_for_bvi_labuan = - idv_status && - onfido_status && - manual_status && - [idv_status, onfido_status, manual_status].every(status => status === 'none'); - - const poi_verified_for_bvi_labuan = [idv_status, onfido_status, manual_status].includes('verified'); - - const poi_pending_for_bvi_labuan = - idv_status && - onfido_status && - manual_status && - [idv_status, onfido_status, manual_status].includes('pending') && - !poi_verified_for_bvi_labuan; - - const poi_resubmit_for_bvi_labuan = - !poi_pending_for_bvi_labuan && !poi_not_submitted_for_bvi_labuan && !poi_verified_for_bvi_labuan; - const poi_poa_verified_for_bvi_labuan = poi_verified_for_bvi_labuan && poa_verified; + const poi_poa_verified_for_bvi_labuan_vanuatu: boolean = poi_verified_for_bvi_labuan_vanuatu && poa_verified; const poa_resubmit_for_labuan = is_authenticated_with_idv_photoid; return { @@ -344,27 +381,27 @@ export const getAuthenticationStatusInfo = (account_status: GetAccountStatus) => onfido_status, manual_status, acknowledged_status, - poi_acknowledged_for_vanuatu_maltainvest, - poi_poa_verified_for_bvi_labuan, + poi_acknowledged_for_maltainvest, + poi_poa_verified_for_bvi_labuan_vanuatu, poa_acknowledged, - poi_poa_verified_for_vanuatu_maltainvest, + poi_poa_verified_for_maltainvest, need_poa_submission, - poi_verified_for_vanuatu_maltainvest, - poi_acknowledged_for_bvi_labuan, - poi_verified_for_bvi_labuan, + poi_verified_for_maltainvest, + poi_acknowledged_for_bvi_labuan_vanuatu, + poi_verified_for_bvi_labuan_vanuatu, poa_verified, poi_or_poa_not_submitted, need_poa_resubmission, poi_and_poa_not_submitted, poa_not_submitted, poi_not_submitted, - need_poi_for_vanuatu_maltainvest, - need_poi_for_bvi_labuan, - poi_not_submitted_for_vanuatu_maltainvest, - poi_pending_for_bvi_labuan, - poi_pending_for_vanuatu_maltainvest, - poi_resubmit_for_vanuatu_maltainvest, - poi_resubmit_for_bvi_labuan, + need_poi_for_maltainvest, + need_poi_for_bvi_labuan_vanuatu, + poi_not_submitted_for_maltainvest, + poi_pending_for_bvi_labuan_vanuatu, + poi_pending_for_maltainvest, + poi_resubmit_for_maltainvest, + poi_resubmit_for_bvi_labuan_vanuatu, poa_pending, poa_resubmit_for_labuan, is_idv_revoked, diff --git a/packages/shared/src/utils/helpers/__tests__/format-response.ts b/packages/shared/src/utils/helpers/__tests__/format-response.ts index a4ecc34cbea8..c1b54cf27d52 100644 --- a/packages/shared/src/utils/helpers/__tests__/format-response.ts +++ b/packages/shared/src/utils/helpers/__tests__/format-response.ts @@ -1,6 +1,7 @@ -import { formatPortfolioPosition } from '../format-response'; +import { GetSettings, ResidenceList } from '@deriv/api-types'; +import { formatPortfolioPosition, isVerificationServiceSupported } from '../format-response'; -describe('formatPortfolioPosition', () => { +describe('format-response', () => { const mock_active_symbols = [{ display_name: 'Volatility 25 Index', symbol: 'R_25' }]; const portfolio_pos = { buy_price: 2500.5, @@ -13,7 +14,82 @@ describe('formatPortfolioPosition', () => { transaction_id: 5678, }; - it('should return an object with values in object passed as argument', () => { + const get_settings: GetSettings = { + account_opening_reason: '', + address_city: 'MUDGEERABA', + address_line_1: "29 Ross Street, .'", + address_line_2: ".'", + address_postcode: '111', + address_state: '', + allow_copiers: 0, + citizen: '', + client_tnc_status: 'Version 4.2.0 2020-08-07', + country: 'Singapore', + country_code: 'sg', + date_of_birth: 984960000, + email: 'mock@gmail.com', + email_consent: 1, + feature_flag: { + wallet: 0, + }, + first_name: 'deriv', + has_secret_answer: 1, + immutable_fields: ['residence'], + is_authenticated_payment_agent: 0, + last_name: 'am', + non_pep_declaration: 1, + phone: '+651213456', + place_of_birth: null, + preferred_language: 'EN', + request_professional_status: 0, + residence: 'Singapore', + salutation: '', + tax_identification_number: null, + tax_residence: null, + user_hash: 'mock_hash', + }; + + const residence_list: ResidenceList = [ + { + disabled: 'DISABLED', + identity: { + services: { + idv: { + documents_supported: {}, + has_visual_sample: 0, + is_country_supported: 0, + }, + onfido: { + documents_supported: { + driving_licence: { + display_name: 'Driving Licence', + }, + national_identity_card: { + display_name: 'National Identity Card', + }, + passport: { + display_name: 'Passport', + }, + }, + is_country_supported: 1, + }, + }, + }, + phone_idd: '65', + text: 'Singapore', + tin_format: [ + '^[SsTtFfGg]\\d{7}[A-Za-z]$', + '^[A-Za-z]{9,10}$', + '^[Ff]0000\\d{6}$', + '^[Ff]\\d{9}$', + '^([Ss]|[Tt][4])\\d{9}$', + '^[Aa]\\d{9}$', + ], + value: 'sg', + }, + ]; + + it('should return an object with values in object passed as argument to formatPortfolioPosition', () => { expect(formatPortfolioPosition(portfolio_pos, mock_active_symbols)).toEqual({ details: 'test
test
test', display_name: 'Volatility 25 Index', @@ -28,4 +104,8 @@ describe('formatPortfolioPosition', () => { contract_info: portfolio_pos, }); }); + + it('should return true if residence is in the list of supported countries for onfido', () => { + expect(isVerificationServiceSupported(residence_list, get_settings, 'onfido')).toBeTruthy(); + }); }); diff --git a/packages/shared/src/utils/helpers/format-response.ts b/packages/shared/src/utils/helpers/format-response.ts index 5cb8f2baac36..7f111cd1c063 100644 --- a/packages/shared/src/utils/helpers/format-response.ts +++ b/packages/shared/src/utils/helpers/format-response.ts @@ -1,3 +1,4 @@ +import { GetSettings, ResidenceList } from '@deriv/api-types'; import { getUnsupportedContracts } from '../constants'; import { getSymbolDisplayName, TActiveSymbols } from './active-symbols'; import { getMarketInformation } from './market-underlying'; @@ -54,3 +55,15 @@ export const formatPortfolioPosition = ( contract_update: portfolio_pos.limit_order, }; }; + +export const isVerificationServiceSupported = ( + residence_list: ResidenceList, + account_settings: GetSettings, + service: 'idv' | 'onfido' +): boolean => { + const citizen = account_settings?.citizen || account_settings?.country_code; + if (!citizen) return false; + const citizen_data = residence_list.find(item => item.value === citizen); + + return !!citizen_data?.identity?.services?.[service]?.is_country_supported; +};