Skip to content

Commit

Permalink
Merge branch 'binary-com:master' into amina/feature/90115/update_juri…
Browse files Browse the repository at this point in the history
…sdiction
  • Loading branch information
shaheer-deriv committed Apr 18, 2023
2 parents 1ba5b58 + 98f39eb commit c68bc20
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -49,7 +50,7 @@ const RealAccountCard = () => {
secondary
className='currency-switcher__button'
>
{localize('Deposit')}
<Localize key={`currency-switcher__button-text-${current_language}`} i18n_default_text='Deposit' />
</Button>
}
has_interaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 10 additions & 5 deletions packages/core/src/Stores/client-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1958,16 +1959,20 @@ 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) {
this.citizen = citizen;
}

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) {
Expand Down
82 changes: 43 additions & 39 deletions packages/core/src/Stores/traders-hub-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 &&
Expand Down

0 comments on commit c68bc20

Please sign in to comment.