Skip to content

Commit f487297

Browse files
committed
fix: mt5 default account
1 parent a393531 commit f487297

14 files changed

+92
-171
lines changed

packages/appstore/src/components/cfds-listing/index.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import PlatformLoader from 'Components/pre-loader/platform-loader';
2020
import CompareAccount from 'Components/compare-account';
2121
import CFDsDescription from 'Components/elements/cfds-description';
2222
import { getHasDivider } from 'Constants/utils';
23-
import { useMT5SVGEligibleToMigrate } from '@deriv/hooks';
23+
import { useMT5SVGEligibleToMigrate, useGetDefaultMT5Jurisdiction } from '@deriv/hooks';
2424
import './cfds-listing.scss';
2525

2626
const MigrationBanner = makeLazyLoader(
@@ -67,7 +67,7 @@ const CFDsListing = observer(() => {
6767
financial_restricted_countries,
6868
} = traders_hub;
6969

70-
const { setAccountType, toggleCTraderTransferModal, setProduct } = cfd;
70+
const { setAccountType, toggleCTraderTransferModal, setProduct, setJurisdictionSelectedShortcode } = cfd;
7171
const {
7272
account_status,
7373
is_landing_company_loaded,
@@ -88,6 +88,7 @@ const CFDsListing = observer(() => {
8888
is_idv_revoked,
8989
} = getAuthenticationStatusInfo(account_status);
9090

91+
const default_jurisdiction = useGetDefaultMT5Jurisdiction();
9192
const { has_svg_accounts_to_migrate } = useMT5SVGEligibleToMigrate();
9293
const getAuthStatus = (status_list: boolean[]) => status_list.some(status => status);
9394

@@ -254,6 +255,7 @@ const CFDsListing = observer(() => {
254255
});
255256
setProduct(existing_account.product);
256257
setAppstorePlatform(existing_account.platform);
258+
setJurisdictionSelectedShortcode(default_jurisdiction);
257259
getAccount();
258260
}
259261
} else if (existing_account.action_type === 'multi-action') {
@@ -418,6 +420,7 @@ const CFDsListing = observer(() => {
418420
</Text>
419421
</div>
420422
</React.Fragment>
423+
{/* dxtrade */}
421424
{is_landing_company_loaded ? (
422425
available_dxtrade_accounts?.map(account => {
423426
const existing_accounts = getExistingAccounts(account.platform, account.market_type);

packages/cfd/src/Components/props.types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type TCFDPlatform = 'dxtrade' | 'mt5' | 'ctrader';
88

99
export type TCFDsPlatformType = 'dxtrade' | 'mt5' | 'ctrader' | '';
1010

11-
export type TProducts = 'swap_free' | 'zero_spread' | 'ctrader' | 'derivx';
11+
export type TProducts = 'swap_free' | 'zero_spread' | 'ctrader' | 'derivx' | 'financial' | 'standard';
1212

1313
export type TShortcode = DetailsOfEachMT5Loginid['landing_company_short'];
1414

packages/cfd/src/Containers/cfd-password-change.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type TCFDPasswordChangeProps = TCFDPasswordFormReusedProps & {
2525
onForgotPassword: () => void;
2626
setNewPasswordValue?: React.Dispatch<React.SetStateAction<string>>;
2727
should_set_trading_password: boolean;
28+
need_tnc: boolean;
2829
};
2930

3031
type TOnSubmitPasswordChange = (
@@ -41,6 +42,7 @@ const CFDPasswordChange = observer(
4142
setNewPasswordValue,
4243
should_set_trading_password,
4344
platform,
45+
need_tnc,
4446
}: TCFDPasswordChangeProps) => {
4547
const { ui, modules } = useStore();
4648
const { product, account_type } = useCfdStore();
@@ -197,6 +199,7 @@ const CFDPasswordChange = observer(
197199
platform={platform}
198200
checked={checked}
199201
onCheck={() => setChecked(prev => !prev)}
202+
need_tnc={need_tnc}
200203
/>
201204
)}
202205
</div>

packages/cfd/src/Containers/cfd-password-modal-info.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type CfdPasswordModalInfoProps = {
1010
};
1111

1212
const CfdPasswordModalInfo = ({ jurisdiction_selected_shortcode, platform, product }: CfdPasswordModalInfoProps) => {
13-
const need_tnc = jurisdiction_selected_shortcode !== 'svg'; //TODO: @amina
13+
const need_tnc = jurisdiction_selected_shortcode !== 'svg'; //TODO: check for default jurisdiction project
1414

1515
return (
1616
<div className='cfd-password-modal-info'>

packages/cfd/src/Containers/cfd-password-modal-tnc.tsx

+23-19
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,32 @@ import classNames from 'classnames';
99
type CfdPasswordModalTncProps = {
1010
platform: typeof CFD_PLATFORMS[keyof typeof CFD_PLATFORMS];
1111
checked: boolean;
12+
need_tnc: boolean;
1213
onCheck: () => void;
1314
className?: string;
1415
};
1516

16-
const CfdPasswordModalTnc = observer(({ platform, checked, onCheck, className }: CfdPasswordModalTncProps) => {
17-
const { jurisdiction_selected_shortcode, account_title } = useCfdStore();
18-
19-
return (
20-
<div className={classNames('cfd-password-modal-tnc', className)}>
21-
<CfdPasswordModalInfo
22-
jurisdiction_selected_shortcode={jurisdiction_selected_shortcode}
23-
platform={getCFDPlatformLabel(platform)}
24-
product={account_title}
25-
/>
26-
<JurisdictionCheckBox
27-
is_checked={checked}
28-
onCheck={onCheck}
29-
class_name='cfd-password-modal__checkbox'
30-
jurisdiction_selected_shortcode={jurisdiction_selected_shortcode}
31-
/>
32-
</div>
33-
);
34-
});
17+
const CfdPasswordModalTnc = observer(
18+
({ platform, checked, onCheck, className, need_tnc }: CfdPasswordModalTncProps) => {
19+
const { jurisdiction_selected_shortcode, account_title } = useCfdStore();
20+
return (
21+
<div className={classNames('cfd-password-modal-tnc', className)}>
22+
<CfdPasswordModalInfo
23+
jurisdiction_selected_shortcode={jurisdiction_selected_shortcode}
24+
platform={getCFDPlatformLabel(platform)}
25+
product={account_title}
26+
/>
27+
{need_tnc && (
28+
<JurisdictionCheckBox
29+
is_checked={checked}
30+
onCheck={onCheck}
31+
class_name='cfd-password-modal__checkbox'
32+
jurisdiction_selected_shortcode={jurisdiction_selected_shortcode}
33+
/>
34+
)}
35+
</div>
36+
);
37+
}
38+
);
3539

3640
export default CfdPasswordModalTnc;

packages/cfd/src/Containers/cfd-password-modal.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,9 @@ const CFDPasswordForm = observer(
363363
}: TCFDPasswordFormProps) => {
364364
const { isDesktop } = useDevice();
365365
const { jurisdiction_selected_shortcode } = useCfdStore();
366-
const [checked, setChecked] = React.useState(false); //TODO: @amina
367-
const need_tnc = jurisdiction_selected_shortcode !== 'svg'; //TODO: @amina
366+
const [checked, setChecked] = React.useState(false); // TODO: check for default jurisdiction project
367+
const need_tnc = jurisdiction_selected_shortcode !== 'svg'; /// TODO: check for default jurisdiction project
368+
368369
const button_label = React.useMemo(() => {
369370
if (error_type === 'PasswordReset') {
370371
return localize('Try later');
@@ -480,14 +481,13 @@ const CFDPasswordForm = observer(
480481
/>
481482
</Text>
482483
)}
483-
{need_tnc && (
484-
<CfdPasswordModalTnc
485-
className='cfd-password-modal-tnc--bottom'
486-
platform={platform}
487-
checked={checked}
488-
onCheck={() => setChecked(prev => !prev)}
489-
/>
490-
)}
484+
<CfdPasswordModalTnc
485+
className='cfd-password-modal-tnc--bottom'
486+
platform={platform}
487+
checked={checked}
488+
onCheck={() => setChecked(prev => !prev)}
489+
need_tnc={need_tnc}
490+
/>
491491
</div>
492492
<FormSubmitButton
493493
is_disabled={!values.password || !checked}

packages/cfd/src/Containers/jurisdiction-checkbox.tsx

+15-20
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@ import { Checkbox, StaticUrl, Text } from '@deriv/components';
33
import { DBVI_COMPANY_NAMES } from '@deriv/shared';
44
import { observer, useStore } from '@deriv/stores';
55
import { Localize } from '@deriv/translations';
6-
import { TJurisdictionCheckBoxProps } from './props.types';
7-
import { JURISDICTION } from '../Helpers/cfd-config';
6+
7+
type TJurisdictionCheckBoxProps = {
8+
class_name: string;
9+
is_checked: boolean;
10+
jurisdiction_selected_shortcode: string;
11+
onCheck: () => void;
12+
};
813

914
const JurisdictionCheckBox = observer(
1015
({ class_name, is_checked, jurisdiction_selected_shortcode, onCheck }: TJurisdictionCheckBoxProps) => {
1116
const { ui } = useStore();
1217
const { is_mobile } = ui;
13-
const shouldShowCheckBox = () => {
14-
if (!jurisdiction_selected_shortcode || jurisdiction_selected_shortcode === JURISDICTION.SVG) {
15-
return false;
16-
}
17-
return true;
18-
};
1918

2019
const getCheckboxLabel = () => (
2120
<Text as='p' align={is_mobile ? 'left' : 'center'} size='xxs' line_height='m'>
@@ -35,18 +34,14 @@ const JurisdictionCheckBox = observer(
3534
);
3635

3736
return (
38-
<React.Fragment>
39-
{shouldShowCheckBox() && (
40-
<div className={class_name}>
41-
<Checkbox
42-
value={is_checked}
43-
onChange={onCheck}
44-
label={getCheckboxLabel()}
45-
defaultChecked={!!is_checked}
46-
/>
47-
</div>
48-
)}
49-
</React.Fragment>
37+
<div className={class_name}>
38+
<Checkbox
39+
value={is_checked}
40+
onChange={onCheck}
41+
label={getCheckboxLabel()}
42+
defaultChecked={!!is_checked}
43+
/>
44+
</div>
5045
);
5146
}
5247
);

packages/cfd/src/Containers/jurisdiction-licence-note.tsx

-101
This file was deleted.

packages/cfd/src/Containers/mt5-create-password.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ const MT5CreatePassword = ({
117117
)}
118118
</PasswordMeter>
119119
</div>
120-
{need_tnc && (
121-
<CfdPasswordModalTnc
122-
platform={platform}
123-
checked={checked}
124-
onCheck={() => setChecked(prev => !prev)}
125-
/>
126-
)}
120+
121+
<CfdPasswordModalTnc
122+
platform={platform}
123+
checked={checked}
124+
onCheck={() => setChecked(prev => !prev)}
125+
need_tnc={need_tnc}
126+
/>
127127
<FormSubmitButton
128128
is_disabled={!values.password || !checked || Object.keys(errors).length > 0}
129129
is_loading={isSubmitting}

packages/cfd/src/Containers/props.types.ts

-6
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,6 @@ export type TVerificationStatusBannerProps = {
218218
residence_list: ResidenceList;
219219
};
220220

221-
export type TJurisdictionCheckBoxProps = {
222-
class_name: string;
223-
is_checked: boolean;
224-
jurisdiction_selected_shortcode: string;
225-
onCheck: () => void;
226-
};
227221
export type TOpenAccountTransferMeta = {
228222
category: string;
229223
type?: string;

packages/core/src/Stores/traders-hub-store.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -611,12 +611,9 @@ export default class TradersHubStore extends BaseStore {
611611
async openRealAccount(account_type, platform) {
612612
const { client, modules } = this.root_store;
613613
const { has_active_real_account } = client;
614-
const { createCFDAccount, enableCFDPasswordModal, setJurisdictionSelectedShortcode, setAccountType } =
615-
modules.cfd;
614+
const { createCFDAccount, enableCFDPasswordModal, setAccountType } = modules.cfd;
616615
if (has_active_real_account && platform === CFD_PLATFORMS.MT5) {
617616
setAccountType(account_type);
618-
// getDefaultJurisdiction();
619-
setJurisdictionSelectedShortcode('vanuatu'); // TODO:@amina
620617
enableCFDPasswordModal();
621618
} else if (platform === CFD_PLATFORMS.DXTRADE) {
622619
enableCFDPasswordModal();

packages/hooks/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,4 @@ export { default as useResidenceSelfDeclaration } from './useResidenceSelfDeclar
8484
export { default as useTotalAssetCurrency } from './useTotalAssetCurrency';
8585
export { default as useGrowthbookIsOn } from './useGrowthbookIsOn';
8686
export { default as useResidenceList } from './useResidenceList';
87+
export { default as useGetDefaultMT5Jurisdiction } from './useGetDefaultMT5Jurisdiction';

0 commit comments

Comments
 (0)