From 3137c6468f624c9c674b7aedfd54aa72781ee95b Mon Sep 17 00:00:00 2001 From: amina-deriv <84661147+amina-deriv@users.noreply.github.com> Date: Tue, 18 Apr 2023 09:22:46 +0400 Subject: [PATCH 1/2] Amina/93124/empty blank page after logged out from mf account (#8210) * fix: blank_page_on_logout * fix: blank_page_on_logout * fix: remove console * fix: undefined error --- .../AccountSwitcher/account-switcher.jsx | 18 ++-- packages/core/src/Stores/client-store.js | 15 ++-- packages/core/src/Stores/traders-hub-store.js | 82 ++++++++++--------- 3 files changed, 65 insertions(+), 50 deletions(-) diff --git a/packages/core/src/App/Containers/AccountSwitcher/account-switcher.jsx b/packages/core/src/App/Containers/AccountSwitcher/account-switcher.jsx index 1c23674364b9..a406608bab29 100644 --- a/packages/core/src/App/Containers/AccountSwitcher/account-switcher.jsx +++ b/packages/core/src/App/Containers/AccountSwitcher/account-switcher.jsx @@ -37,6 +37,7 @@ const AccountSwitcher = ({ history, is_dark_mode_on, is_eu, + is_landing_company_loaded, is_low_risk, is_high_risk, is_logged_in, @@ -131,13 +132,16 @@ const AccountSwitcher = ({ const isDemoAccountTab = active_tab_index === 1; const getRealMT5 = () => { - const low_risk_non_eu = content_flag === ContentFlag.LOW_RISK_CR_NON_EU; - if (low_risk_non_eu) { - return getSortedCFDList(mt5_login_list).filter( - account => !isDemo(account) && account.landing_company_short !== 'maltainvest' - ); + if (is_landing_company_loaded) { + const low_risk_non_eu = content_flag === ContentFlag.LOW_RISK_CR_NON_EU; + if (low_risk_non_eu) { + return getSortedCFDList(mt5_login_list).filter( + account => !isDemo(account) && account.landing_company_short !== 'maltainvest' + ); + } + return getSortedCFDList(mt5_login_list).filter(account => !isDemo(account)); } - return getSortedCFDList(mt5_login_list).filter(account => !isDemo(account)); + return []; }; const canOpenMulti = () => { @@ -540,6 +544,7 @@ AccountSwitcher.propTypes = { history: PropTypes.object, is_dark_mode_on: PropTypes.bool, is_eu: PropTypes.bool, + is_landing_company_loaded: PropTypes.bool, is_low_risk: PropTypes.bool, is_high_risk: PropTypes.bool, is_logged_in: PropTypes.bool, @@ -580,6 +585,7 @@ const account_switcher = withRouter( country_standpoint: client.country_standpoint, is_dark_mode_on: ui.is_dark_mode_on, is_eu: client.is_eu, + is_landing_company_loaded: client.is_landing_company_loaded, is_low_risk: client.is_low_risk, is_high_risk: client.is_high_risk, is_logged_in: client.is_logged_in, diff --git a/packages/core/src/Stores/client-store.js b/packages/core/src/Stores/client-store.js index fb969103ab61..ef6bf7c41fef 100644 --- a/packages/core/src/Stores/client-store.js +++ b/packages/core/src/Stores/client-store.js @@ -1638,8 +1638,9 @@ export default class ClientStore extends BaseStore { if (this.account_settings && !this.account_settings.residence) { this.root_store.ui.toggleSetResidenceModal(true); } - - await WS.authorized.cache.landingCompany(this.residence).then(this.responseLandingCompany); + if (this.residence) { + await WS.authorized.cache.landingCompany(this.residence).then(this.responseLandingCompany); + } if (!this.is_virtual) await this.getLimits(); await WS.p2pAdvertiserInfo().then(this.setP2pAdvertiserInfo); @@ -1958,7 +1959,9 @@ export default class ClientStore extends BaseStore { } setResidence(residence) { - this.accounts[this.loginid].residence = residence; + if (this.loginid) { + this.accounts[this.loginid].residence = residence; + } } setCitizen(citizen) { @@ -1966,8 +1969,10 @@ export default class ClientStore extends BaseStore { } setEmail(email) { - this.accounts[this.loginid].email = email; - this.email = email; + if (this.loginid) { + this.accounts[this.loginid].email = email; + this.email = email; + } } setAccountSettings(settings) { diff --git a/packages/core/src/Stores/traders-hub-store.js b/packages/core/src/Stores/traders-hub-store.js index 1c3ce1610e12..614c08381600 100644 --- a/packages/core/src/Stores/traders-hub-store.js +++ b/packages/core/src/Stores/traders-hub-store.js @@ -248,45 +248,52 @@ export default class TradersHubStore extends BaseStore { } get is_demo_low_risk() { - const { financial_company, gaming_company } = this.root_store.client.landing_companies; - return ( - this.content_flag === ContentFlag.CR_DEMO && - financial_company?.shortcode === 'maltainvest' && - gaming_company?.shortcode === 'svg' - ); + const { is_landing_company_loaded } = this.root_store.client; + if (is_landing_company_loaded) { + const { financial_company, gaming_company } = this.root_store.client.landing_companies; + return ( + this.content_flag === ContentFlag.CR_DEMO && + financial_company?.shortcode === 'maltainvest' && + gaming_company?.shortcode === 'svg' + ); + } + return false; } get content_flag() { - const { is_logged_in, landing_companies, residence } = this.root_store.client; - const { financial_company, gaming_company } = landing_companies; - - //this is a conditional check for countries like Australia/Norway which fulfills one of these following conditions - const restricted_countries = financial_company?.shortcode === 'svg' || gaming_company?.shortcode === 'svg'; - - if (!is_logged_in) return ''; - if (!gaming_company?.shortcode && financial_company?.shortcode === 'maltainvest') { - if (this.is_demo) return ContentFlag.EU_DEMO; - return ContentFlag.EU_REAL; - } else if ( - financial_company?.shortcode === 'maltainvest' && - gaming_company?.shortcode === 'svg' && - this.is_real - ) { - if (this.is_eu_user) return ContentFlag.LOW_RISK_CR_EU; - return ContentFlag.LOW_RISK_CR_NON_EU; - } else if ( - ((financial_company?.shortcode === 'svg' && gaming_company?.shortcode === 'svg') || restricted_countries) && - this.is_real - ) { - return ContentFlag.HIGH_RISK_CR; - } + const { is_logged_in, landing_companies, residence, is_landing_company_loaded } = this.root_store.client; + if (is_landing_company_loaded) { + const { financial_company, gaming_company } = landing_companies; + + //this is a conditional check for countries like Australia/Norway which fulfills one of these following conditions + const restricted_countries = financial_company?.shortcode === 'svg' || gaming_company?.shortcode === 'svg'; + + if (!is_logged_in) return ''; + if (!gaming_company?.shortcode && financial_company?.shortcode === 'maltainvest') { + if (this.is_demo) return ContentFlag.EU_DEMO; + return ContentFlag.EU_REAL; + } else if ( + financial_company?.shortcode === 'maltainvest' && + gaming_company?.shortcode === 'svg' && + this.is_real + ) { + if (this.is_eu_user) return ContentFlag.LOW_RISK_CR_EU; + return ContentFlag.LOW_RISK_CR_NON_EU; + } else if ( + ((financial_company?.shortcode === 'svg' && gaming_company?.shortcode === 'svg') || + restricted_countries) && + this.is_real + ) { + return ContentFlag.HIGH_RISK_CR; + } - // Default Check - if (isEuCountry(residence)) { - if (this.is_demo) return ContentFlag.EU_DEMO; - return ContentFlag.EU_REAL; + // Default Check + if (isEuCountry(residence)) { + if (this.is_demo) return ContentFlag.EU_DEMO; + return ContentFlag.EU_REAL; + } + if (this.is_demo) return ContentFlag.CR_DEMO; } - if (this.is_demo) return ContentFlag.CR_DEMO; return ContentFlag.LOW_RISK_CR_NON_EU; } @@ -484,12 +491,9 @@ export default class TradersHubStore extends BaseStore { } get multipliers_account_status() { - const { - has_maltainvest_account, - account_status: { authentication }, - } = this.root_store.client; + const { has_maltainvest_account, account_status } = this.root_store.client; - const multipliers_account_status = getMultipliersAccountStatus(authentication); + const multipliers_account_status = getMultipliersAccountStatus(account_status?.authentication); const should_show_status_for_multipliers_account = [ContentFlag.EU_REAL, ContentFlag.LOW_RISK_CR_EU].includes(this.content_flag) && has_maltainvest_account && From 98f39ebccee77f71ff5f049f370bc22df4d6af48 Mon Sep 17 00:00:00 2001 From: thisyahlen <104053934+thisyahlen-deriv@users.noreply.github.com> Date: Tue, 18 Apr 2023 13:42:53 +0800 Subject: [PATCH 2/2] thisyahlen/fix: deposit button not translated (#8211) * fix: deposit button not translated * fix: subaccount type cfd --- .../currency-switcher-card/real/real-account-card.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/appstore/src/components/currency-switcher-card/real/real-account-card.tsx b/packages/appstore/src/components/currency-switcher-card/real/real-account-card.tsx index 1618f61b4c4c..5b42527f31c5 100644 --- a/packages/appstore/src/components/currency-switcher-card/real/real-account-card.tsx +++ b/packages/appstore/src/components/currency-switcher-card/real/real-account-card.tsx @@ -3,7 +3,7 @@ import { useHistory } from 'react-router'; import { observer } from 'mobx-react-lite'; import { Button, Text } from '@deriv/components'; import { formatMoney, getCurrencyName, routes } from '@deriv/shared'; -import { localize } from '@deriv/translations'; +import { Localize } from '@deriv/translations'; import BalanceText from 'Components/elements/text/balance-text'; import CurrencySwitcherContainer from 'Components/containers/currency-switcher-container'; import { TRootStore } from 'Types'; @@ -14,9 +14,10 @@ const default_balance = { balance: 0, currency: 'USD' }; const RealAccountCard = () => { const history = useHistory(); const store = useStores(); - const { client, modules, traders_hub }: TRootStore = store; + const { client, common, modules, traders_hub }: TRootStore = store; const { accounts, loginid } = client; + const { current_language } = common; const { current_list } = modules.cfd; const { openModal, is_eu_user } = traders_hub; const { balance, currency } = accounts[loginid] || default_balance; @@ -49,7 +50,7 @@ const RealAccountCard = () => { secondary className='currency-switcher__button' > - {localize('Deposit')} + } has_interaction