({
+export default connect(({ client, common, ui, notifications }) => ({
acc_switcher_disabled_message: ui.account_switcher_disabled_message,
account_type: client.account_type,
addNotificationMessage: notifications.addNotificationMessage,
@@ -230,10 +223,8 @@ export default connect(({ client, common, ui, menu, modules, notifications }) =>
is_notifications_visible: notifications.is_notifications_visible,
is_route_modal_on: ui.is_route_modal_on,
is_virtual: client.is_virtual,
- menu_items: menu.extensions,
notifications_count: notifications.notifications.length,
openRealAccountSignup: ui.openRealAccountSignup,
- replaceCashierMenuOnclick: modules.cashier.general_store.replaceCashierMenuOnclick,
platform: common.platform,
removeNotificationMessage: notifications.removeNotificationMessage,
toggleAccountsDialog: ui.toggleAccountsDialog,
diff --git a/packages/core/src/App/Containers/Layout/header/trading-hub-header.jsx b/packages/core/src/App/Containers/Layout/header/trading-hub-header.jsx
index ca6f7b89e42d..c7652526b357 100644
--- a/packages/core/src/App/Containers/Layout/header/trading-hub-header.jsx
+++ b/packages/core/src/App/Containers/Layout/header/trading-hub-header.jsx
@@ -113,7 +113,7 @@ const ShowNotifications = ({ is_notifications_visible, notifications_count, togg
);
};
-const MemoizedMenuLinks = React.memo(MenuLinks);
+
const TradingHubHeader = ({
content_flag,
header_extension,
@@ -121,15 +121,11 @@ const TradingHubHeader = ({
is_eu_country,
is_eu,
is_logged_in,
- is_mobile,
is_mt5_allowed,
is_notifications_visible,
- is_pre_appstore,
loginid,
- menu_items,
modal_data,
notifications_count,
- replaceCashierMenuOnclick,
setIsOnboardingVisited,
setIsPreAppStore,
should_show_exit_traders_modal,
@@ -165,13 +161,7 @@ const TradingHubHeader = ({
@@ -263,16 +253,12 @@ TradingHubHeader.propTypes = {
is_eu_country: PropTypes.bool,
is_eu: PropTypes.bool,
is_logged_in: PropTypes.bool,
- is_mobile: PropTypes.bool,
is_mt5_allowed: PropTypes.bool,
is_notifications_visible: PropTypes.bool,
- is_pre_appstore: PropTypes.bool,
is_settings_modal_on: PropTypes.bool,
loginid: PropTypes.string,
- menu_items: PropTypes.array,
modal_data: PropTypes.object,
notifications_count: PropTypes.number,
- replaceCashierMenuOnclick: PropTypes.func,
setIsPreAppStore: PropTypes.func,
setIsOnboardingVisited: PropTypes.func,
settings_extension: PropTypes.array,
@@ -284,22 +270,18 @@ TradingHubHeader.propTypes = {
switchToCRAccount: PropTypes.func,
};
-export default connect(({ client, modules, notifications, ui, menu, traders_hub }) => ({
+export default connect(({ client, notifications, ui, traders_hub }) => ({
header_extension: ui.header_extension,
is_dark_mode: ui.is_dark_mode_on,
is_eu_country: client.is_eu_country,
is_eu: client.is_eu,
is_logged_in: client.is_logged_in,
- is_mobile: ui.is_mobile,
is_mt5_allowed: client.is_mt5_allowed,
is_notifications_visible: notifications.is_notifications_visible,
- is_pre_appstore: client.is_pre_appstore,
modal_data: traders_hub.modal_data,
notifications_count: notifications.notifications.length,
toggleNotifications: notifications.toggleNotificationsModal,
loginid: client.loginid,
- menu_items: menu.extensions,
- replaceCashierMenuOnclick: modules.cashier.general_store.replaceCashierMenuOnclick,
setIsOnboardingVisited: traders_hub.setIsOnboardingVisited,
setIsPreAppStore: client.setIsPreAppStore,
should_show_exit_traders_modal: traders_hub.should_show_exit_traders_modal,
diff --git a/packages/core/src/App/Containers/RealAccountSignup/real-account-signup.jsx b/packages/core/src/App/Containers/RealAccountSignup/real-account-signup.jsx
index 4cff6b1edaab..7c1d5240da15 100644
--- a/packages/core/src/App/Containers/RealAccountSignup/real-account-signup.jsx
+++ b/packages/core/src/App/Containers/RealAccountSignup/real-account-signup.jsx
@@ -112,7 +112,6 @@ const RealAccountSignup = ({
is_real_acc_signup_on,
real_account_signup_target,
realAccountSignup,
- replaceCashierMenuOnclick,
routing_history,
setIsDeposit,
setIsTradingAssessmentForNewUserEnabled,
@@ -291,7 +290,6 @@ const RealAccountSignup = ({
};
const closeModalThenOpenCashier = () => {
- replaceCashierMenuOnclick();
closeRealAccountSignup();
history.push(routes.cashier_deposit);
};
@@ -360,7 +358,6 @@ const RealAccountSignup = ({
}, [is_from_restricted_country, is_real_acc_signup_on]);
const closeModal = e => {
- replaceCashierMenuOnclick();
// Do not close modal on external link and popover click event
if (
e?.target.getAttribute('rel') === 'noopener noreferrer' ||
@@ -643,7 +640,6 @@ export default connect(({ ui, client, common, traders_hub, modules }) => ({
is_real_acc_signup_on: ui.is_real_acc_signup_on,
real_account_signup_target: ui.real_account_signup_target,
realAccountSignup: client.realAccountSignup,
- replaceCashierMenuOnclick: modules.cashier.general_store.replaceCashierMenuOnclick,
routing_history: common.app_routing_history,
setCFDScore: client.setCFDScore,
setIsDeposit: modules.cashier.general_store.setIsDeposit,
diff --git a/packages/core/src/Stores/index.js b/packages/core/src/Stores/index.js
index 0c1e8e15cfb3..0a6dad2e6b9d 100644
--- a/packages/core/src/Stores/index.js
+++ b/packages/core/src/Stores/index.js
@@ -4,7 +4,6 @@ import GTMStore from './gtm-store';
import RudderStackStore from './rudderstack-store';
import PushWooshStore from './pushwoosh-store';
import ModulesStore from './Modules';
-import MenuStore from './menu-store';
import NotificationStore from './notification-store';
import UIStore from './ui-store';
import ActiveSymbolsStore from './active-symbols-store';
@@ -22,7 +21,6 @@ export default class RootStore {
this.ui = new UIStore(this);
this.gtm = new GTMStore(this);
this.rudderstack = new RudderStackStore(this);
- this.menu = new MenuStore(this);
this.pushwoosh = new PushWooshStore(this);
this.notifications = new NotificationStore(this);
this.active_symbols = new ActiveSymbolsStore(this);
diff --git a/packages/core/src/Stores/menu-store.js b/packages/core/src/Stores/menu-store.js
deleted file mode 100644
index 42cf4ef91dfa..000000000000
--- a/packages/core/src/Stores/menu-store.js
+++ /dev/null
@@ -1,46 +0,0 @@
-import React from 'react';
-import { action, observable, makeObservable } from 'mobx';
-import { Icon } from '@deriv/components';
-import { localize } from '@deriv/translations';
-import { routes } from '@deriv/shared';
-import BaseStore from './base-store';
-
-export default class MenuStore extends BaseStore {
- extensions = [
- {
- id: 'dt_reports_tab',
- icon: ,
- text: () => localize('Reports'),
- link_to: routes.reports,
- login_only: true,
- },
- ];
-
- constructor() {
- // TODO: [mobx-undecorate] verify the constructor arguments and the arguments of this automatically generated super call
- super();
-
- makeObservable(this, {
- extensions: observable,
- attach: action.bound,
- detach: action.bound,
- });
- }
-
- attach(menu) {
- if (!(menu instanceof Object)) {
- throw new TypeError('Menu is not an instance of object.');
- }
- this.extensions.push(menu);
- }
-
- update(menu, index) {
- if (this.extensions[index]) {
- this.extensions[index] = menu;
- }
- }
-
- detach(menu) {
- this.extensions = this.extensions.filter(extension => extension.id !== menu);
- }
-}
diff --git a/packages/hooks/src/index.ts b/packages/hooks/src/index.ts
index 4417d0dd313a..0961e4908618 100644
--- a/packages/hooks/src/index.ts
+++ b/packages/hooks/src/index.ts
@@ -5,4 +5,7 @@ export { default as useNeedFinancialAssessment } from './useNeedFinancialAssessm
export { default as useRealSTPAccount } from './useRealSTPAccount';
export { default as useNeedTNC } from './useNeedTNC';
export { default as useDepositLocked } from './useDepositLocked';
+export { default as useHasSetCurrency } from './useHasSetCurrency';
+export { default as useHasActiveRealAccount } from './useHasActiveRealAccount';
+export { default as useP2PNotificationCount } from './useP2PNotificationCount';
export { default as useOnrampVisible } from './useOnrampVisible';
diff --git a/packages/hooks/src/useHasActiveRealAccount.ts b/packages/hooks/src/useHasActiveRealAccount.ts
new file mode 100644
index 000000000000..df58321dfc95
--- /dev/null
+++ b/packages/hooks/src/useHasActiveRealAccount.ts
@@ -0,0 +1,12 @@
+import { useStore } from '@deriv/stores';
+
+const useHasActiveRealAccount = () => {
+ const { client } = useStore();
+ const { active_accounts } = client;
+
+ const has_active_real_account = active_accounts.some(account => account.is_virtual === 0);
+
+ return has_active_real_account;
+};
+
+export default useHasActiveRealAccount;
diff --git a/packages/hooks/src/useHasSetCurrency.ts b/packages/hooks/src/useHasSetCurrency.ts
new file mode 100644
index 000000000000..702323dad4a5
--- /dev/null
+++ b/packages/hooks/src/useHasSetCurrency.ts
@@ -0,0 +1,17 @@
+import { useStore } from '@deriv/stores';
+import useHasActiveRealAccount from './useHasActiveRealAccount';
+
+const useHasSetCurrency = () => {
+ const { client } = useStore();
+ const { account_list } = client;
+ const has_active_real_account = useHasActiveRealAccount();
+ const has_real_account = account_list
+ .filter(account => !account.is_virtual)
+ .some(account => account.title !== 'Real');
+
+ const has_set_currency = has_real_account || !has_active_real_account;
+
+ return has_set_currency;
+};
+
+export default useHasSetCurrency;
diff --git a/packages/hooks/src/useP2PNotificationCount.ts b/packages/hooks/src/useP2PNotificationCount.ts
new file mode 100644
index 000000000000..ef193a648628
--- /dev/null
+++ b/packages/hooks/src/useP2PNotificationCount.ts
@@ -0,0 +1,46 @@
+import { useStore } from '@deriv/stores';
+import { useEffect, useState } from 'react';
+
+type TNotification = {
+ order_id: string;
+ is_seen: boolean;
+ is_active: boolean;
+};
+
+type TClientData = {
+ is_cached: boolean;
+ notifications: TNotification[];
+};
+
+type TP2PSettings = Record;
+
+const useP2PNotificationCount = () => {
+ const [p2p_settings, setP2PSettings] = useState(
+ JSON.parse(localStorage.getItem('p2p_settings') || '{}')
+ );
+ const { client } = useStore();
+ const { loginid } = client;
+ const notifications = loginid ? p2p_settings[loginid]?.notifications : null;
+
+ useEffect(() => {
+ const onStorageChanged = () => {
+ const data = localStorage.getItem('p2p_settings');
+
+ if (data) {
+ setP2PSettings(JSON.parse(data));
+ }
+ };
+
+ window.addEventListener('storage', onStorageChanged);
+
+ return () => {
+ window.removeEventListener('storage', onStorageChanged);
+ };
+ }, []);
+
+ const p2p_notification_count = notifications?.filter(notification => !notification.is_seen).length || 0;
+
+ return p2p_notification_count;
+};
+
+export default useP2PNotificationCount;
diff --git a/packages/p2p/src/stores/general-store.js b/packages/p2p/src/stores/general-store.js
index 2f275e2986ca..a63c36269ccf 100644
--- a/packages/p2p/src/stores/general-store.js
+++ b/packages/p2p/src/stores/general-store.js
@@ -889,6 +889,7 @@ export default class GeneralStore extends BaseStore {
p2p_settings[this.client.loginid] = user_settings;
localStorage.setItem('p2p_settings', JSON.stringify(p2p_settings));
+ window.dispatchEvent(new Event('storage'));
this.setNotificationCount(notification_count);
this.setActiveNotificationCount(active_notification_count);
diff --git a/packages/stores/types.ts b/packages/stores/types.ts
index 01b2c79601d2..20d6d864fc34 100644
--- a/packages/stores/types.ts
+++ b/packages/stores/types.ts
@@ -30,6 +30,7 @@ type TAccountsList = {
// balance is missing in @deriv/api-types
type TActiveAccount = TAccount & {
balance?: number;
+ is_virtual: number;
};
type TAuthenticationStatus = { document_status: string; identity_status: string };