diff --git a/packages/account/src/Components/poi/poi-country-selector/__tests__/poi-country-selector.spec.tsx b/packages/account/src/Components/poi/poi-country-selector/__tests__/poi-country-selector.spec.tsx index c08cd8136db8..be59e5489ce0 100644 --- a/packages/account/src/Components/poi/poi-country-selector/__tests__/poi-country-selector.spec.tsx +++ b/packages/account/src/Components/poi/poi-country-selector/__tests__/poi-country-selector.spec.tsx @@ -126,4 +126,16 @@ describe('', () => { expect(mock_props.handleSelectionNext).toHaveBeenCalledTimes(1); }); }); + + it('should render high risk error message', () => { + mock_props.mismatch_status = 'POI_HIGH_RISK'; + + renderComponent({ props: mock_props }); + + expect( + screen.getByText( + 'For enhanced security, we need to reverify your identity. Kindly resubmit your proof of identity to unlock your account.' + ) + ).toBeInTheDocument(); + }); }); diff --git a/packages/account/src/Components/poi/poi-country-selector/poi-country-selector.tsx b/packages/account/src/Components/poi/poi-country-selector/poi-country-selector.tsx index 9beb162b2524..75066326c3a3 100644 --- a/packages/account/src/Components/poi/poi-country-selector/poi-country-selector.tsx +++ b/packages/account/src/Components/poi/poi-country-selector/poi-country-selector.tsx @@ -57,6 +57,11 @@ const CountrySelector = ({ handleSelectionNext, is_from_external, mismatch_statu ); } + if (mismatch_status === idv_error_statuses.poi_high_risk) { + failed_message = ( + + ); + } return ( diff --git a/packages/account/src/Sections/Verification/ProofOfIdentity/proof-of-identity-submission.jsx b/packages/account/src/Sections/Verification/ProofOfIdentity/proof-of-identity-submission.jsx index b0606dbbb4b7..10dab8e86153 100644 --- a/packages/account/src/Sections/Verification/ProofOfIdentity/proof-of-identity-submission.jsx +++ b/packages/account/src/Sections/Verification/ProofOfIdentity/proof-of-identity-submission.jsx @@ -39,8 +39,9 @@ const POISubmission = observer( const { client, notifications } = useStore(); - const { account_settings, getChangeableFields } = client; + const { account_settings, getChangeableFields, account_status } = client; const { refreshNotifications } = notifications; + const is_high_risk = account_status.risk_classification === 'high'; const handleSelectionNext = () => { if (Object.keys(selected_country).length) { @@ -81,11 +82,12 @@ const POISubmission = observer( const needs_resubmission = has_require_submission || allow_poi_resubmission; - const mismatch_status = formatIDVError(idv.last_rejected, idv.status); + const mismatch_status = formatIDVError(idv.last_rejected, idv.status, is_high_risk); const setIdentityService = React.useCallback( identity_last_attempt => { const { service, country_code } = identity_last_attempt; + setSelectedCountry(getCountryFromResidence(country_code)); switch (service) { case service_code.idv: case service_code.onfido: { @@ -98,7 +100,6 @@ const POISubmission = observer( break; } case service_code.manual: { - setSelectedCountry(getCountryFromResidence(country_code)); setSubmissionService(service_code.manual); setSubmissionStatus(submission_status_code.submitting); break; @@ -114,6 +115,7 @@ const POISubmission = observer( setSelectedCountry, setSubmissionService, setSubmissionStatus, + is_idv_disallowed, ] ); @@ -125,7 +127,11 @@ const POISubmission = observer( setIdentityService(identity_last_attempt); } else if ( mismatch_status && - ![idv_error_statuses.poi_expired, idv_error_statuses.poi_failed].includes(mismatch_status) && + ![ + idv_error_statuses.poi_expired, + idv_error_statuses.poi_failed, + idv_error_statuses.poi_high_risk, + ].includes(mismatch_status) && idv.submissions_left > 0 ) { setSubmissionService(service_code.idv); diff --git a/packages/hooks/src/useNotificationEvent.ts b/packages/hooks/src/useNotificationEvent.ts index 99691b0ca740..44063ec58cf7 100644 --- a/packages/hooks/src/useNotificationEvent.ts +++ b/packages/hooks/src/useNotificationEvent.ts @@ -1,5 +1,5 @@ import React from 'react'; -import { useMutation, useInvalidateQuery } from '@deriv/api'; +import { useMutation } from '@deriv/api'; import { TSocketRequestPayload } from '@deriv/api/types'; type TNotificationEventPayload = TSocketRequestPayload<'notification_event'>['payload']; @@ -10,12 +10,7 @@ type TNotificationEventPayload = TSocketRequestPayload<'notification_event'>['pa * @returns response, mutation function and other properties from useRequest hook */ const useNotificationEvent = () => { - const invalidate = useInvalidateQuery(); - const { data, mutate, ...rest } = useMutation('notification_event', { - onSuccess: () => { - invalidate('notification_event'); - }, - }); + const { data, mutate, ...rest } = useMutation('notification_event'); /** * Function to send notification event to the server diff --git a/packages/shared/src/utils/constants/idv-failure-codes.ts b/packages/shared/src/utils/constants/idv-failure-codes.ts index 5df21e24c9d5..2b19a044278d 100644 --- a/packages/shared/src/utils/constants/idv-failure-codes.ts +++ b/packages/shared/src/utils/constants/idv-failure-codes.ts @@ -4,4 +4,5 @@ export const idv_error_statuses = Object.freeze({ poi_name_mismatch: 'POI_NAME_MISMATCH', poi_expired: 'POI_EXPIRED', poi_failed: 'POI_FAILED', + poi_high_risk: 'POI_HIGH_RISK', }); diff --git a/packages/shared/src/utils/helpers/format-response.ts b/packages/shared/src/utils/helpers/format-response.ts index bd63434ffd40..0521403b7815 100644 --- a/packages/shared/src/utils/helpers/format-response.ts +++ b/packages/shared/src/utils/helpers/format-response.ts @@ -61,19 +61,27 @@ export const formatPortfolioPosition = ( export type TIDVErrorStatus = typeof idv_error_statuses[keyof typeof idv_error_statuses]; //formatIDVError is parsing errors messages from BE (strings) and returns error codes for using it on FE -export const formatIDVError = (errors: string[], status_code: string) => { +export const formatIDVError = (errors: string[], status_code: string, is_high_risk?: boolean) => { /** * Check required incase of DIEL client */ - if (errors.length === 0 && (status_code === STATUS_CODES.NONE || status_code === STATUS_CODES.VERIFIED)) + if ( + errors.length === 0 && + (status_code === STATUS_CODES.NONE || status_code === STATUS_CODES.VERIFIED) && + !is_high_risk + ) { return null; + } + if (is_high_risk && status_code === STATUS_CODES.VERIFIED) { + return idv_error_statuses.poi_high_risk; + } const error_keys: Record = { name: 'POI_NAME_MISMATCH', birth: 'POI_DOB_MISMATCH', rejected: 'POI_FAILED', }; if (status_code === STATUS_CODES.EXPIRED) { - return 'POI_EXPIRED'; + return idv_error_statuses.poi_expired; } const status: TIDVErrorStatus[] = []; errors.forEach(error => { @@ -85,8 +93,8 @@ export const formatIDVError = (errors: string[], status_code: string) => { return status.includes(error_keys.name) && status.includes(error_keys.birth) && !status.includes(error_keys.rejected) - ? 'POI_NAME_DOB_MISMATCH' - : status[0] ?? 'POI_FAILED'; + ? idv_error_statuses.poi_name_dob_mismatch + : status[0] ?? idv_error_statuses.poi_failed; }; export const isVerificationServiceSupported = (