+
diff --git a/packages/tradershub/src/components/CFDSection/CFDSection.tsx b/packages/tradershub/src/components/CFDSection/CFDSection.tsx
index e33bcc5616c7..7cc75bff3e4e 100644
--- a/packages/tradershub/src/components/CFDSection/CFDSection.tsx
+++ b/packages/tradershub/src/components/CFDSection/CFDSection.tsx
@@ -1,12 +1,27 @@
import React from 'react';
+import useRegulationFlags from '../../hooks/useRegulationFlags';
+import { GetADerivAccountBanner } from '../GetADerivAccountBanner';
+import { useUIContext } from '../UIProvider';
import { CFDContent } from './CFDContent';
import { CFDHeading } from './CFDHeading';
-const CFDSection = () => (
-
-
-
-
-);
+const CFDSection = () => {
+ const { getUIState } = useUIContext();
+ const regulation = getUIState('regulation');
+ const accountType = getUIState('accountType');
+ const { isSuccess, noRealCRNonEUAccount, noRealMFEUAccount } = useRegulationFlags(regulation, accountType);
+
+ return (
+
+
+ {(noRealCRNonEUAccount || noRealMFEUAccount) && isSuccess && (
+
+
+
+ )}
+
+
+ );
+};
export default CFDSection;
diff --git a/packages/tradershub/src/components/CurrencySwitcher/CurrencySwitcher.tsx b/packages/tradershub/src/components/CurrencySwitcher/CurrencySwitcher.tsx
index c2b11e78abe1..3ecfacc194ea 100644
--- a/packages/tradershub/src/components/CurrencySwitcher/CurrencySwitcher.tsx
+++ b/packages/tradershub/src/components/CurrencySwitcher/CurrencySwitcher.tsx
@@ -5,10 +5,12 @@ import { Provider } from '@deriv/library';
import { Button, Text } from '@deriv/quill-design';
import { StandaloneChevronDownBoldIcon } from '@deriv/quill-icons';
import { IconToCurrencyMapper } from '../../constants/constants';
+import useRegulationFlags from '../../hooks/useRegulationFlags';
import { THooks } from '../../types';
import { CurrencySwitcherLoader } from '../Loaders';
import { Modal } from '../Modal';
import { TradingAccountsList } from '../TradingAccountsList';
+import { useUIContext } from '../UIProvider';
type AccountActionButtonProps = {
balance: THooks.ActiveTradingAccount['balance'];
@@ -47,9 +49,18 @@ const CurrencySwitcher = () => {
const { data: activeAccount, isSuccess } = useActiveTradingAccount();
const isDemo = activeAccount?.is_virtual;
const { show } = Provider.useModal();
+ const { getUIState } = useUIContext();
+
+ const accountType = getUIState('accountType');
+
+ const regulation = getUIState('regulation');
+
+ const { noRealCRNonEUAccount, noRealMFEUAccount } = useRegulationFlags(regulation, accountType);
const iconCurrency = isDemo ? 'virtual' : activeAccount?.currency ?? 'virtual';
+ if (noRealCRNonEUAccount || noRealMFEUAccount) return null;
+
if (!isSuccess) return
;
return (
diff --git a/packages/tradershub/src/components/DemoRealSwitcher/DemoRealSwitcher.tsx b/packages/tradershub/src/components/DemoRealSwitcher/DemoRealSwitcher.tsx
index 28c30803543e..8bccec302fa9 100644
--- a/packages/tradershub/src/components/DemoRealSwitcher/DemoRealSwitcher.tsx
+++ b/packages/tradershub/src/components/DemoRealSwitcher/DemoRealSwitcher.tsx
@@ -3,6 +3,7 @@ import { useOnClickOutside } from 'usehooks-ts';
import { useActiveTradingAccount, useAuthorize, useTradingAccountsList } from '@deriv/api';
import { Button, qtMerge, Text } from '@deriv/quill-design';
import { LabelPairedChevronDownSmRegularIcon } from '@deriv/quill-icons';
+import { useUIContext } from '../UIProvider';
type TAccount = {
label: string;
@@ -19,19 +20,25 @@ const DemoRealSwitcher = () => {
const { data: activeTradingAccount } = useActiveTradingAccount();
const { switchAccount } = useAuthorize();
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
- const [selected, setSelected] = useState(accountTypes[0]);
- const { label, value } = selected;
+ const activeAccountType = activeTradingAccount?.is_virtual ? 'demo' : 'real';
+ const activeType = accountTypes.find(account => account.value === activeAccountType);
+ const [selected, setSelected] = useState(activeType);
+ const { label, value } = selected || {};
+ const { setUIState } = useUIContext();
const ref = useRef(null);
useOnClickOutside(ref, () => setIsDropdownOpen(false));
+ const firstRealLoginId = tradingAccountsList?.find(acc => !acc.is_virtual)?.loginid;
+
+ const demoLoginId = tradingAccountsList?.find(acc => acc.is_virtual)?.loginid;
+
useEffect(() => {
- const activeAccountType = activeTradingAccount?.is_virtual ? 'demo' : 'real';
- const activeAccount = accountTypes.find(account => account.value === activeAccountType);
- if (activeAccount) {
- setSelected(activeAccount);
+ if (activeType) {
+ setSelected(activeType);
+ setUIState('accountType', activeAccountType);
}
- }, [activeTradingAccount]);
+ }, [activeAccountType, activeType, setUIState]);
useEffect(() => {
setIsDropdownOpen(false);
@@ -41,12 +48,9 @@ const DemoRealSwitcher = () => {
setIsDropdownOpen(prevState => !prevState);
}, []);
- const firstRealLoginId = tradingAccountsList?.find(acc => !acc.is_virtual)?.loginid;
-
- const demoLoginId = tradingAccountsList?.find(acc => acc.is_virtual)?.loginid;
-
const selectAccount = (account: TAccount) => {
setSelected(account);
+ setUIState('accountType', account.value);
const loginId = account.value === 'demo' ? demoLoginId : firstRealLoginId;
if (loginId) {
diff --git a/packages/tradershub/src/components/Modal/ModalHeader.tsx b/packages/tradershub/src/components/Modal/ModalHeader.tsx
index 7838be71623b..3cdc07b30c3f 100644
--- a/packages/tradershub/src/components/Modal/ModalHeader.tsx
+++ b/packages/tradershub/src/components/Modal/ModalHeader.tsx
@@ -30,7 +30,7 @@ const ModalHeader = ({ className, hideCloseButton = false, title, titleClassName
className
)}
>
- {title &&
{title}}
+ {title &&
{title}}
{!hideCloseButton &&
}
);
diff --git a/packages/tradershub/src/components/RegulationSwitcher/RegulationSwitcherDesktop.tsx b/packages/tradershub/src/components/RegulationSwitcher/RegulationSwitcherDesktop.tsx
index 36a87a6130e2..c61e6513c3c3 100644
--- a/packages/tradershub/src/components/RegulationSwitcher/RegulationSwitcherDesktop.tsx
+++ b/packages/tradershub/src/components/RegulationSwitcher/RegulationSwitcherDesktop.tsx
@@ -1,15 +1,20 @@
import React, { useEffect } from 'react';
-import { useActiveTradingAccount, useAuthorize, useTradingAccountsList } from '@deriv/api';
+import { useActiveTradingAccount, useAuthorize, useIsDIELEnabled, useTradingAccountsList } from '@deriv/api';
import { Button, qtJoin } from '@deriv/quill-design';
import { LabelPairedCircleInfoMdRegularIcon } from '@deriv/quill-icons';
import { Text } from '@deriv-com/ui/dist/components/Text';
import { Regulation } from '../../constants/constants';
+import useRegulationFlags from '../../hooks/useRegulationFlags';
import { useUIContext } from '../UIProvider';
const RegulationSwitcherDesktop = () => {
const { switchAccount } = useAuthorize();
const { data: tradingAccountsList } = useTradingAccountsList();
const { getUIState, setUIState } = useUIContext();
+ const { data: isDIEL } = useIsDIELEnabled();
+ const regulation = getUIState('regulation');
+ const accountType = getUIState('accountType');
+ const { isEU, isHighRisk } = useRegulationFlags(regulation, accountType);
const realCRAccount = tradingAccountsList?.find(account => account.loginid.startsWith('CR'))?.loginid ?? '';
@@ -36,9 +41,9 @@ const RegulationSwitcherDesktop = () => {
};
useEffect(() => {
- if (activeTrading?.loginid.startsWith('CR')) {
+ if (activeTrading?.loginid.startsWith('CR') || isDIEL || isHighRisk) {
setUIState('regulation', Regulation.NonEU);
- } else if (activeTrading?.loginid.startsWith('MF')) {
+ } else if (activeTrading?.loginid.startsWith('MF') || isEU) {
setUIState('regulation', Regulation.EU);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
diff --git a/packages/tradershub/src/components/UIProvider/UIProvider.tsx b/packages/tradershub/src/components/UIProvider/UIProvider.tsx
index 377dc3447bbd..f051242af851 100644
--- a/packages/tradershub/src/components/UIProvider/UIProvider.tsx
+++ b/packages/tradershub/src/components/UIProvider/UIProvider.tsx
@@ -33,11 +33,14 @@ export const UIProvider = ({ children }: { children: React.ReactNode }) => {
[uiState]
);
- const updateUIState =