From 714d4d6506f1924dea7e4c5c2d0339c862fff2ce Mon Sep 17 00:00:00 2001 From: Likhith Kolayari <98398322+likhith-deriv@users.noreply.github.com> Date: Mon, 27 Nov 2023 15:03:40 +0400 Subject: [PATCH] Likhith/wall 1728/impriove error message for high risk client (#10942) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * style: fix side container width in poi (#39) * style: container height fix for POI error messages when content in not overflowing (#40) * fix: onfido message alignment * fix: :bug: incorporated continue trade button * fix: onfido page mobile * style: no padding on fields container in idv screen (#41) * refactor: onfido hint center alignment fix * fix: odd translate value fix * fix: :bug: minor CSS fix * fix: green message responsive position * fix: green message full width * fix: :white_check_mark: updated testcases * fix: failing tests * refactor: code and ts fixes * fix: display of IDV error * chore: add duplication account error * refactor: added undefined check to response data * chore: review comments * chore: review comments * fix: :arrow_up: upgraded SDK and handled language change * fix: :recycle: incorporated review comments * fix: :recycle: refactored code to remove useRef * fix: barriers test fix form master * fix: barriers test * chore: refactored object.freeze to as const * chore: optional chaining to document type * chore: update spec file for idv-form * test: update personal-details spec * chore: review comments * refactor: :recycle: incorporated hooks to handle business logic * refactor: css structure * fix: barriers test * fix: :coffin: removed unwanted code * test: :fire: removed mocked tokens * chore: :memo: Added documentation for UseNotificationEvent hook * fix: :lipstick: incorporated styling * fix: :recycle: incorporated review comments * refactor: rename properties * refactor: remove is_appstore from tests * fix: :recycle: incorporated review comments * refactor: styles refactor * fix: :zap: reduced duplicate data * fix: incorporated review comments * fix: :recycle: incorporated review comments * chore: Trigger Build * fix: :truck: modified path * chore: remove unused fila and variable, updated icons * revert: :beers: removed icon changes * refactor: removed formatting * fix: removed assignment of default values * fix: :bug: unable to select a new doc supporting country * fix: :bug: resolved re-render issue * fix: :zap: resolved message issue * refactor: :truck: renamed varibales * fix: :test_tube: failing testcase * fix: :bug: resolved issues with failure messages * fix: :bug: resolved issue with DIEL accounts * fix: :bug: fixed issue for DIEL clients * fix: styling issues * fix: ts error for format-response * build: :pushpin: updated package-lock after updating onfido-sdk-ui * fix: :truck: fixed path * fix: :truck: fixed path * fix: :bug: resolved styling bugs * fix: :bug: resolved styling bugs * fix: :recycle: removed default values * fix: :fire: incorporated new styles to fix icon size * fix: :fire: incorporated new styles to fix icon size * fix: :white_check_mark: fixed failing testcase * fix: :green_heart: eslint issues * fix: :zap: incorporated platform language change * fix: removed store * fix: layout styles * fix: style issues * fix: styles * fix: moved common styles to core * refactor: incorporated review comments * fix: :lipstick: updated styles * fix: :bug: reverted code * fix: :bug: reverted code * refactor: incorporated review comments * fix: :bug: Onfido SDK language code conversion * fix: migrated hooks * revert: logic for generating code * chore: adding missing testcases * fix: recatored Onfido constants * fix: onfido screen css issues * fix: removed package-lock to resolve merge error * Merge branch 'master' into likhith/KYC-363/onfido-sdk-updation * chore: added package-lock * Merge branch 'master' into combined/wall-400/IDV-error-message-handled * chore: Trigger Build * fix: bug: /WEBREL-1358/personal-details page and poa page css issue * fix: layout button * fix: layout button * fix: mt5 next button not getting enabled * fix: resolved issue with button * fix: resolved issue with button * fix: resolved missing dropdown * fix: removed console * fix: incorporated review comments * feat: :sparkles: incorporated new images and merged checkbox feature * feat: :sparkles: incorporated new images and merged checkbox feature * fix: idv failed document type * fix: removed duplicate import * fix: incorporated error message scenario * fix: styling as per new figma * fix: styling as per new figma * fix: spacing between fields * fix: spacing between fields * fix: spacing between fields * fix: incorporated new error code and styles as per new figma * fix: incorporated new error code and styles as per new figma * Merge branch 'master' into likhith/kyc-195/display-idv-error-messages * fix: reverted changes * Incorporate poi context (#55) * chore: incorporate POIContext to keep track of submission * chore: reset poi context state upon route change * refactor: added reset for all path * fix: changed testcases --------- Co-authored-by: Likhith Kolayari * feat: added message for High risk * refactor: incorporated review comment * fix: added the right check for high-risk * refactor: incorporated review comments * fix: resolved issues pointed out in sonar-cloud * fix: code smells * chore: trigger rebuild * fix: issue with checkbox * fix: added CSS changes to resolve the spacing * fix: added CSS changes to resolve the spacing * fix: removed unused import * fix: added keyboard event * fix: resolved build failure * Merge branch 'master' into likhith/KYC-363/onfido-sdk-updation * fix: Onfido styles * fix: resolved code-smells * fix: Content changes --------- Co-authored-by: yauheni-deriv <103182683+yauheni-deriv@users.noreply.github.com> Co-authored-by: Shahzaib Co-authored-by: “yauheni-kryzhyk-deriv” <“yauheni@deriv.me”> --- .../__tests__/poi-country-selector.spec.tsx | 12 ++++++++++++ .../poi-country-selector.tsx | 5 +++++ .../proof-of-identity-submission.jsx | 14 ++++++++++---- packages/hooks/src/useNotificationEvent.ts | 9 ++------- .../src/utils/constants/idv-failure-codes.ts | 1 + .../src/utils/helpers/format-response.ts | 18 +++++++++++++----- 6 files changed, 43 insertions(+), 16 deletions(-) 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 = (