From dfa4c98ee4aaf861710711b2472d04bfcafd7ee0 Mon Sep 17 00:00:00 2001 From: Yashim Wong Date: Mon, 6 Mar 2023 18:49:10 +0800 Subject: [PATCH 1/3] yashim/feat: add continent to cookie (#7815) * feat: add continent to cookie * fix: conditions * fix: logic for vrtc. renamed keys * fix: add arguments --- packages/core/src/Stores/client-store.js | 5 ++++- packages/core/src/_common/utility.js | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/core/src/Stores/client-store.js b/packages/core/src/Stores/client-store.js index 531879d28ae8..43ca78f74e8a 100644 --- a/packages/core/src/Stores/client-store.js +++ b/packages/core/src/Stores/client-store.js @@ -27,7 +27,7 @@ import { WS, requestLogout } from 'Services'; import { action, computed, makeObservable, observable, reaction, runInAction, toJS, when } from 'mobx'; import { getAccountTitle, getClientAccountType } from './Helpers/client'; import { getLanguage, localize } from '@deriv/translations'; -import { isEuCountry, isMultipliersOnly, isOptionsBlocked } from '_common/utility'; +import { isEuCountry, isMultipliersOnly, isOptionsBlocked, getRegion } from '_common/utility'; import BaseStore from './base-store'; import BinarySocket from '_common/base/socket_base'; @@ -1169,6 +1169,7 @@ export default class ClientStore extends BaseStore { setCookieAccount() { const domain = /deriv\.(com|me)/.test(window.location.hostname) ? deriv_urls.DERIV_HOST_NAME : 'binary.sx'; + // eslint-disable-next-line max-len const { loginid, @@ -1195,9 +1196,11 @@ export default class ClientStore extends BaseStore { preferred_language, user_id, }; + Cookies.set('region', getRegion(landing_company_shortcode, residence), { domain }); Cookies.set('client_information', client_information, { domain }); this.has_cookie_account = true; } else { + Cookies.remove('region', { domain }); Cookies.remove('client_information', { domain }); this.has_cookie_account = false; } diff --git a/packages/core/src/_common/utility.js b/packages/core/src/_common/utility.js index 2ecf35655ae8..6727a4408096 100644 --- a/packages/core/src/_common/utility.js +++ b/packages/core/src/_common/utility.js @@ -92,6 +92,13 @@ const isOptionsBlocked = country => blocked_options_countries.includes(country); const multipliers_only_countries = ['de', 'es', 'it', 'lu', 'gr', 'au', 'fr']; const isMultipliersOnly = country => multipliers_only_countries.includes(country); +const getRegion = (landing_company_shortcode, residence) => { + if (landing_company_shortcode === 'virtual') { + return isEuCountry(residence) ? 'eu' : 'row'; + } + return landing_company_shortcode === 'svg' ? 'row' : 'eu'; +}; + module.exports = { template, createElement, @@ -101,4 +108,5 @@ module.exports = { isOptionsBlocked, isSyntheticsUnavailable, isMultipliersOnly, + getRegion, }; From f6a07c8fa4bd8a838e7823ab43ac1ef8de85eac3 Mon Sep 17 00:00:00 2001 From: Likhith Kolayari <98398322+likhith-deriv@users.noreply.github.com> Date: Mon, 6 Mar 2023 16:17:28 +0400 Subject: [PATCH 2/3] likhith/89901/feat: :bug: fixed issue in trading assessment (#7812) * feat: :bug: fixed issue in trading assessment * feat: removed unused props --------- Co-authored-by: amina-deriv <84661147+amina-deriv@users.noreply.github.com> --- .../TradingAssessment/trading-assessment.jsx | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/packages/account/src/Sections/Assessment/TradingAssessment/trading-assessment.jsx b/packages/account/src/Sections/Assessment/TradingAssessment/trading-assessment.jsx index 683e286efb23..bed017e98c62 100644 --- a/packages/account/src/Sections/Assessment/TradingAssessment/trading-assessment.jsx +++ b/packages/account/src/Sections/Assessment/TradingAssessment/trading-assessment.jsx @@ -35,12 +35,7 @@ const populateData = form_data => { }; }; -const TradingAssessment = ({ - is_virtual, - setFinancialAndTradingAssessment, - // setShouldShowWarningModal, - // should_show_risk_accept_modal, -}) => { +const TradingAssessment = ({ is_virtual, setFinancialAndTradingAssessment }) => { const history = useHistory(); const [is_loading, setIsLoading] = React.useState(true); const [is_btn_loading, setIsBtnLoading] = React.useState(false); @@ -173,7 +168,7 @@ const TradingAssessment = ({ title={localize('Trading Experience')} subtitle={localize('All fields are required')} /> - {trading_assessment_questions.map(item => { + {trading_assessment_questions().map(item => { const form_control = item.form_control; if (item.field_type === 'radio') { return ( @@ -293,8 +288,4 @@ const TradingAssessment = ({ export default connect(({ client }) => ({ is_virtual: client.is_virtual, setFinancialAndTradingAssessment: client.setFinancialAndTradingAssessment, - is_trading_experience_incomplete: client.is_trading_experience_incomplete, - updateAccountStatus: client.updateAccountStatus, - // setShouldShowWarningModal: ui.setShouldShowWarningModal, - // should_show_risk_accept_modal: ui.should_show_risk_accept_modal, }))(withRouter(TradingAssessment)); From f863ad94d8046ad04cb8ac829c5fbba92384855a Mon Sep 17 00:00:00 2001 From: thisyahlen <104053934+thisyahlen-deriv@users.noreply.github.com> Date: Mon, 6 Mar 2023 21:26:05 +0800 Subject: [PATCH 3/3] thisyahlen/chore: add CTA for CFDs in Traders hub account switcher in dtrader (#7790) * chore: add CTA for CFDs in Traders hub account switcher in dtrader * chore: add CTA for CFDs in Traders hub account switcher in dtrader * fix: switch to cfd in mobile after switching account from account switcher * fix: comments * fix: conditions * fix: real account switch --------- Co-authored-by: amina-deriv <84661147+amina-deriv@users.noreply.github.com> --- .../AccountSwitcher/account-switcher.jsx | 50 ++++++++++++++++++- .../_common/components/account-switcher.scss | 22 ++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/packages/core/src/App/Containers/AccountSwitcher/account-switcher.jsx b/packages/core/src/App/Containers/AccountSwitcher/account-switcher.jsx index cc1d87ae1920..85e04cbeb5f1 100644 --- a/packages/core/src/App/Containers/AccountSwitcher/account-switcher.jsx +++ b/packages/core/src/App/Containers/AccountSwitcher/account-switcher.jsx @@ -1,7 +1,7 @@ import classNames from 'classnames'; import PropTypes from 'prop-types'; import React from 'react'; -import { withRouter } from 'react-router'; +import { withRouter, useHistory } from 'react-router'; import { Button, DesktopWrapper, @@ -30,6 +30,7 @@ import { AccountsItemLoader } from 'App/Components/Layout/Header/Components/Prel import AccountList from './account-switcher-account-list.jsx'; import AccountWrapper from './account-switcher-account-wrapper.jsx'; import { getSortedAccountList, getSortedCFDList, isDemo, getCFDConfig } from './helpers'; +import { BinaryLink } from 'App/Components/Routes'; const AccountSwitcher = props => { const [active_tab_index, setActiveTabIndex] = React.useState( @@ -65,6 +66,8 @@ const AccountSwitcher = props => { props.mt5_login_list.find(account => isDemo(account))?.currency || props.dxtrade_accounts_list.find(account => isDemo(account))?.currency; + const history = useHistory(); + React.useEffect(() => { if (getMaxAccountsDisplayed()) { setDmt5RealVisible(false); @@ -340,6 +343,7 @@ const AccountSwitcher = props => { // Real accounts is always the first tab index based on design const isRealAccountTab = active_tab_index === 0; + const isDemoAccountTab = active_tab_index === 1; const getDemoMT5 = () => { return getSortedCFDList(props.mt5_login_list).filter(isDemo); @@ -1209,6 +1213,43 @@ const AccountSwitcher = props => { const demo_accounts = props.is_pre_appstore ? traders_hub_demo_account : default_demo_accounts; + const first_real_login_id = props.account_list?.find(account => /^(CR|MF)/.test(account.loginid))?.loginid; + + const TradersHubRedirect = () => { + const TradersHubLink = () => { + const handleRedirect = async () => { + if (!props.is_virtual && isDemoAccountTab) { + await props.switchAccount(props.virtual_account_loginid); + } else if (props.is_virtual && isRealAccountTab) { + await props.switchAccount(first_real_login_id); + } + props.toggleAccountsDialog(false); + history.push(routes.traders_hub); + props.setTogglePlatformType('cfd'); + }; + + return ( + +
+ + + + + +
+
+ + ); + }; + + if (props.is_pre_appstore) { + if ((isRealAccountTab && props.has_any_real_account) || isDemoAccountTab) { + return ; + } + } + return null; + }; + return (
{
+ +