Skip to content

Commit

Permalink
shahzaib/WALL-756/allow idv for vanuatu jurisdiction on MT5 (binary-c…
Browse files Browse the repository at this point in the history
…om#8907)

* chore: allow idv for vanuatu jurisdiction on MT5

* chore: update document status message in jurisdiction cards regarding idv

* refactor: shared util function to check idv supported resident

* refactor: util function to get supported verification service

* chore: added flag to check if idv is disallowed

* fix: failing test cases

* refactor: refactoring the condition for better readability and conciseness

* refactor: nullish coalescing operator

* refactor: updated type for authenticationStatusInfo util function

* chore: updated conditions regarding the vanuatu idv support in cfd

* chore: updated conditions regarding the vanuatu idv support in cfd

* chore: minor condition update

* chore: update poa condition to poi in card banner

* chore: resolve review comments

* chore: prevent idv for eu region selection

* refactor: condition to check verification status for maltainvest in cfd

* refactor: renamed status variable for better readability

* refactor: renamed status variable name

* chore: update jurisdiction content

* chore: update jurisdiction title indicator

* chore: update test case

* chore: update test case for format-response

* chore: update test case for cfd-poi

* chore: empty commit

* fix: 🐛 resolved incorrect section display (#5)

* fix: failing test cases

---------

Co-authored-by: Shahzaib <shahzaib@deriv.com>
  • Loading branch information
likhith-deriv and shahzaib-deriv committed Jul 26, 2023
1 parent 1af1cc5 commit ca31c81
Show file tree
Hide file tree
Showing 17 changed files with 296 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react-hooks/exhaustive-deps */
import React from 'react';
import { WS, 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';
Expand All @@ -18,22 +18,18 @@ 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();
React.useEffect(() => {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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');
Expand Down
4 changes: 4 additions & 0 deletions packages/cfd/src/Components/__tests__/cfd-poi.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ describe('<CFDPOI />', () => {
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(),
Expand Down
4 changes: 3 additions & 1 deletion packages/cfd/src/Components/cfd-poi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -64,6 +65,7 @@ const CFDPOI = observer(({ index, onSave, onSubmit, height, ...props }: TCFDPOIP
refreshNotifications,
getChangeableFields,
updateAccountStatus,
is_eu_user,
...props,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ describe('<CFDFinancialStpRealAccountSignup />', () => {
storeProofOfAddress: jest.fn(),
},
},
jurisdiction_selected_shortcode: 'svg',
};

it('should render CFDFinancialStpRealAccountSignup component', () => {
Expand All @@ -194,7 +195,7 @@ describe('<CFDFinancialStpRealAccountSignup />', () => {
});

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(<CFDFinancialStpRealAccountSignup />, {
wrapper: ({ children }) => <CFDProviders store={mockStore(mockRootStore)}>{children}</CFDProviders>,
});
Expand Down Expand Up @@ -223,7 +224,7 @@ describe('<CFDFinancialStpRealAccountSignup />', () => {
},
};

getAuthenticationStatusInfo.mockReturnValueOnce({ need_poi_for_vanuatu_maltainvest: true });
getAuthenticationStatusInfo.mockReturnValueOnce({ need_poi_for_bvi_labuan_vanuatu: true });

render(<CFDFinancialStpRealAccountSignup />, {
wrapper: ({ children }) => <CFDProviders store={mockStore(new_mock_store)}>{children}</CFDProviders>,
Expand All @@ -243,7 +244,7 @@ describe('<CFDFinancialStpRealAccountSignup />', () => {
},
};

getAuthenticationStatusInfo.mockReturnValueOnce({ need_poi_for_vanuatu_maltainvest: true });
getAuthenticationStatusInfo.mockReturnValueOnce({ need_poi_for_maltainvest: true });

render(<CFDFinancialStpRealAccountSignup />, {
wrapper: ({ children }) => <CFDProviders store={mockStore(new_mock_store)}>{children}</CFDProviders>,
Expand Down
23 changes: 10 additions & 13 deletions packages/cfd/src/Containers/cfd-dbvi-onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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 = () => {
Expand Down
10 changes: 4 additions & 6 deletions packages/cfd/src/Containers/cfd-password-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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:
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 &&
Expand All @@ -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 &&
Expand All @@ -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
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,36 @@ 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,
} = getAuthenticationStatusInfo(account_status);

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';
}
}
Expand Down
Loading

0 comments on commit ca31c81

Please sign in to comment.