Skip to content

Commit

Permalink
chore: added setpreferredlanguage in trading-hub-header and exit-trad…
Browse files Browse the repository at this point in the history
…ers-hub-modal (binary-com#7553)
  • Loading branch information
aizad-deriv authored and Carol Sachdeva committed Feb 9, 2023
1 parent 7f8f7fa commit 6bdaf92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classNames from 'classnames';
import { useHistory, withRouter } from 'react-router-dom';
import { DesktopWrapper, Icon, MobileWrapper, Popover, Text, Button } from '@deriv/components';
import { routes, ContentFlag } from '@deriv/shared';
import { Localize } from '@deriv/translations';
import { getLanguage, Localize } from '@deriv/translations';
import { ToggleNotifications, MenuLinks } from 'App/Components/Layout/Header';
import platform_config from 'App/Constants/platform-config';
import ToggleMenuDrawer from 'App/Components/Layout/Header/toggle-menu-drawer.jsx';
Expand Down Expand Up @@ -49,17 +49,18 @@ const RedirectToOldInterface = ({
toggleExitTradersHubModal,
content_flag,
switchToCRAccount,
setPreferredLanguage,
}) => {
const history = useHistory();
const language = getLanguage();
const disablePreAppstore = async () => {
if (should_show_exit_traders_modal) {
toggleExitTradersHubModal();
} else {
if (content_flag === ContentFlag.LOW_RISK_CR_EU) {
await switchToCRAccount();
}
setPreferredLanguage(language);
setIsPreAppStore(false);
history.push(routes.root);
}
};
return (
Expand Down Expand Up @@ -137,6 +138,7 @@ const TradingHubHeader = ({
toggleNotifications,
toggleExitTradersHubModal,
switchToCRAccount,
setPreferredLanguage,
}) => {
const is_mf = loginid?.startsWith('MF');
const filterPlatformsForClients = payload =>
Expand Down Expand Up @@ -181,6 +183,7 @@ const TradingHubHeader = ({
toggleExitTradersHubModal={toggleExitTradersHubModal}
content_flag={content_flag}
switchToCRAccount={switchToCRAccount}
setPreferredLanguage={setPreferredLanguage}
/>
<Divider />
<div className='trading-hub-header__menu-right--items'>
Expand Down Expand Up @@ -282,6 +285,7 @@ TradingHubHeader.propTypes = {
toggleExitTradersHubModal: PropTypes.func,
content_flag: PropTypes.string,
switchToCRAccount: PropTypes.func,
setPreferredLanguage: PropTypes.func,
};

export default connect(({ client, modules, notifications, ui, menu, traders_hub }) => ({
Expand All @@ -307,4 +311,5 @@ export default connect(({ client, modules, notifications, ui, menu, traders_hub
toggleExitTradersHubModal: ui.toggleExitTradersHubModal,
content_flag: traders_hub.content_flag,
switchToCRAccount: traders_hub.switchToCRAccount,
setPreferredLanguage: client.setPreferredLanguage,
}))(withRouter(TradingHubHeader));
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';
import { useHistory } from 'react-router-dom';
import { connect } from 'Stores/connect';
import { Button, DesktopWrapper, MobileDialog, MobileWrapper, Modal, Text, UILoader } from '@deriv/components';
import { isMobile, routes, ContentFlag } from '@deriv/shared';
import { localize } from '@deriv/translations';
import { isMobile, ContentFlag } from '@deriv/shared';
import { getLanguage, localize } from '@deriv/translations';

const ExitTradersHubModal = ({
disableApp,
Expand All @@ -16,9 +15,8 @@ const ExitTradersHubModal = ({
account_list,
active_accounts,
setIsLoggingIn,
setPreferredLanguage,
}) => {
const history = useHistory();

const exit_traders_hub_modal_content = (
<Text size={isMobile() ? 'xxs' : 'xs'}>
{localize(`You won’t be able to see your EU account in the traditional view. The open positions in your EU
Expand All @@ -43,6 +41,7 @@ const ExitTradersHubModal = ({
};

const onClickExitButton = async () => {
const language = getLanguage();
setIsPreAppStore(false);
setIsLoggingIn(true);
const cr_account = active_accounts.some(acc => acc.landing_company_shortcode === 'svg');
Expand All @@ -55,7 +54,7 @@ const ExitTradersHubModal = ({
//if eu is currently selected , switch to non-eu on exiting tradershub
await switchAccount(account_list.find(acc => acc.loginid.startsWith('CR'))?.loginid);
}
history.push(routes.root);
setPreferredLanguage(language);
setIsLoggingIn(false);
};

Expand Down Expand Up @@ -103,4 +102,5 @@ export default connect(({ ui, client, traders_hub }) => ({
account_list: client.account_list,
active_accounts: client.active_accounts,
setIsLoggingIn: client.setIsLoggingIn,
setPreferredLanguage: client.setPreferredLanguage,
}))(ExitTradersHubModal);

0 comments on commit 6bdaf92

Please sign in to comment.