From 66acce03fe432a0664bc1fce40b03c32de1f6a99 Mon Sep 17 00:00:00 2001 From: Niloofar Sadeghi <93518187+niloofar-deriv@users.noreply.github.com> Date: Wed, 12 Apr 2023 12:35:09 +0330 Subject: [PATCH 01/10] Fix broken tik issue (#8229) * fix: the broken tik bar * fix: stores issue --- packages/core/src/Stores/client-store.js | 22 ++++++++----------- packages/shared/src/utils/helpers/duration.ts | 5 +++-- packages/shared/src/utils/storage/storage.ts | 5 ++--- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/packages/core/src/Stores/client-store.js b/packages/core/src/Stores/client-store.js index 129e6311a5b9..078dc3c717c3 100644 --- a/packages/core/src/Stores/client-store.js +++ b/packages/core/src/Stores/client-store.js @@ -1223,13 +1223,12 @@ export default class ClientStore extends BaseStore { } responseAuthorize(response) { - const new_accounts = Object.create(this.accounts); - new_accounts[this.loginid].email = response.authorize.email; - new_accounts[this.loginid].currency = response.authorize.currency; - new_accounts[this.loginid].is_virtual = +response.authorize.is_virtual; - new_accounts[this.loginid].session_start = parseInt(moment().utc().valueOf() / 1000); - new_accounts[this.loginid].landing_company_shortcode = response.authorize.landing_company_name; - new_accounts[this.loginid].country = response.country; + this.accounts[this.loginid].email = response.authorize.email; + this.accounts[this.loginid].currency = response.authorize.currency; + this.accounts[this.loginid].is_virtual = +response.authorize.is_virtual; + this.accounts[this.loginid].session_start = parseInt(moment().utc().valueOf() / 1000); + this.accounts[this.loginid].landing_company_shortcode = response.authorize.landing_company_name; + this.accounts[this.loginid].country = response.country; this.updateAccountList(response.authorize.account_list); this.upgrade_info = this.getBasicUpgradeInfo(); this.user_id = response.authorize.user_id; @@ -1959,8 +1958,7 @@ export default class ClientStore extends BaseStore { } setResidence(residence) { - const new_accounts = Object.create(this.accounts); - new_accounts[this.loginid].residence = residence; + this.accounts[this.loginid].residence = residence; } setCitizen(citizen) { @@ -1968,8 +1966,7 @@ export default class ClientStore extends BaseStore { } setEmail(email) { - const new_accounts = Object.create(this.accounts); - new_accounts[this.loginid].email = email; + this.accounts[this.loginid].email = email; this.email = email; } @@ -2081,8 +2078,7 @@ export default class ClientStore extends BaseStore { const loginid = obj_params[`acct${i}`]; const token = obj_params[`token${i}`]; if (loginid && token) { - const new_client_object = Object.create(client_object); - new_client_object[loginid].token = token; + client_object[loginid].token = token; } i++; } diff --git a/packages/shared/src/utils/helpers/duration.ts b/packages/shared/src/utils/helpers/duration.ts index 0d06e075a792..84d47c169c9a 100644 --- a/packages/shared/src/utils/helpers/duration.ts +++ b/packages/shared/src/utils/helpers/duration.ts @@ -52,9 +52,10 @@ export const buildDurationConfig = ( const duration_min_max = durations.min_max[contract.start_type as keyof typeof durations.min_max]; const obj_min = getDurationFromString(contract.min_contract_duration); const obj_max = getDurationFromString(contract.max_contract_duration); - const durations_min_max = Object.create(durations.min_max[contract.start_type as keyof typeof durations.min_max]); - durations_min_max[contract.expiry_type as keyof typeof duration_min_max] = { + durations.min_max[contract.start_type as keyof typeof durations.min_max][ + contract.expiry_type as keyof typeof duration_min_max + ] = { min: convertDurationUnit(obj_min.duration, obj_min.unit, 's') || 0, max: convertDurationUnit(obj_max.duration, obj_max.unit, 's') || 0, }; diff --git a/packages/shared/src/utils/storage/storage.ts b/packages/shared/src/utils/storage/storage.ts index bb6e3c84b190..0c66975d32f4 100644 --- a/packages/shared/src/utils/storage/storage.ts +++ b/packages/shared/src/utils/storage/storage.ts @@ -96,13 +96,12 @@ InScriptStore.prototype = { obj = this.store ) { let key = k; - const store_object = Object.create(obj); if (!Array.isArray(key)) key = [key]; if (key.length > 1) { - if (!(key[0] in obj) || isEmptyObject(obj[key[0]])) store_object[key[0]] = {}; + if (!(key[0] in obj) || isEmptyObject(obj[key[0]])) obj[key[0]] = {}; this.set(key.slice(1), value, obj[key[0]]); } else { - store_object[key[0]] = value; + obj[key[0]] = value; } }, getObject(key: string) { From cd353874c986cd2f218802b564ac5d13ee0bf685 Mon Sep 17 00:00:00 2001 From: Sergei Baranovski <120570511+sergei-deriv@users.noreply.github.com> Date: Wed, 12 Apr 2023 13:13:23 +0300 Subject: [PATCH 02/10] feat: add check for null and undefined (#8097) --- packages/core/src/Stores/notification-store.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/src/Stores/notification-store.js b/packages/core/src/Stores/notification-store.js index 56493a150f33..bf2c81c9dac8 100644 --- a/packages/core/src/Stores/notification-store.js +++ b/packages/core/src/Stores/notification-store.js @@ -107,8 +107,8 @@ export default class NotificationStore extends BaseStore { if ( root_store.client.is_logged_in && !root_store.client.is_virtual && - Object.keys(root_store.client.account_status).length > 0 && - Object.keys(root_store.client.landing_companies).length > 0 && + Object.keys(root_store.client.account_status || {}).length > 0 && + Object.keys(root_store.client.landing_companies || {}).length > 0 && root_store.modules?.cashier?.general_store?.is_p2p_visible ) { await debouncedGetP2pCompletedOrders(); @@ -116,8 +116,8 @@ export default class NotificationStore extends BaseStore { if ( !root_store.client.is_logged_in || - (Object.keys(root_store.client.account_status).length > 0 && - Object.keys(root_store.client.landing_companies).length > 0) + (Object.keys(root_store.client.account_status || {}).length > 0 && + Object.keys(root_store.client.landing_companies || {}).length > 0) ) { this.removeNotifications(); this.removeAllNotificationMessages(); From 0b10511062d798593cc29cf50a00a9ac3523332e Mon Sep 17 00:00:00 2001 From: amina-deriv <84661147+amina-deriv@users.noreply.github.com> Date: Wed, 12 Apr 2023 14:13:54 +0400 Subject: [PATCH 03/10] Amina/fix: error in investor password (#8186) * fix: error in investor password * fix: investor password --- .../src/Containers/cfd-reset-password-modal.tsx | 14 +------------- packages/cfd/src/Containers/props.types.ts | 3 +-- packages/core/src/Stores/client-store.js | 2 +- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/packages/cfd/src/Containers/cfd-reset-password-modal.tsx b/packages/cfd/src/Containers/cfd-reset-password-modal.tsx index b3df79fa7093..ab128029f8d5 100644 --- a/packages/cfd/src/Containers/cfd-reset-password-modal.tsx +++ b/packages/cfd/src/Containers/cfd-reset-password-modal.tsx @@ -4,15 +4,7 @@ import RootStore from '../Stores/index'; import React from 'react'; import { withRouter } from 'react-router-dom'; import { Button, Icon, PasswordMeter, PasswordInput, FormSubmitButton, Loading, Modal, Text } from '@deriv/components'; -import { - routes, - validLength, - validPassword, - getErrorMessages, - CFD_PLATFORMS, - WS, - redirectToLogin, -} from '@deriv/shared'; +import { validLength, validPassword, getErrorMessages, CFD_PLATFORMS, WS, redirectToLogin } from '@deriv/shared'; import { localize, Localize, getLanguage } from '@deriv/translations'; import { connect } from '../Stores/connect'; import { getMtCompanies, TMtCompanies } from '../Stores/Modules/CFD/Helpers/cfd-config'; @@ -61,7 +53,6 @@ const CFDResetPasswordModal = ({ is_logged_in, platform, setCFDPasswordResetModal, - history, }: TCFDResetPasswordModal) => { const [state, setState] = React.useState<{ error_code: string | number | undefined; @@ -89,9 +80,6 @@ const CFDResetPasswordModal = ({ localStorage.removeItem('cfd_reset_password_intent'); localStorage.removeItem('cfd_reset_password_type'); localStorage.removeItem('cfd_reset_password_code'); - if (history.location.pathname !== routes.mt5) { - history.push(`${routes.mt5}`); - } }; const validatePassword = (values: { new_password: string }) => { const errors: { new_password?: string } = {}; diff --git a/packages/cfd/src/Containers/props.types.ts b/packages/cfd/src/Containers/props.types.ts index c41f4978a4fe..3c3efa417011 100644 --- a/packages/cfd/src/Containers/props.types.ts +++ b/packages/cfd/src/Containers/props.types.ts @@ -1,4 +1,3 @@ -import { RouteComponentProps } from 'react-router'; import { DetailsOfEachMT5Loginid, GetAccountStatus, @@ -79,7 +78,7 @@ export type TError = { message: string; }; -export type TCFDResetPasswordModal = RouteComponentProps & { +export type TCFDResetPasswordModal = { current_list: Record; email: string; context?: RootStore; diff --git a/packages/core/src/Stores/client-store.js b/packages/core/src/Stores/client-store.js index 078dc3c717c3..fb969103ab61 100644 --- a/packages/core/src/Stores/client-store.js +++ b/packages/core/src/Stores/client-store.js @@ -1616,7 +1616,7 @@ export default class ClientStore extends BaseStore { this.responsePayoutCurrencies(await WS.authorized.payoutCurrencies()); if (this.is_logged_in) { - WS.storage.mt5LoginList().then(this.responseMt5LoginList); + await WS.mt5LoginList().then(this.responseMt5LoginList); WS.tradingServers(CFD_PLATFORMS.MT5).then(this.responseMT5TradingServers); WS.tradingPlatformAvailableAccounts(CFD_PLATFORMS.MT5).then(this.responseTradingPlatformAvailableAccounts); From ebef1438c42b28a8fcb51d5ccdd407bd5eb9e5aa Mon Sep 17 00:00:00 2001 From: amina-deriv <84661147+amina-deriv@users.noreply.github.com> Date: Wed, 12 Apr 2023 14:14:22 +0400 Subject: [PATCH 04/10] Amina/92662/unable to add mt5 derived due to incorrect jurisdictions in other lang (#8151) * fix: issues in local languiages for jurisdictiom * fix: code smell * chore: trigger build --- .../account-type-modal/account-type-modal.tsx | 26 ++++++++--------- .../Constants/cfd_compare_account_content.ts | 18 +++++------- .../src/Constants/jurisdiction-contents.ts | 4 +-- .../src/Containers/compare-accounts-modal.tsx | 2 +- .../jurisdiction-modal/jurisdiction-card.tsx | 6 ++-- .../Containers/mt5-compare-table-content.tsx | 29 +++++++++---------- packages/cfd/src/Containers/props.types.ts | 2 ++ 7 files changed, 42 insertions(+), 45 deletions(-) diff --git a/packages/appstore/src/components/modals/account-type-modal/account-type-modal.tsx b/packages/appstore/src/components/modals/account-type-modal/account-type-modal.tsx index 57119007fb8b..54afec4e0cef 100644 --- a/packages/appstore/src/components/modals/account-type-modal/account-type-modal.tsx +++ b/packages/appstore/src/components/modals/account-type-modal/account-type-modal.tsx @@ -9,17 +9,17 @@ import { TModalContent, TAccountType, TAccountCard, TTradingPlatformAvailableAcc import { TIconTypes } from 'Types'; import { CFD_PLATFORMS } from '@deriv/shared'; -const derived_account: TAccountType = { +const getDerivedAccount = (): TAccountType => ({ title_and_type: localize('Derived'), icon: 'Derived', description: localize('Trade CFDs on MT5 with Derived indices that simulate real-world market movements.'), -}; +}); -const financial_account: TAccountType = { +const getFinancialAccount = (): TAccountType => ({ title_and_type: localize('Financial'), icon: 'Financial', description: localize('Trade CFDs on MT5 with forex, stock indices, commodities, and cryptocurrencies.'), -}; +}); const AccountCard = ({ selectAccountTypeCard, account_type_card, title_and_type, description, icon }: TAccountCard) => { const cardSelection = (cardType: string) => { @@ -60,19 +60,19 @@ const ModalContent = ({ {is_synthetic_available && ( selectAccountTypeCard(`${derived_account.title_and_type}`)} - description={derived_account.description} - title_and_type={derived_account.title_and_type} - icon={derived_account.icon} + selectAccountTypeCard={() => selectAccountTypeCard(`${getDerivedAccount().title_and_type}`)} + description={getDerivedAccount().description} + title_and_type={getDerivedAccount().title_and_type} + icon={getDerivedAccount().icon} /> )} {is_financial_available && ( selectAccountTypeCard(`${financial_account.title_and_type}`)} - description={financial_account.description} - title_and_type={financial_account.title_and_type} - icon={financial_account.icon} + selectAccountTypeCard={() => selectAccountTypeCard(`${getFinancialAccount().title_and_type}`)} + description={getFinancialAccount().description} + title_and_type={getFinancialAccount().title_and_type} + icon={getFinancialAccount().icon} /> )} @@ -101,7 +101,7 @@ const MT5AccountTypeModal = () => { ); const set_account_type = () => - account_type_card === 'Derived' + account_type_card === localize('Derived') ? setAccountType({ category: 'real', type: 'synthetic' }) : setAccountType({ category: 'real', type: 'financial' }); diff --git a/packages/cfd/src/Constants/cfd_compare_account_content.ts b/packages/cfd/src/Constants/cfd_compare_account_content.ts index b722f9a263d6..8ca3611e0153 100644 --- a/packages/cfd/src/Constants/cfd_compare_account_content.ts +++ b/packages/cfd/src/Constants/cfd_compare_account_content.ts @@ -1,7 +1,7 @@ import { localize } from '@deriv/translations'; import { TCompareAccountContentProps, TCompareAccountFooterButtonData } from '../Containers/props.types'; -export const eu_real_content: TCompareAccountContentProps[] = [ +export const getEuRealContent = (): TCompareAccountContentProps[] => [ { id: 'platform', attribute: localize('Platform'), @@ -59,7 +59,7 @@ export const eu_real_content: TCompareAccountContentProps[] = [ }, }, ]; -export const cr_real_content: TCompareAccountContentProps[] = [ +export const getCrRealContent = (): TCompareAccountContentProps[] => [ { id: 'platform', attribute: localize('Platform'), @@ -171,7 +171,7 @@ export const cr_real_content: TCompareAccountContentProps[] = [ }, ]; -export const cr_real_footer_buttons: TCompareAccountFooterButtonData[] = [ +export const getCrRealFooterButtons = (): TCompareAccountFooterButtonData[] => [ { label: localize('Add'), action: 'synthetic_svg' }, { label: localize('Add'), action: 'synthetic_bvi' }, { label: localize('Add'), action: 'synthetic_vanuatu' }, @@ -181,15 +181,11 @@ export const cr_real_footer_buttons: TCompareAccountFooterButtonData[] = [ { label: localize('Add'), action: 'financial_labuan' }, { label: localize('Add'), action: 'derivx' }, ]; -export const eu_real_footer_button: TCompareAccountFooterButtonData[] = [ +export const getEuFooterButtons = (): TCompareAccountFooterButtonData[] => [ { label: localize('Add'), action: 'financial_maltainvest' }, ]; -export const eu_demo_footer_button: TCompareAccountFooterButtonData[] = [ - { label: localize('Add'), action: 'financial_maltainvest' }, -]; - -export const preappstore_cr_demo_content: TCompareAccountContentProps[] = [ +export const getPreappstoreCrDemoContent = (): TCompareAccountContentProps[] => [ { id: 'platform', attribute: localize('Platform'), @@ -238,13 +234,13 @@ export const preappstore_cr_demo_content: TCompareAccountContentProps[] = [ }, ]; -export const preappstore_cr_demo_footer_buttons: TCompareAccountFooterButtonData[] = [ +export const getPreappstoreCrDemoFooterButtons = (): TCompareAccountFooterButtonData[] => [ { label: localize('Add'), action: 'synthetic_svg' }, { label: localize('Add'), action: 'financial_svg' }, { label: localize('Add'), action: 'derivx' }, ]; -export const preppstore_eu_demo_content: TCompareAccountContentProps[] = [ +export const getPreappstoreEuDemoContent = (): TCompareAccountContentProps[] => [ { id: 'leverage', attribute: localize('Maximum leverage'), diff --git a/packages/cfd/src/Constants/jurisdiction-contents.ts b/packages/cfd/src/Constants/jurisdiction-contents.ts index 7c8cd66e7453..e47a5e95d456 100644 --- a/packages/cfd/src/Constants/jurisdiction-contents.ts +++ b/packages/cfd/src/Constants/jurisdiction-contents.ts @@ -15,7 +15,7 @@ type TJurisdictionContent = { bvi: TJurisdictionCardItems; }; -export const jurisdiction_contents: TJurisdictionContent = { +export const getJurisdictionContents = (): TJurisdictionContent => ({ svg: { is_over_header_available: false, header: localize('St. Vincent & Grenadines'), @@ -103,4 +103,4 @@ export const jurisdiction_contents: TJurisdictionContent = { `${localize('Leverage up to 1:1000')}`, ], }, -}; +}); diff --git a/packages/cfd/src/Containers/compare-accounts-modal.tsx b/packages/cfd/src/Containers/compare-accounts-modal.tsx index 992ee761f0fa..04fe878214fe 100644 --- a/packages/cfd/src/Containers/compare-accounts-modal.tsx +++ b/packages/cfd/src/Containers/compare-accounts-modal.tsx @@ -198,7 +198,7 @@ const CompareAccountsModal = ({ }; } else if (is_pre_appstore_setting && should_show_derivx) { return { - height: '574px', + height: '600px', width: '1115px', }; } diff --git a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-card.tsx b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-card.tsx index 1eff06d9c8cd..bee3284893ce 100644 --- a/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-card.tsx +++ b/packages/cfd/src/Containers/jurisdiction-modal/jurisdiction-card.tsx @@ -2,8 +2,8 @@ import React from 'react'; import classNames from 'classnames'; import { Icon, Text, Popover } from '@deriv/components'; import { Localize, localize } from '@deriv/translations'; -import { jurisdiction_contents } from '../../Constants/jurisdiction-contents'; -import { TJurisdictionCardProps } from '../props.types'; +import { getJurisdictionContents } from '../../Constants/jurisdiction-contents'; +import { TJurisdictionCardProps, TJurisdictionCardType } from '../props.types'; import JurisdictionCardBanner from './jurisdiction-card-banner'; const JurisdictionCard = ({ @@ -25,7 +25,7 @@ const JurisdictionCard = ({ is_synthetic ? number_of_synthetic_accounts_to_be_shown : number_of_financial_accounts_to_be_shown ); - const card_values = jurisdiction_contents[type_of_card as keyof typeof jurisdiction_contents]; + const card_values = getJurisdictionContents()[type_of_card as TJurisdictionCardType]; const card_data = is_synthetic ? card_values.synthetic_contents : card_values.financial_contents; diff --git a/packages/cfd/src/Containers/mt5-compare-table-content.tsx b/packages/cfd/src/Containers/mt5-compare-table-content.tsx index 4521e7889b41..94e09a3acacc 100644 --- a/packages/cfd/src/Containers/mt5-compare-table-content.tsx +++ b/packages/cfd/src/Containers/mt5-compare-table-content.tsx @@ -14,14 +14,13 @@ import { TCompareAccountRowItem, } from './props.types'; import { - eu_real_content, - cr_real_content, - cr_real_footer_buttons, - eu_real_footer_button, - preappstore_cr_demo_content, - preappstore_cr_demo_footer_buttons, - preppstore_eu_demo_content, - eu_demo_footer_button, + getEuRealContent, + getCrRealContent, + getCrRealFooterButtons, + getPreappstoreCrDemoContent, + getPreappstoreCrDemoFooterButtons, + getPreappstoreEuDemoContent, + getEuFooterButtons, } from '../Constants/cfd_compare_account_content'; import { GetSettings, GetAccountSettingsResponse } from '@deriv/api-types'; @@ -412,20 +411,20 @@ const DMT5CompareModalContent = ({ const getModalContent = () => { if (is_preappstore_cr_demo_account) { - return preappstore_cr_demo_content; + return getPreappstoreCrDemoContent(); } else if (show_eu_related_content) { if (is_pre_appstore_setting && content_flag === ContentFlag.EU_DEMO) { - return preppstore_eu_demo_content; + return getPreappstoreEuDemoContent(); } - return eu_real_content; + return getEuRealContent(); } - return cr_real_content; + return getCrRealContent(); }; const modal_footer = () => { - if (is_preappstore_cr_demo_account) return preappstore_cr_demo_footer_buttons; - else if (is_demo_tab && show_eu_related_content) return eu_demo_footer_button; - return show_eu_related_content ? eu_real_footer_button : cr_real_footer_buttons; + if (is_preappstore_cr_demo_account) return getPreappstoreCrDemoFooterButtons(); + else if (is_demo_tab && show_eu_related_content) return getEuFooterButtons(); + return show_eu_related_content ? getEuFooterButtons() : getCrRealFooterButtons(); }; const shouldShowPendingStatus = (item: TCompareAccountFooterButtonData) => { diff --git a/packages/cfd/src/Containers/props.types.ts b/packages/cfd/src/Containers/props.types.ts index 3c3efa417011..0a69cc609877 100644 --- a/packages/cfd/src/Containers/props.types.ts +++ b/packages/cfd/src/Containers/props.types.ts @@ -172,6 +172,8 @@ export type TJurisdictionCardProps = { disabled: boolean; }; +export type TJurisdictionCardType = 'svg' | 'bvi' | 'vanuatu' | 'labuan' | 'maltainvest'; + export type TVerificationStatusBannerProps = { account_status: GetAccountStatus; account_type: string; From 1a8ef823d63c888c6c04ca6dbe8aa69ea9927bbe Mon Sep 17 00:00:00 2001 From: Likhith Kolayari <98398322+likhith-deriv@users.noreply.github.com> Date: Wed, 12 Apr 2023 14:14:49 +0400 Subject: [PATCH 05/10] likhith/fix: :bug: fixed Risk assessment warning dual popup issue (#8118) * fix: :bug: fixed Risk assessment warning dual popup issue * feat: :bug: translation bug * feat: fix for mobile * fix: :bug: incorporated design as per figma --- .../financial-details/financial-details.jsx | 5 +- .../risk-tolerance-warning-modal.jsx | 102 +++++++++++++----- .../trading-assessment-existing-user.jsx | 1 + .../RealAccountSignup/real-account-signup.jsx | 4 +- packages/core/src/sass/account-wizard.scss | 25 +++++ 5 files changed, 105 insertions(+), 32 deletions(-) diff --git a/packages/account/src/Components/financial-details/financial-details.jsx b/packages/account/src/Components/financial-details/financial-details.jsx index 84c00ecac42f..92c7ccf7fc33 100644 --- a/packages/account/src/Components/financial-details/financial-details.jsx +++ b/packages/account/src/Components/financial-details/financial-details.jsx @@ -87,10 +87,7 @@ const FinancialDetails = props => { is_disabled={isDesktop()} > - +
{ +const RiskToleranceWarningModal = ({ + show_risk_modal, + handleAcceptRisk, + title, + button_text, + body_content, + has_sub_header = false, +}) => { return ( - - - - + + - {body_content} - - - -