From 2d10240eff69e8fb41bfd94cf3b6c593844198e2 Mon Sep 17 00:00:00 2001 From: henry-deriv <118344354+henry-deriv@users.noreply.github.com> Date: Tue, 26 Sep 2023 16:39:29 +0800 Subject: [PATCH 1/5] henry/92673/fix: implement redirect action for add and manage account (#8143) * fix: implement redirect action for add and manage account * chore: refactor --- .../src/App/Containers/Redirect/redirect.jsx | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/core/src/App/Containers/Redirect/redirect.jsx b/packages/core/src/App/Containers/Redirect/redirect.jsx index 530bf682a9e6..1cb2d9c80f07 100644 --- a/packages/core/src/App/Containers/Redirect/redirect.jsx +++ b/packages/core/src/App/Containers/Redirect/redirect.jsx @@ -10,7 +10,6 @@ const Redirect = ({ currency, setVerificationCode, verification_code, - hasAnyRealAccount, openRealAccountSignup, setResetTradingPasswordModalOpen, toggleAccountSignupModal, @@ -24,7 +23,12 @@ const Redirect = ({ let redirected_to_route = false; const action_param = url_params.get('action'); const code_param = url_params.get('code') || verification_code[action_param]; + const ext_platform_url = url_params.get('ext_platform_url'); + const redirectToExternalPlatform = url => { + history.push(`${routes.root}?ext_platform_url=${url}`); + redirected_to_route = true; + }; setVerificationCode(code_param, action_param); setNewEmail(url_params.get('email'), action_param); @@ -119,14 +123,9 @@ const Redirect = ({ case 'add_account': { WS.wait('get_account_status').then(() => { if (!currency) return openRealAccountSignup('set_currency'); - if (hasAnyRealAccount()) return openRealAccountSignup('manage'); return openRealAccountSignup('svg'); }); - const ext_platform_url = url_params.get('ext_platform_url'); - if (ext_platform_url) { - history.push(`${routes.root}?ext_platform_url=${ext_platform_url}`); - redirected_to_route = true; - } + if (ext_platform_url) redirectToExternalPlatform(ext_platform_url); break; } case 'add_account_multiplier': { @@ -134,11 +133,14 @@ const Redirect = ({ if (!currency) return openRealAccountSignup('set_currency'); return openRealAccountSignup('maltainvest'); }); - const ext_platform_url = url_params.get('ext_platform_url'); - if (ext_platform_url) { - history.push(`${routes.root}?ext_platform_url=${ext_platform_url}`); - redirected_to_route = true; - } + if (ext_platform_url) redirectToExternalPlatform(ext_platform_url); + break; + } + case 'manage_account': { + WS.wait('get_account_status').then(() => { + return openRealAccountSignup('manage'); + }); + if (ext_platform_url) redirectToExternalPlatform(ext_platform_url); break; } case 'verification': { @@ -184,7 +186,6 @@ Redirect.propTypes = { currency: PropTypes.string, loginid: PropTypes.string, getServerTime: PropTypes.object, - hasAnyRealAccount: PropTypes.bool, history: PropTypes.object, openRealAccountSignup: PropTypes.func, setResetTradingPasswordModalOpen: PropTypes.func, @@ -204,7 +205,6 @@ export default withRouter( setVerificationCode: client.setVerificationCode, verification_code: client.verification_code, fetchResidenceList: client.fetchResidenceList, - hasAnyRealAccount: client.hasAnyRealAccount, openRealAccountSignup: ui.openRealAccountSignup, setResetTradingPasswordModalOpen: ui.setResetTradingPasswordModalOpen, toggleAccountSignupModal: ui.toggleAccountSignupModal, From 013f6d4905f7e203635b04f6437edff60cf893f8 Mon Sep 17 00:00:00 2001 From: kate-deriv <121025168+kate-deriv@users.noreply.github.com> Date: Tue, 26 Sep 2023 11:59:50 +0300 Subject: [PATCH 2/5] Kate / Test coverage + TS migration: ContractError + SellButton + SellInfo in Trader package (#8805) * refactor: ts migration and tests for sell folder * refactor: migrate to ts and add tests for contract error component * chore: update test description * chore: change extention * refactor: remove unused components --- .../Contract/Components/InfoBox/info-box.jsx | 2 +- .../Contract/Components/Sell/sell-button.jsx | 34 ------------------- .../Contract/Components/Sell/sell-info.jsx | 34 ------------------- .../__tests__/contract-error.spec.tsx | 32 +++++++++++++++++ ...{contract-error.jsx => contract-error.tsx} | 13 ++++--- 5 files changed, 39 insertions(+), 76 deletions(-) delete mode 100644 packages/trader/src/Modules/Contract/Components/Sell/sell-button.jsx delete mode 100644 packages/trader/src/Modules/Contract/Components/Sell/sell-info.jsx create mode 100644 packages/trader/src/Modules/Contract/Components/__tests__/contract-error.spec.tsx rename packages/trader/src/Modules/Contract/Components/{contract-error.jsx => contract-error.tsx} (86%) diff --git a/packages/trader/src/Modules/Contract/Components/InfoBox/info-box.jsx b/packages/trader/src/Modules/Contract/Components/InfoBox/info-box.jsx index e0c3607add99..9631a004c4c4 100644 --- a/packages/trader/src/Modules/Contract/Components/InfoBox/info-box.jsx +++ b/packages/trader/src/Modules/Contract/Components/InfoBox/info-box.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import { SlideIn } from 'App/Components/Animations'; import InfoBoxLongcode from './info-box-longcode.jsx'; -import ContractError from '../contract-error.jsx'; +import ContractError from '../contract-error'; const InfoBox = ({ contract_info, error_message, removeError }) => { const is_ready = !!contract_info.longcode; diff --git a/packages/trader/src/Modules/Contract/Components/Sell/sell-button.jsx b/packages/trader/src/Modules/Contract/Components/Sell/sell-button.jsx deleted file mode 100644 index ca255bdb2be4..000000000000 --- a/packages/trader/src/Modules/Contract/Components/Sell/sell-button.jsx +++ /dev/null @@ -1,34 +0,0 @@ -import { observer } from 'mobx-react'; -import PropTypes from 'prop-types'; -import React from 'react'; -import { Button, Popover } from '@deriv/components'; -import { localize } from '@deriv/translations'; - -const SellButton = ({ contract_info, is_sell_requested, is_valid_to_sell, onClickSell }) => { - const sell_message = is_valid_to_sell - ? localize( - 'Contract will be sold at the prevailing market price when the request is received by our servers. This price may differ from the indicated price.' - ) - : contract_info.validation_error; - - return ( - - -