Skip to content

Commit

Permalink
Revert "Sync with master to get latest update (#9750)"
Browse files Browse the repository at this point in the history
This reverts commit 0dcb820.
  • Loading branch information
vinu-deriv committed Aug 25, 2023
1 parent 0dcb820 commit c20f2e4
Show file tree
Hide file tree
Showing 438 changed files with 6,561 additions and 9,148 deletions.
14 changes: 7 additions & 7 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
# deriv-app/account
# ==============================================================

/packages/account/**/* @matin-deriv @amina-deriv @maryia-deriv
/packages/account/**/* @matin-deriv @amina-deriv


# ==============================================================
Expand Down Expand Up @@ -118,13 +118,13 @@
# ==============================================================

/packages/api/**/* @ali-hosseini-deriv @matin-deriv
/packages/core/**/* @ali-hosseini-deriv @matin-deriv @maryia-deriv
/packages/shared/**/* @ali-hosseini-deriv @matin-deriv @maryia-deriv
/packages/components/**/* @ali-hosseini-deriv @matin-deriv @maryia-deriv
/packages/translations/**/* @ali-hosseini-deriv @matin-deriv @maryia-deriv
/packages/utils/**/* @ali-hosseini-deriv @matin-deriv @maryia-deriv
/packages/core/**/* @ali-hosseini-deriv @matin-deriv
/packages/shared/**/* @ali-hosseini-deriv @matin-deriv
/packages/components/**/* @ali-hosseini-deriv @matin-deriv
/packages/translations/**/* @ali-hosseini-deriv @matin-deriv
/packages/utils/**/* @ali-hosseini-deriv @matin-deriv
/packages/hooks/**/* @ali-hosseini-deriv @matin-deriv
/packages/stores/**/* @ali-hosseini-deriv @matin-deriv @maryia-deriv
/packages/stores/**/* @ali-hosseini-deriv @matin-deriv


# ==============================================================
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
},
"dependencies": {
"@binary-com/binary-document-uploader": "^2.4.8",
"@deriv/api-types": "^1.0.116",
"@deriv/api-types": "^1.0.94",
"@deriv/components": "^1.0.0",
"@deriv/hooks": "^1.0.0",
"@deriv/shared": "^1.0.0",
"@deriv/stores": "^1.0.0",
"@deriv/stores":"^1.0.0",
"@deriv/translations": "^1.0.0",
"bowser": "^2.9.0",
"classnames": "^2.2.6",
Expand Down
3 changes: 0 additions & 3 deletions packages/account/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ const App = ({ passthrough }: TAppProps) => {
const { root_store, WS } = passthrough;
setWebsocket(WS);

const { notification_messages_ui: Notifications } = root_store.ui;

return (
<StoreProvider store={root_store}>
{Notifications && <Notifications />}
<Routes />
<ResetTradingPassword />
</StoreProvider>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import * as React from 'react';
import { StaticUrl } from '@deriv/components';
import { Localize, localize } from '@deriv/translations';
Expand Down Expand Up @@ -28,4 +29,8 @@ const AccountLimitsArticle = ({ is_from_derivgo }: TAccountLimitsArticle) => {
return <AccountArticle title={localize('Account limits')} descriptions={getDescription()} />;
};

AccountLimitsArticle.propTypes = {
is_from_derivgo: PropTypes.bool,
};

export default AccountLimitsArticle;
40 changes: 31 additions & 9 deletions packages/account/src/Components/forms/idv-form.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
import React from 'react';
import classNames from 'classnames';
import { Field, FieldProps } from 'formik';
import { Field, FormikProps, FormikHandlers, FieldProps } from 'formik';
import { ResidenceList } from '@deriv/api-types';
import { localize } from '@deriv/translations';
import { formatInput, getIDVNotApplicableOption } from '@deriv/shared';
import { formatInput, IDV_NOT_APPLICABLE_OPTION } from '@deriv/shared';
import { Autocomplete, DesktopWrapper, Input, MobileWrapper, SelectNative, Text } from '@deriv/components';
import { getDocumentData, preventEmptyClipboardPaste, generatePlaceholderText, getExampleFormat } from 'Helpers/utils';
import { TDocumentList, TIDVForm } from 'Types';

type TDocumentList = Array<{
id: string;
text: string;
value?: string;
sample_image?: string;
example_format?: string;
additional?: any;
}>;

type TFormProps = {
document_type: TDocumentList[0];
document_number: string;
document_additional?: string;
error_message?: string;
};

type TIDVForm = {
selected_country: ResidenceList[0];
hide_hint?: boolean;
class_name?: string;
can_skip_document_verification: boolean;
} & Partial<FormikHandlers> &
FormikProps<TFormProps>;

const IDVForm = ({
errors,
Expand All @@ -19,7 +43,7 @@ const IDVForm = ({
hide_hint,
can_skip_document_verification = false,
}: TIDVForm) => {
const [document_list, setDocumentList] = React.useState<TDocumentList[]>([]);
const [document_list, setDocumentList] = React.useState<TDocumentList>([]);
const [document_image, setDocumentImage] = React.useState<string | null>(null);
const [selected_doc, setSelectedDoc] = React.useState('');

Expand All @@ -33,8 +57,6 @@ const IDVForm = ({
sample_image: '',
};

const IDV_NOT_APPLICABLE_OPTION = React.useMemo(() => getIDVNotApplicableOption(), []);

React.useEffect(() => {
if (document_data && selected_country && selected_country.value) {
const document_types = Object.keys(document_data);
Expand Down Expand Up @@ -78,7 +100,7 @@ const IDVForm = ({
setDocumentList([...new_document_list]);
}
}
}, [document_data, selected_country, can_skip_document_verification, IDV_NOT_APPLICABLE_OPTION]);
}, [document_data, selected_country, can_skip_document_verification]);

const resetDocumentItemSelected = () => {
setFieldValue('document_type', default_document, true);
Expand All @@ -98,7 +120,7 @@ const IDVForm = ({
setFieldValue(document_name, current_input, true);
};

const bindDocumentData = (item: TDocumentList) => {
const bindDocumentData = (item: TDocumentList[0]) => {
setFieldValue('document_type', item, true);
setSelectedDoc(item?.id);
if (item?.id === IDV_NOT_APPLICABLE_OPTION.id) {
Expand Down Expand Up @@ -149,7 +171,7 @@ const IDVForm = ({
}
}}
onChange={handleChange}
onItemSelection={(item: TDocumentList) => {
onItemSelection={(item: TDocumentList[0]) => {
if (
item.text === 'No results found' ||
!item.text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
isDesktop,
isMobile,
PlatformContext,
getIDVNotApplicableOption,
IDV_NOT_APPLICABLE_OPTION,
removeEmptyPropertiesFromObject,
} from '@deriv/shared';
import { localize, Localize } from '@deriv/translations';
Expand Down Expand Up @@ -83,7 +83,6 @@ const PersonalDetails = ({
residence_list,
real_account_signup_target,
});
const IDV_NOT_APPLICABLE_OPTION = React.useMemo(() => getIDVNotApplicableOption(), []);

const validateIDV = values => {
const errors = {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { Button } from '@deriv/components';
import { Formik } from 'formik';
import { localize } from '@deriv/translations';
import {
WS,
getIDVNotApplicableOption,
IDV_NOT_APPLICABLE_OPTION,
toMoment,
filterObjProperties,
isDesktop,
removeEmptyPropertiesFromObject,
formatIDVFormValues,
} from '@deriv/shared';
import { documentAdditionalError, getRegex, validate, makeSettingsRequest, validateName } from 'Helpers/utils';
import FormFooter from 'Components/form-footer';
import BackButtonIcon from 'Assets/ic-poi-back-btn.svg';
import IDVForm from 'Components/forms/idv-form';
import PersonalDetailsForm from 'Components/forms/personal-details-form';
import FormSubHeader from 'Components/form-sub-header';
import { GetSettings, IdentityVerificationAddDocumentResponse, ResidenceList } from '@deriv/api-types';
import { TIDVFormValues, TInputFieldValues, TDocumentList } from 'Types';

type TIDVDocumentSubmitProps = {
account_settings: GetSettings;
getChangeableFields: () => Array<string>;
handleBack: React.MouseEventHandler;
handleViewComplete: () => void;
is_from_external: boolean;
selected_country: ResidenceList[0];
};

const IdvDocumentSubmit = ({
handleBack,
Expand All @@ -37,7 +26,7 @@ const IdvDocumentSubmit = ({
is_from_external,
account_settings,
getChangeableFields,
}: TIDVDocumentSubmitProps) => {
}) => {
const visible_settings = ['first_name', 'last_name', 'date_of_birth'];
const form_initial_values = filterObjProperties(account_settings, visible_settings) || {};

Expand All @@ -59,29 +48,28 @@ const IdvDocumentSubmit = ({
...form_initial_values,
};

const getExampleFormat = (example_format: string) => {
const getExampleFormat = example_format => {
return example_format ? localize('Example: ') + example_format : '';
};
const IDV_NOT_APPLICABLE_OPTION = React.useMemo(() => getIDVNotApplicableOption(), []);

const shouldHideHelperImage = (document_id: string) => document_id === IDV_NOT_APPLICABLE_OPTION.id;
const shouldHideHelperImage = document_id => document_id === IDV_NOT_APPLICABLE_OPTION.id;

const isDocumentTypeValid = (document_type: TDocumentList) => {
const isDocumentTypeValid = document_type => {
if (!document_type?.text) {
return localize('Please select a document type.');
}
return undefined;
};

const isAdditionalDocumentValid = (document_type: TDocumentList, document_additional: string) => {
const isAdditionalDocumentValid = (document_type, document_additional) => {
const error_message = documentAdditionalError(document_additional, document_type.additional?.format);
if (error_message) {
return localize(error_message) + getExampleFormat(document_type.additional?.example_format);
}
return undefined;
};

const isDocumentNumberValid = (document_number: string, document_type: Required<TDocumentList>) => {
const isDocumentNumberValid = (document_number, document_type) => {
const is_document_number_invalid = document_number === document_type.example_format;
if (!document_number) {
return localize('Please enter your document number. ') + getExampleFormat(document_type.example_format);
Expand All @@ -95,8 +83,8 @@ const IdvDocumentSubmit = ({
return undefined;
};

const validateFields = (values: TIDVFormValues) => {
const errors: Partial<TInputFieldValues> = {};
const validateFields = values => {
const errors = {};
const { document_type, document_number, document_additional } = values;
const needs_additional_document = !!document_type.additional;

Expand Down Expand Up @@ -139,22 +127,25 @@ const IdvDocumentSubmit = ({
setSubmitting(false);
return;
}

const submit_data = {
identity_verification_document_add: 1,
...formatIDVFormValues(values, selected_country.value),
document_number: values.document_number,
document_additional: values.document_additional || '',
document_type: values.document_type.id,
issuing_country: selected_country.value,
};

WS.send(submit_data).then(
(response: IdentityVerificationAddDocumentResponse & { error: { message: string } }) => {
setSubmitting(false);
if (response.error) {
setErrors({ error_message: response.error.message });
return;
}
handleViewComplete();
if (submit_data.document_type === IDV_NOT_APPLICABLE_OPTION.id) {
return;
}
WS.send(submit_data).then(response => {
setSubmitting(false);
if (response.error) {
setErrors({ error_message: response.error.message });
return;
}
);
handleViewComplete();
});
};

return (
Expand Down Expand Up @@ -234,4 +225,13 @@ const IdvDocumentSubmit = ({
);
};

IdvDocumentSubmit.propTypes = {
account_settings: PropTypes.object,
getChangeableFields: PropTypes.func,
handleBack: PropTypes.func,
handleViewComplete: PropTypes.func,
is_from_external: PropTypes.bool,
selected_country: PropTypes.object,
};

export default IdvDocumentSubmit;
Loading

0 comments on commit c20f2e4

Please sign in to comment.