Skip to content

Commit

Permalink
chore: filter list for australian clients (deriv-com#8319)
Browse files Browse the repository at this point in the history
* chore: filter list for australian clients

* fix: resolve comments

* fix: circle ci error

* fix: added mockstore types

* fix: updated types

* fix: show available cfds correctly on onboarding page

* fix: commit suggestion
  • Loading branch information
aizad-deriv authored May 2, 2023
1 parent 45c3523 commit 7cca6b5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/appstore/src/components/cfds-listing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const CFDsListing = () => {
no_CR_account,
setSelectedAccount,
CFDs_restricted_countries,
financial_restricted_countries,
} = traders_hub;

const { toggleCompareAccountsModal, setAccountType } = cfd;
Expand Down Expand Up @@ -204,7 +205,7 @@ const CFDsListing = () => {
) : (
<PlatformLoader />
)}
{!is_eu_user && !CFDs_restricted_countries && (
{!is_eu_user && !CFDs_restricted_countries && !financial_restricted_countries && (
<div className='cfd-full-row'>
<hr className='divider' />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const StaticDashboard = ({
loginid,
}: TStaticDashboard) => {
const { client, traders_hub } = useStores();
const { content_flag, CFDs_restricted_countries } = traders_hub;
const { content_flag, CFDs_restricted_countries, financial_restricted_countries } = traders_hub;
const { is_eu_country, is_logged_in } = client;

const [index, setIndex] = React.useState<number>(0);
Expand Down Expand Up @@ -434,7 +434,7 @@ const StaticDashboard = ({
</div>

<div className='static-dashboard-wrapper__body'>
{!is_eu_user && (
{!is_eu_user && !financial_restricted_countries && (
<StaticCFDAccountManager
type='synthetic'
platform='mt5'
Expand All @@ -453,7 +453,7 @@ const StaticDashboard = ({
/>
)}
{isMobile() && !has_account && <Divider />}
{is_eu_user && (
{is_eu_user && !financial_restricted_countries && (
<StaticCFDAccountManager
type='financial'
platform='mt5'
Expand Down Expand Up @@ -501,7 +501,7 @@ const StaticDashboard = ({
/>
)}
</div>
{!is_eu_user && !CFDs_restricted_countries && (
{!is_eu_user && !CFDs_restricted_countries && !financial_restricted_countries && (
<React.Fragment>
<Divider />
<div className='static-dashboard-wrapper__body--header'>
Expand All @@ -520,7 +520,7 @@ const StaticDashboard = ({
</div>
</React.Fragment>
)}
{!is_eu_user && !CFDs_restricted_countries && (
{!is_eu_user && !CFDs_restricted_countries && !financial_restricted_countries && (
<StaticCFDAccountManager
type='all'
platform='dxtrade'
Expand Down
17 changes: 16 additions & 1 deletion packages/core/src/Stores/traders-hub-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default class TradersHubStore extends BaseStore {
toggleIsTourOpen: action.bound,
toggleRegulatorsCompareModal: action.bound,
showTopUpModal: action.bound,
financial_restricted_countries: computed,
});

reaction(
Expand All @@ -104,6 +105,7 @@ export default class TradersHubStore extends BaseStore {
this.root_store.modules?.cfd?.current_list,
this.root_store.client.landing_companies,
this.root_store.common.current_language,
this.financial_restricted_countries,
],
() => {
this.getAvailablePlatforms();
Expand Down Expand Up @@ -368,6 +370,12 @@ export default class TradersHubStore extends BaseStore {
this.setCombinedCFDMT5Accounts();
}

get financial_restricted_countries() {
const { financial_company, gaming_company } = this.root_store.client.landing_companies;

return financial_company?.shortcode === 'svg' && !gaming_company;
}

get CFDs_restricted_countries() {
const { financial_company, gaming_company } = this.root_store.client.landing_companies;

Expand All @@ -382,6 +390,13 @@ export default class TradersHubStore extends BaseStore {
return;
}

if (this.financial_restricted_countries) {
this.available_mt5_accounts = this.available_cfd_accounts.filter(
account => account.market_type === 'financial' && account.platform === CFD_PLATFORMS.MT5
);
return;
}

if (this.CFDs_restricted_countries) {
this.available_mt5_accounts = this.available_cfd_accounts.filter(
account => account.market_type !== 'financial' && account.platform === CFD_PLATFORMS.MT5
Expand All @@ -395,7 +410,7 @@ export default class TradersHubStore extends BaseStore {
}

getAvailableDxtradeAccounts() {
if (this.CFDs_restricted_countries) {
if (this.CFDs_restricted_countries || this.financial_restricted_countries) {
this.available_dxtrade_accounts = [];
return;
}
Expand Down
1 change: 1 addition & 0 deletions packages/stores/src/mockStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ const mock = (): TStores => {
is_real: false,
selectRegion: jest.fn(),
is_low_risk_cr_eu_real: false,
financial_restricted_countries: false,
selected_account_type: 'real',
no_CR_account: false,
no_MF_account: false,
Expand Down
1 change: 1 addition & 0 deletions packages/stores/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ type TTradersHubStore = {
setTogglePlatformType: (platform_type: string) => void;
is_real: boolean;
selectRegion: (region: string) => void;
financial_restricted_countries: boolean;
selected_account_type: string;
no_CR_account: boolean;
no_MF_account: boolean;
Expand Down

0 comments on commit 7cca6b5

Please sign in to comment.