Skip to content

Commit

Permalink
Merge branch 'master' of github.com:binary-com/deriv-app into evgeniy…
Browse files Browse the repository at this point in the history
…/89431/no_error_message_for_idv_duplicated_document_numbers
  • Loading branch information
“yauheni-kryzhyk-deriv” committed Mar 7, 2023
2 parents 901acc1 + f863ad9 commit d2abe53
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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));
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 (
<React.Fragment>
<div className='acc-switcher__traders-hub'>
<BinaryLink onClick={handleRedirect} className='acc-switcher__traders-hub--link'>
<Text size='xs' align='center' className='acc-switcher__traders-hub--text'>
<Localize i18n_default_text="Looking for CFD accounts? Go to Trader's hub" />
</Text>
</BinaryLink>
</div>
<div className='acc-switcher__separator' />
</React.Fragment>
);
};

if (props.is_pre_appstore) {
if ((isRealAccountTab && props.has_any_real_account) || isDemoAccountTab) {
return <TradersHubLink />;
}
}
return null;
};

return (
<div className='acc-switcher__list' ref={wrapper_ref}>
<Tabs
Expand Down Expand Up @@ -1267,6 +1308,8 @@ const AccountSwitcher = props => {
</Text>
<div className='acc-switcher__separator' />

<TradersHubRedirect />

<div
className={classNames('acc-switcher__footer', {
'acc-switcher__footer--traders-hub': props.is_pre_appstore,
Expand Down Expand Up @@ -1364,6 +1407,8 @@ AccountSwitcher.propTypes = {
real_account_creation_unlock_date: PropTypes.number,
setShouldShowCooldownModal: PropTypes.func,
content_flag: PropTypes.string,
virtual_account_loginid: PropTypes.string,
setTogglePlatformType: PropTypes.func,
};

const account_switcher = withRouter(
Expand Down Expand Up @@ -1430,6 +1475,9 @@ const account_switcher = withRouter(
trading_platform_available_accounts: client.trading_platform_available_accounts,
show_eu_related_content: traders_hub.show_eu_related_content,
content_flag: traders_hub.content_flag,
has_any_real_account: client.has_any_real_account,
virtual_account_loginid: client.virtual_account_loginid,
setTogglePlatformType: traders_hub.setTogglePlatformType,
}))(AccountSwitcher)
);

Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/Stores/client-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand All @@ -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;
}
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/_common/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -101,4 +108,5 @@ module.exports = {
isOptionsBlocked,
isSyntheticsUnavailable,
isMultipliersOnly,
getRegion,
};
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,28 @@
margin: 1.3rem 1.1rem 1rem 1rem;
}
}

&__traders-hub {
padding: 1.2rem 0.5rem 0.6rem 0.8rem;

@include mobile {
padding: 1.2rem 0.5rem 0.6rem 2.5rem;
}
&--link {
cursor: pointer;
text-decoration: none;
:hover {
cursor: pointer;
text-decoration: underline;
}
}

&--text {
align-items: center;
padding: 0.8rem;
color: var(--text-loss-danger);
}
}
}

/** @define set-currency; weak */
Expand Down

0 comments on commit d2abe53

Please sign in to comment.