Skip to content

Commit

Permalink
Likhith/wall 1728/impriove error message for high risk client (deriv-…
Browse files Browse the repository at this point in the history
…com#10942)

* style: fix side container width in poi (deriv-com#39)

* style: container height fix for POI error messages when content in not overflowing (deriv-com#40)

* fix: onfido message alignment

* fix: 🐛 incorporated continue trade button

* fix: onfido page mobile

* style: no padding on fields container in idv screen (deriv-com#41)

* refactor: onfido hint center alignment fix

* fix: odd translate value fix

* fix: 🐛 minor CSS fix

* fix: green message responsive position

* fix: green message full width

* fix: ✅ 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: ⬆️ upgraded SDK and handled language change

* fix: ♻️ incorporated review comments

* fix: ♻️ 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: ♻️ incorporated hooks to handle business logic

* refactor: css structure

* fix: barriers test

* fix: ⚰️ removed unwanted code

* test: 🔥 removed mocked tokens

* chore: 📝 Added documentation for UseNotificationEvent hook

* fix: 💄 incorporated styling

* fix: ♻️ incorporated review comments

* refactor: rename properties

* refactor: remove is_appstore from tests

* fix: ♻️ incorporated review comments

* refactor: styles refactor

* fix: ⚡ reduced duplicate data

* fix: incorporated review comments

* fix: ♻️ incorporated review comments

* chore: Trigger Build

* fix: 🚚 modified path

* chore: remove unused fila and variable, updated icons

* revert: 🍻 removed icon changes

* refactor: removed formatting

* fix: removed assignment of default values

* fix: 🐛 unable to select a new doc supporting country

* fix: 🐛 resolved re-render issue

* fix: ⚡ resolved message issue

* refactor: 🚚 renamed varibales

* fix: 🧪 failing testcase

* fix: 🐛 resolved issues with failure messages

* fix: 🐛 resolved issue with DIEL accounts

* fix: 🐛 fixed issue for DIEL clients

* fix: styling issues

* fix: ts error for format-response

* build: 📌 updated package-lock after updating onfido-sdk-ui

* fix: 🚚 fixed path

* fix: 🚚 fixed path

* fix: 🐛 resolved styling bugs

* fix: 🐛 resolved styling bugs

* fix: ♻️ removed default values

* fix: 🔥 incorporated new styles to fix icon size

* fix: 🔥 incorporated new styles to fix icon size

* fix: ✅ fixed failing testcase

* fix: 💚 eslint issues

* fix: ⚡ 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: 💄 updated styles

* fix: 🐛 reverted code

* fix: 🐛 reverted code

* refactor: incorporated review comments

* fix: 🐛 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: ✨ incorporated new images and merged checkbox feature

* feat: ✨ 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 (deriv-com#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 <likhith@regentmarkets.com>

* 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 <shahzaib@deriv.com>
Co-authored-by: “yauheni-kryzhyk-deriv” <“yauheni@deriv.me”>
  • Loading branch information
4 people authored Nov 27, 2023
1 parent 3649620 commit 714d4d6
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,16 @@ describe('<CountrySelector/>', () => {
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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ const CountrySelector = ({ handleSelectionNext, is_from_external, mismatch_statu
<Localize i18n_default_text='We were unable to verify the identity document with the details provided.' />
);
}
if (mismatch_status === idv_error_statuses.poi_high_risk) {
failed_message = (
<Localize i18n_default_text='For enhanced security, we need to reverify your identity. Kindly resubmit your proof of identity to unlock your account.' />
);
}

return (
<Formik initialValues={initial_form_values} validate={validateFields} onSubmit={submitHandler}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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: {
Expand All @@ -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;
Expand All @@ -114,6 +115,7 @@ const POISubmission = observer(
setSelectedCountry,
setSubmissionService,
setSubmissionStatus,
is_idv_disallowed,
]
);

Expand All @@ -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);
Expand Down
9 changes: 2 additions & 7 deletions packages/hooks/src/useNotificationEvent.ts
Original file line number Diff line number Diff line change
@@ -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'];
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/utils/constants/idv-failure-codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
18 changes: 13 additions & 5 deletions packages/shared/src/utils/helpers/format-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, TIDVErrorStatus> = {
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 => {
Expand All @@ -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 = (
Expand Down

0 comments on commit 714d4d6

Please sign in to comment.