Skip to content

Commit

Permalink
Sync with master to get latest update (#9750)
Browse files Browse the repository at this point in the history
* translations: 📚 sync translations with crowdin (#9672)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* chore: translation workflow trigger (#9684)

* Revert "chore: translation workflow trigger (#9684)" (#9686)

This reverts commit cfacd85.

* Kate / WEBREL-51 / Test coverage: ProgressSliderStream in Trader package (#9464)

* feat: add unit tests

* refactor: incapsulated trade providers

* Kate / Test coverage:  ChartLoader + Loading in Trader package (#8398)

* refactor: add integr and unit tests for loader

* refactor: removed hardcoded test id

* likhith/fix: 🐛 display onfido error message (#9401)

* fix: 🐛 display onfido error message

* fix: reverted change

* test: ✅ added testcases

* fix: test case names

* fix: added testcases

* Henry/fix: test coverage and ts migration for asset/trading/categories (#8483)

* fix: test coverage and ts migration for asset/trading/categories

* fix: codecov issues

* fix: codecov issues

* test: dynamic test component import

* fix: code smell add error handling

* fix: change from FC to componenttype

* fix: circleCi

* fix: circleCI

* fix: circleCi

* fix: failing test

* fix: circleCI

* Matin/WALL-1308/Adding Korean language (#9426)

* chore: adding Korean language

* chore: changed Korean short form to KO from KR

* chore: fix translation issue in login history table

* chore: update all flags to follow the latest design system

* chore: Korean language on P2P

* chore: update deriv-charts to v1.3.2

* chore: empty

* translations: 📚 sync translations with crowdin (#9607)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* chore: empty

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* Amina/fix: disable account when proof failed (#9555)

* fix: disable account when proof failed

* fix: disable account when proof failed

* fix: flag

* fix: import

* fix: update with master

* fix: duplicate_types (#9691)

* likhith/fix: 🐛 translation of IDV documents dropdown option (#9336)

* fix: 🐛 translation of IDV documents dropdown option

* fix: 🐛 translation of default config

* fix: 🐛 translation of default config

* fix: 🐛 removed unused-import

* fix: 🐛 refactored code

* fix: ♻️ incorporated review comments

* fix: 🐛 added missing function

* maryia/DTRA-350/feat: handle displayed positions locally in TogglePositionsMobile (#9610)

* feat: handle displayed positions locally in mobile TogglePositions

* test: added a test

* chore: refactoring

* test: fix tests after conflict resolution

* FarhanNurzi/P2PS-1417/2FA order confirm modal is not showing up on mobile browsers (#9620)

* fix: completed order modal is not showing in mobile

* fix: add test case, fix error in chat component upon creating order

* refactor: destructure order in handleResponse

* Adrienne / Implemented new navigation flow for filtering payment methods in buy/sell page (#8544)

* Create codeql.yml

* Create codeql-test.yml

* chore: removed codeql workflows

* chore: removed dccache

* chore: added escapeHtml function to login

* feat: added new flow for filter modal

* chore: removed old commits

* fix: fixed ui issues regarding requirements

* feat: changed reset flow

* feat: changed flow for reset, added status for filter modal icon

* chore: incorporated reviews

* chore: applied code review changes

* Amina/wall 575/maintenance notifications for site and cashier (#9064)

* fix: notifications_in_cashier_and_accounts

* fix: notification for maintenance

* fix: notification_filter

* fix: notification_filter

* fix: filter notifications in mobile

* fix: code_review_suggestions

* chore: merge master

* chore: resolve conflict

* fix: showing notification in mobile

* Shaheer/wall 1229 (#9240)

* feat: ✨ adds financial assessment notification

* refactor: 🎨 sorts the object block

* feat: ✨ displays financial assessment notification on trigger from backend

* chore: 🚑 resolves merge conflict with master

* test: 🧪 adds test case for app-notification

* test: 🧪 adds test cases for notification

* Kate / OPT-306 / Update Accumulator to Accumulators  (#9577)

* chore: change text

* chore: apply suggestion

* Kate / Add video for Vanillas description (#9622)

* feat: add video for vanilla

* refactor: add tests and change file structure

* refactor: video component and test

* refactor: change folders name and add more videos

* refactor: apply suggestions

* chore: rename data test id

* chore: correct spelling

* chore: remove optional data test id

* refactor: add backup

* fix: tests

* likhith/chore: incorporated the API response to save the opt-out user data (#9618)

* chore: incorporated the API response to save the opt-out user data

* chore: incorporated the API response to save the opt-out user data

* chore: incorporated the API response to save the opt-out user data

* chore: incorporated the API response to save the opt-out user data

* chore: incorporated review comments

* chore: incorporated review comments

* chore: incorporated review comments

* fix: error displayed for MF account creation

* Merge branch 'master' into likhith/KYC-362/track-idv-opt-out-during-account-creation

* translations: 📚 sync translations with crowdin (#9702)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* Matin / Remove ESLint Ignore (#9707)

* chore: fix Oneall social unlinking from Apple accounts

* Revert "chore: fix Oneall social unlinking from Apple accounts"

This reverts commit 84009b0.

* chore: remove eslint ignore

* translations: 📚 sync translations with crowdin (#9709)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* fix: set dbot as external in platform config for authorize logout isssue (#9711)

* feat: transaction details modal (#9032)

* feat: transaction details modal

* feat: complete test cases for TransactionDetails modal

* chore: fix code smells

* chore: fix code smells

* chore: remove code smells

* chore: redeploy

* chore: move transaction details types to types folder

* chore: show enrty and exit tick if available

* fix: transaction scroll css issue fix

* fix: update key with data for divider inside transaction details modal

* fix: update buy price to have decimal value

* fix: css issue on modal height and fixed decimal profit/loss

* fix: fix style for modal getting cut

* fix: modal css issue after build

* fix: decrease the modal height for edge cutting issue

* fix: hide download button on mobile

* fix: gtm issue (#9551)

* fix: registration flow in buy/sell tab (#9573)

* fix: registration flow in buy/sell tab

* fix: added unit test

* Farzin/WALL-460/DepositCrypto module (#8867)

* Merge branch 'master' into farzin/wall-252/replace_the_use_of_cashier_store_in_other_packages_with_shared_hooks

* Merge branch 'farzin/wall-252/replace_the_use_of_cashier_store_in_other_packages_with_shared_hooks' into farzin/wall-434/separate_cashier_onboarding_to_a_new_route

* fix(cashier): 📝 resolve conflict

* feat(cashier): 🔥 remove `AccountPromptDialogStore`

* fix(cashier): ✅ fix failing tests

* feat(cashier): 🔥 remove `onMountCashierOnboarding`

* fix(cashier): ✅ fix `CashierOnboardingP2PCard`

* Merge branch 'master' into farzin/wall-434/separate_cashier_onboarding_to_a_new_route

* Merge branch 'master' into farzin/wall-434/separate_cashier_onboarding_to_a_new_route

* fix(cashier): 🐛 fix dialog issue

* fix(cashier): 📝 resolve PR comments

* refactor(cashier): ♻️ `CashierOnboardingModule` clean-up

* feat(cashier): ✨ add `useDepositCryptoAddress` hook

* feat(cashier): ✨ add `DepositCryptoWalletAddress`

* feat(cashier): ✨ add `DepositCryptoTryFiatOnRamp`

* feat(cashier): ✨ add `DepositCryptoModule`

* feat(cashier): ✨ add `PageContainer`

* refactor(cashier): 🚚 change folder structure

* feat(cashier): ✨ add `PageContainer`

* style(cashier): 💄 update the styles to match with the desing

* fix(cashier): 📝 resolve PR comments

* fix(cashier): 📝 resolve PR comments

* fix(cashier): ✅ fix failing tests

* feat(cashier): ♻️ move `CashierBreadcrumb` to `PageContainer`

* feat(cashier): ✨ add `DepositCryptoCurrencyDetails`

* feat(cashier): ✨ add `DepositCryptoWalletAddress`

* refactor(cashier): 🚚 change folder structure

* style(cashier): 💄 update the styles to match with the design

* feat(cashier): ✨ add `DepositCryptoDisclaimers`

* feat(components): ✨ add `InlineMessage`

* feat(cashier): ♻️ render `RecentTransaction` in `DepositCrypto`

* ci: 💚 trigger build

* refactor(cashier): ♻️ `CashierOnboardingModule` clean-up

* refactor(cashier): ♻️ `CashierOnboardingModule` clean-up

* fix(cashier): 🐛 fix double loader issue while switching accounts

* fix(cashier): ✅ fix failing test

* fix: 🔧 fix `jest.config.js` issue

* ci: 👷 set jest `maxWorkers` to `8`

* ci: 👷 set jest `maxWorkers` to `2`

* refactor(components): 💄 refactor `InlineMessage` component with the new design

* refactor(components): 💄 refactor `InlineMessage` component with the new design

* refactor(components): 🚚 move `SideNote` to components package

* feat(components): ✨ add `InlineMessage` component

* feat(components): ✨ add `SideNote` component

* feat(hooks): ✨ add `useInputDecimalFormatter` hook

* feat(hooks): ✨ add `useInputATMFormatter` hook

* feat(hooks): ✨ add `useCurrencyConfig` hook

* feat(hooks): ✨ add `useDepositCryptoAddress` hook

* fix: 🔧 fix `jest.config.js`

* feat: 🏷️ add `Prettify<T>` utility type

* fix(hooks): ✅ fix failing test

* fix(hooks): ✅ fix failing test

* feat(cashier): ✨ show transaction confirmations number

* feat(cashier): ✨ add `useUnsafeCashierRouteHandler` hook

* feat(cashier): ✨ use `useUnsafeCashierRouteHandler` hook in `AppContent`

* fix(appstore): 🚚 update deposit link in trader hub page

* refactor(cashier): ♻️ refactor cashier onboarding side notes

* feat(cashier): ✨ add `DepositCryptoResentTransactionSideNote`

* fix(cashier): ♻️ replace `is_crypto` with `useCurrencyConfig` hook

* style(cashier): 💄 update the styles

* style(cashier): 💄 update the styles

* style(cashier): 💄 update the styles

* refactor(cashier): 🚚 move components

* Merge branch 'master' into farzin/deposit_crypto_module

* feat(cashier): ✨ add `Confirmations` column to crypto transactions history

* refactor(cashier): ♻️ improve `CashierBreadcrumb`

* refactor(cashier): ♻️ improve `PageContainer`

* refactor(cashier): 🚚 move `SwitchToFiatAccountDialog` to components

* refactor(cashier): ♻️ clean-up cashier onboarding components

* feat(cashier): ✨ add `Confirmations` to recent transaction side note

* fix(cashier): ✅ fix failing test

* fix(cashier): ✅ fix failing test

* Merge remote-tracking branch 'aum-deriv/aum/WALL-297/deposit-fiat-module' into farzin/deposit_crypto_module

* refactor(cashier): 🔥 remove `containers` constant

* refactor(cashier): 🔥 remove `ErrorDialogStore`

* refactor(cashier): 🔥 remove `DepositStore`

* fix(cashier): 📝 resolve conflicts

* fix(cashier): 📝 resolve conflicts

* fix(cashier): 📝 resolve conflicts

* fix(cashier): 📝 resolve conflicts

* fix(cashier): 🐛 fix reaise issues

* refactor(cashier): 🎨 improvements on `CashierOnboardingModule`

* refactor(cashier): 🚚 move cashier `EmptyState` to components package

* fix(cashier): 🐛 fix raised issues

* chore: ⬆️ update `@deriv/api-types` to `1.0.111`

* feat(api): 🏷️ add types for `cashier_payments` private call

* style(cashier): 💄 update deposit crypto page style to match the design

* feat(hooks): ✨ add `useCurrentCurrencyConfig` hook

* fix(cashier): ✅ fix failing tests

* fix(cashier): 🐛 fix raised issues

* fix(cashier): 🐛 fix raised issues

* fix(cashier): 🐛 fix raised issues

* fix(cashier): 🐛 fix raised issues

* fix(cashier): 🐛 fix raised issues

* feat(hooks): ✨ add `useCryptoTransactions` hook

* fix(cashier): 🐛 fix raised issues

* style(cashier): 💄 update `CryptoTransactionsSideNoteResentTransaction` style

* style(cashier): 💄 update `DepositCryptoSideNoteUSDT` style

* fix(cashier): 🐛 fix raised issues

* fix(cashier): 🐛 fix raised issues

* fix(cashier): 📝 resolve conflicts

* fix(cashier): 📝 resolve conflicts

* fix(cashier): 📝 resolve comments

* fix(cashier): 📝 resolve comments

* Merge branch 'master' into farzin/wall-852/show_pending_crypto_deposit_transaction_even_if_0_confirmation

* fix(cashier): 📝 resolve PR comments

* fix(cashier): 📝 resolve PR comments

* fix(cashier): 📝 resolve PR comments

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* Merge branch 'master' into farzin/deposit_crypto_module

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

---------

Co-authored-by: Farzin Mirzaie <farzin@deriv.com>

* fix: fix quick add modal's height bug (#8574)

* Farabi/bot 296/update responsive of tour in light mode (#9315)

* fix: tour responsive on light mode

* chore: updated PR

* fix: highlighted target issue on tour

* fix: added back data-testid

* Maryia/Bot-303/feat: add crash/boom to markets list (#9098)

* feat: add cryptocurrencies to markets list

* feat: crash/boom, step indices

* feat: take profit, stop loss disable when equal 0 to skip definition, add progress slider for crypta

* refactor: currency definition, fix type of variable

* fix: is_mobile

* chore: remove cryptocurrency and step index

* chore: remove cryptocurrency and step index(2)

* fix: Hide Crash & Boom from quick strategy form

* fix: DBot doesn't allow to run mutlipliers with take profit <=0 and stop loss > 0

* Kate / DTRA-166 / Implement Contract pages for Ends/ Stays contracts (#8998)

* refactor: move trade type from un to supported

* feat: ad contract type check func and add to contract details

* feat: add chart markers settings for contract type

* chore: add style for mobile

* chore: remove gradient

* chore: empty commit

* chore: add gradient for contract details card for desktop

* feat: add chart markers setings and update style

* refactor: apply suggestions

* chore: empty commit

* feat: enable smart trader contract

* refactor: remove rounding for barrier value

* refactor: add swipble component for contract audit mobile and fix style

* refactor: applied suggestions from review

* fix: change trade type icons

* chore: empty commit

* fix: conflicts

* Henry/dtra 282/rewrite contract type info component (#9352)

* fix: initialize

* fix: ts migrate and add test coverage to ContractType folder

* fix: remove unused import

* fix: TS Error due to name and value not being intrinsic attribute to span element

* fix: add test cases

* fix: code smells

* fix: consistency issue

* fix: code smell

* fix: minor change

* fix: rewrite contract-type-info to get rid of visual bug when switching between tabs

* fix: remove unused import

* fix: remove unused css

* fix: refactor component

* fix: small word change

* fix: resolve comments

* fix: resolve comments

* fix: empty commit

* fix: code smells

* fix: circleCI

* fix: resolve comments

* fix: missing import

* fix: remove scroll for contract-type-info

* fix: resolve conflicts and merge master

* fix: remove useeffect as per comment

* fix: remove css styling

* fix: circleCI

* farabi/bot-228/fix-step-5-modal-alignment (#9377)

* fix: removed for loop of loader in dashboard scss

* fix: step 5 content

* Niloofar Sadeghi / useP2PAdvertList custom hook (#9704)

* feat: create a custom hook for handling p2p-advert-list endpoint

* fix: review comments

* fix: review comments

* test: add test case for usepaginatedfetch custom hook

* fix: circle/ci error

---------

Co-authored-by: niloofar sadeghi <niloofar.sadeghi@re-work.dev>

* chore: test case for dbot-providers (#9583)

* henry/test: add test coverage and ts migration for successdialog (#8432)

* test: add test coverage and ts migration for successdialog

* fix: code smell

* fix: switch to userEvent from fireEvent

* fix: make something reusuable variable

* fix: remove unused file

* test: ✅ add test case for Audio component (#9572)

* test: ✅ add test case for Audio component

* test: add test case in audio component to check src attribute

* fix: fixed type in audio test file bot-web-ui

* translations: 📚 sync translations with crowdin (#9730)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* chore: fixed orders failing test case (#9735)

* translations: 📚 sync translations with crowdin (#9741)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* chore: update code owners (#9678)

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>
Co-authored-by: prince-deriv <82309725+prince-deriv@users.noreply.github.com>
Co-authored-by: kate-deriv <121025168+kate-deriv@users.noreply.github.com>
Co-authored-by: Likhith Kolayari <98398322+likhith-deriv@users.noreply.github.com>
Co-authored-by: henry-deriv <118344354+henry-deriv@users.noreply.github.com>
Co-authored-by: Matin shafiei <matin@deriv.com>
Co-authored-by: amina-deriv <84661147+amina-deriv@users.noreply.github.com>
Co-authored-by: Maryia <103177211+maryia-deriv@users.noreply.github.com>
Co-authored-by: Farhan Ahmad Nurzi <125247833+farhan-nurzi-deriv@users.noreply.github.com>
Co-authored-by: adrienne-deriv <103016120+adrienne-deriv@users.noreply.github.com>
Co-authored-by: Shaheer <122449658+shaheer-deriv@users.noreply.github.com>
Co-authored-by: Shafin Al Karim <129021108+shafin-deriv@users.noreply.github.com>
Co-authored-by: nada-deriv <122768621+nada-deriv@users.noreply.github.com>
Co-authored-by: Farzin Mirzaie <72082844+farzin-deriv@users.noreply.github.com>
Co-authored-by: Farzin Mirzaie <farzin@deriv.com>
Co-authored-by: Farabi <102643568+farabi-deriv@users.noreply.github.com>
Co-authored-by: maryia-matskevich-deriv <103181650+maryia-matskevich-deriv@users.noreply.github.com>
Co-authored-by: Niloofar Sadeghi <93518187+niloofar-deriv@users.noreply.github.com>
Co-authored-by: niloofar sadeghi <niloofar.sadeghi@re-work.dev>
Co-authored-by: vinu-deriv <100689171+vinu-deriv@users.noreply.github.com>
Co-authored-by: ameerul-deriv <103412909+ameerul-deriv@users.noreply.github.com>
  • Loading branch information
1 parent 10295fc commit 0dcb820
Show file tree
Hide file tree
Showing 438 changed files with 9,148 additions and 6,561 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
/packages/account/**/* @matin-deriv @amina-deriv @maryia-deriv


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

/packages/api/**/* @ali-hosseini-deriv @matin-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/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/hooks/**/* @ali-hosseini-deriv @matin-deriv
/packages/stores/**/* @ali-hosseini-deriv @matin-deriv
/packages/stores/**/* @ali-hosseini-deriv @matin-deriv @maryia-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.94",
"@deriv/api-types": "^1.0.116",
"@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: 3 additions & 0 deletions packages/account/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ 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,4 +1,3 @@
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 @@ -29,8 +28,4 @@ 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: 9 additions & 31 deletions packages/account/src/Components/forms/idv-form.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,11 @@
import React from 'react';
import classNames from 'classnames';
import { Field, FormikProps, FormikHandlers, FieldProps } from 'formik';
import { ResidenceList } from '@deriv/api-types';
import { Field, FieldProps } from 'formik';
import { localize } from '@deriv/translations';
import { formatInput, IDV_NOT_APPLICABLE_OPTION } from '@deriv/shared';
import { formatInput, getIDVNotApplicableOption } from '@deriv/shared';
import { Autocomplete, DesktopWrapper, Input, MobileWrapper, SelectNative, Text } from '@deriv/components';
import { getDocumentData, preventEmptyClipboardPaste, generatePlaceholderText, getExampleFormat } from 'Helpers/utils';

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>;
import { TDocumentList, TIDVForm } from 'Types';

const IDVForm = ({
errors,
Expand All @@ -43,7 +19,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 @@ -57,6 +33,8 @@ 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 @@ -100,7 +78,7 @@ const IDVForm = ({
setDocumentList([...new_document_list]);
}
}
}, [document_data, selected_country, can_skip_document_verification]);
}, [document_data, selected_country, can_skip_document_verification, IDV_NOT_APPLICABLE_OPTION]);

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

const bindDocumentData = (item: TDocumentList[0]) => {
const bindDocumentData = (item: TDocumentList) => {
setFieldValue('document_type', item, true);
setSelectedDoc(item?.id);
if (item?.id === IDV_NOT_APPLICABLE_OPTION.id) {
Expand Down Expand Up @@ -171,7 +149,7 @@ const IDVForm = ({
}
}}
onChange={handleChange}
onItemSelection={(item: TDocumentList[0]) => {
onItemSelection={(item: TDocumentList) => {
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,
IDV_NOT_APPLICABLE_OPTION,
getIDVNotApplicableOption,
removeEmptyPropertiesFromObject,
} from '@deriv/shared';
import { localize, Localize } from '@deriv/translations';
Expand Down Expand Up @@ -83,6 +83,7 @@ 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,23 +1,34 @@
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,
IDV_NOT_APPLICABLE_OPTION,
getIDVNotApplicableOption,
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 @@ -26,7 +37,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 @@ -48,28 +59,29 @@ const IdvDocumentSubmit = ({
...form_initial_values,
};

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

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

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

const isAdditionalDocumentValid = (document_type, document_additional) => {
const isAdditionalDocumentValid = (document_type: TDocumentList, document_additional: string) => {
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, document_type) => {
const isDocumentNumberValid = (document_number: string, document_type: Required<TDocumentList>) => {
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 @@ -83,8 +95,8 @@ const IdvDocumentSubmit = ({
return undefined;
};

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

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

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

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;
WS.send(submit_data).then(
(response: IdentityVerificationAddDocumentResponse & { error: { message: string } }) => {
setSubmitting(false);
if (response.error) {
setErrors({ error_message: response.error.message });
return;
}
handleViewComplete();
}
handleViewComplete();
});
);
};

return (
Expand Down Expand Up @@ -225,13 +234,4 @@ 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 0dcb820

Please sign in to comment.