Skip to content

Commit

Permalink
Amina/ COJ-674/fix: verified_status for MT5 jurisdictions for POA sub…
Browse files Browse the repository at this point in the history
…mission (deriv-com#14675)

* fix: verified_status

* fix: test cases

* fix: update master
  • Loading branch information
amina-deriv authored and vinu-deriv committed May 28, 2024
1 parent 53dfd2d commit 19f55ba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('<CFDFinancialStpRealAccountSignup />', () => {
jest.clearAllMocks();
});

const authenticated_with_idv = {
const verified_jurisdiction = {
bvi: 1,
labuan: 1,
maltainvest: 0,
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('<CFDFinancialStpRealAccountSignup />', () => {
account_status: {
authentication: {
document: {
authenticated_with_idv,
verified_jurisdiction,
status: 'none',
},
attempts: {
Expand Down Expand Up @@ -256,7 +256,7 @@ describe('<CFDFinancialStpRealAccountSignup />', () => {
});

it('should check for POA status when Jurisdiction is Labuan and resubmit status is set to true', () => {
const authenticated_with_idv = {
const verified_jurisdiction = {
bvi: 1,
labuan: 0,
maltainvest: 0,
Expand All @@ -271,7 +271,7 @@ describe('<CFDFinancialStpRealAccountSignup />', () => {
account_status: {
authentication: {
document: {
authenticated_with_idv,
verified_jurisdiction,
status: 'none',
},
attempts: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('<RealAccountSignupVerifications />', () => {
jest.clearAllMocks();
});

const authenticated_with_idv = {
const verified_jurisdiction = {
bvi: 1,
labuan: 1,
maltainvest: 0,
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('<RealAccountSignupVerifications />', () => {
account_status: {
authentication: {
document: {
authenticated_with_idv,
verified_jurisdiction,
status: 'none',
},
attempts: {
Expand Down Expand Up @@ -256,7 +256,7 @@ describe('<RealAccountSignupVerifications />', () => {
});

it('should check for POA status when Jurisdiction is Labuan and resubmit status is set to true', () => {
const authenticated_with_idv = {
const verified_jurisdiction = {
bvi: 1,
labuan: 0,
maltainvest: 0,
Expand All @@ -271,7 +271,7 @@ describe('<RealAccountSignupVerifications />', () => {
account_status: {
authentication: {
document: {
authenticated_with_idv,
verified_jurisdiction,
status: 'none',
},
attempts: {
Expand Down
18 changes: 6 additions & 12 deletions packages/shared/src/utils/cfd/cfd.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { DetailsOfEachMT5Loginid, GetAccountStatus, LandingCompany } from '@deriv/api-types';
import { localize } from '@deriv/translations';

import { CFD_PLATFORMS } from '../platform';
import { Jurisdiction, JURISDICTION_MARKET_TYPES } from '../constants/jurisdictions-config';
import { AUTH_STATUS_CODES, Jurisdiction, JURISDICTION_MARKET_TYPES } from '../constants';

let CFD_text_translated: { [key: string]: () => void };

Expand Down Expand Up @@ -513,15 +512,10 @@ export const getMT5AccountTitle = ({ account_type, jurisdiction }: TGetMT5Accoun
};

export const isPOARequiredForMT5 = (account_status: GetAccountStatus, jurisdiction_shortcode: string) => {
const { authentication } = account_status || {};

if (authentication?.attempts?.latest?.service === 'idv') {
if (authentication?.document?.status === 'pending') {
return false;
}
// @ts-expect-error as the prop authenticated_with_idv is not yet present in GetAccountStatus
return !authentication?.document?.authenticated_with_idv[jurisdiction_shortcode];
const { document } = account_status?.authentication || {};
if (document?.status === AUTH_STATUS_CODES.PENDING) {
return false;
}

return !['pending', 'verified'].includes(authentication?.document?.status ?? '');
// @ts-expect-error as the prop verified_jurisdiction is not yet present in GetAccountStatu
return !document?.verified_jurisdiction[jurisdiction_shortcode];
};
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ const Verification: FC<TVerificationProps> = ({ selectedJurisdiction }) => {
const selectedMarketType = getModalState('marketType') ?? 'all';
const platform = getModalState('platform') ?? PlatformDetails.mt5.platform;

const shouldSubmitPOA = useMemo(
() => !poaStatus?.has_attempted_poa || (!poaStatus?.is_pending && !poaStatus.is_verified),
[poaStatus]
);
const shouldSubmitPOA = useMemo(() => {
if (poaStatus?.is_pending) return false;
// @ts-expect-error as the prop verified_jurisdiction is not yet present in GetAccountStatusResponse type
return selectedJurisdiction ? !poaStatus?.verified_jurisdiction?.[selectedJurisdiction] : false;
}, [selectedJurisdiction, poaStatus]);

const shouldFillPersonalDetails = useMemo(
() => !settings?.has_submitted_personal_details,
[settings?.has_submitted_personal_details]
Expand Down

0 comments on commit 19f55ba

Please sign in to comment.