Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "yauheni/likhith/Combined/wall 400/idv error message handled" #10497

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/account/src/Assets/ic-poi-dob-example.svg

This file was deleted.

1 change: 0 additions & 1 deletion packages/account/src/Assets/ic-poi-name-example.svg

This file was deleted.

11 changes: 3 additions & 8 deletions packages/account/src/Components/form-body/form-body.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
import React from 'react';
import { ScrollbarsContainer } from '../scrollbars-container/scrollbars-container';
import { Div100vhContainer, DesktopWrapper, MobileWrapper } from '@deriv/components';
import classNames from 'classnames';

type TFormBody = {
scroll_offset?: string;
className?: string;
};

export const FormBody = ({ children, scroll_offset, className }: React.PropsWithChildren<TFormBody>) => (
export const FormBody = ({ children, scroll_offset }: React.PropsWithChildren<TFormBody>) => (
<React.Fragment>
<DesktopWrapper>
<ScrollbarsContainer
className={classNames('account__scrollbars_container--grid-layout', className)}
scroll_offset={scroll_offset}
>
<ScrollbarsContainer className='account__scrollbars_container--grid-layout' scroll_offset={scroll_offset}>
{children}
</ScrollbarsContainer>
</DesktopWrapper>
<MobileWrapper>
<Div100vhContainer
className={classNames('account__scrollbars_container--grid-layout', className)}
className='account__scrollbars_container--grid-layout'
height_offset={scroll_offset || '200px'}
>
{children}
Expand Down
120 changes: 0 additions & 120 deletions packages/account/src/Components/forms/__tests__/idv-form.spec.tsx

This file was deleted.

96 changes: 48 additions & 48 deletions packages/account/src/Components/forms/idv-form.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
import React from 'react';
import classNames from 'classnames';
import { Field, FormikProps, FieldProps, useFormikContext } from 'formik';
import { ResidenceList } from '@deriv/api-types';
import { Autocomplete, DesktopWrapper, Input, MobileWrapper, SelectNative, Text } from '@deriv/components';
import { formatInput, getIDVNotApplicableOption } from '@deriv/shared';
import { Field, FieldProps } from 'formik';
import { localize } from '@deriv/translations';
import { formatInput, getIDVNotApplicableOption } from '@deriv/shared';
import { Autocomplete, DesktopWrapper, Input, MobileWrapper, SelectNative, Text } from '@deriv/components';
import {
getDocumentData,
preventEmptyClipboardPaste,
generatePlaceholderText,
getExampleFormat,
} from '../../Helpers/utils';
import { TDocument, TIDVFormValues } from '../../Types';

type TIDVFormProps = {
selected_country: ResidenceList[0];
hide_hint?: boolean;
class_name?: string;
can_skip_document_verification?: boolean;
};
import { TDocument, TIDVForm } from 'Types';

const IDVForm = ({
errors,
touched,
values,
handleBlur,
handleChange,
setFieldValue,
class_name,
selected_country,
hide_hint,
can_skip_document_verification = false,
}: TIDVFormProps) => {
const [document_list, setDocumentList] = React.useState<Array<TDocument>>([]);
}: TIDVForm) => {
const [document_list, setDocumentList] = React.useState<TDocument[]>([]);
const [document_image, setDocumentImage] = React.useState<string | null>(null);
const [selected_doc, setSelectedDoc] = React.useState('');

const { documents_supported: document_data, has_visual_sample } = selected_country?.identity?.services?.idv ?? {};

const { errors, touched, values, handleBlur, handleChange, setFieldValue }: FormikProps<TIDVFormValues> =
useFormikContext();
const default_document = {
id: '',
text: '',
Expand Down Expand Up @@ -97,12 +93,10 @@ const IDVForm = ({
};

const onKeyUp = (e: { target: HTMLInputElement }, document_name: string) => {
const example_format =
document_name === 'document_number'
? values?.document_type?.example_format
: values?.document_type?.additional?.example_format;
const { example_format } =
document_name === 'document_number' ? values.document_type : values.document_type.additional;
let current_input: string | null = null;
current_input = example_format?.includes('-')
current_input = example_format.includes('-')
? formatInput(example_format, current_input ?? e.target.value, '-')
: e.target.value;
setFieldValue(document_name, current_input, true);
Expand Down Expand Up @@ -141,32 +135,38 @@ const IDVForm = ({
{({ field }: FieldProps) => (
<React.Fragment>
<DesktopWrapper>
<Autocomplete
{...field}
data-lpignore='true'
error={touched.document_type && errors.document_type}
autoComplete='off'
type='text'
label={localize('Choose the document type')}
list_items={document_list}
value={values.document_type.text}
onBlur={(e: { target: HTMLInputElement }) => {
handleBlur(e);
if (!getDocument(e.target.value)) {
resetDocumentItemSelected();
}
}}
onChange={handleChange}
onItemSelection={(item: TDocument) => {
if (item.text === 'No results found' || !item.text) {
setSelectedDoc('');
resetDocumentItemSelected();
} else {
bindDocumentData(item);
}
}}
required
/>
<div className='document-dropdown'>
<Autocomplete
{...field}
name='document_type'
data-lpignore='true'
error={touched.document_type && errors.document_type}
autoComplete='off'
type='text'
label={localize('Choose the document type')}
list_items={document_list}
value={values.document_type.text}
onBlur={(e: { target: HTMLInputElement }) => {
handleBlur(e);
if (!getDocument(e.target.value)) {
resetDocumentItemSelected();
}
}}
onChange={handleChange}
onItemSelection={(item: TDocument) => {
if (
item.text === 'No results found' ||
!item.text
) {
setSelectedDoc('');
resetDocumentItemSelected();
} else {
bindDocumentData(item);
}
}}
required
/>
</div>
</DesktopWrapper>
<MobileWrapper>
<SelectNative
Expand All @@ -193,7 +193,7 @@ const IDVForm = ({
)}
</Field>
</fieldset>
{values?.document_type?.id !== IDV_NOT_APPLICABLE_OPTION.id && (
{values.document_type.id !== IDV_NOT_APPLICABLE_OPTION.id && (
<fieldset
className={classNames({
'proof-of-identity__fieldset-input': !hide_hint,
Expand Down
Loading
Loading