Skip to content

Commit

Permalink
feat: create success toast message for wallets (#8763)
Browse files Browse the repository at this point in the history
  • Loading branch information
aizad-deriv committed May 30, 2023
1 parent 627c87a commit f7d20a6
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const AppNotificationMessages = ({
'has_changed_two_fa',
'svg_needs_poi',
'svg_poi_expired',
'switched_to_real',
'success_wallets_upgrade',
].includes(message.key) || message.type === 'p2p_completed_order'
: true;

Expand All @@ -156,10 +156,7 @@ const AppNotificationMessages = ({
: excluded_notifications.includes(message.key)
);

const notifications_sublist =
window.location.pathname === routes.cashier_deposit
? filtered_excluded_notifications.filter(message => message.key.includes('switched_to_real'))
: filtered_excluded_notifications.slice(0, notifications_limit);
const notifications_sublist = filtered_excluded_notifications.slice(0, notifications_limit);

if (!should_show_popups) return null;

Expand Down
10 changes: 8 additions & 2 deletions packages/core/src/Stores/Helpers/client-notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ export const getCashierValidations = cashier_arr => {
};

// Notifications keys will not be added to localStorage and will appear again after user logout/login
export const excluded_notifications = ['contract_sold', 'switched_to_real', 'has_changed_two_fa'];
export const excluded_notifications = ['contract_sold', 'has_changed_two_fa', 'success_wallets_upgrade'];

export const priority_toast_messages = ['svg', 'need_fa', 'p2p_daily_limit_increase', 'authenticate'];
export const priority_toast_messages = [
'svg',
'need_fa',
'p2p_daily_limit_increase',
'authenticate',
'success_wallets_upgrade',
];
43 changes: 26 additions & 17 deletions packages/core/src/Stores/notification-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ export default class NotificationStore extends BaseStore {

this.handlePOAAddressMismatchNotifications();

// TODO: Update logic when BE API is integrated [Wallets]
this.showSuccessWalletsUpgradeNotification();

if (!has_enabled_two_fa && obj_total_balance.amount_real > 0) {
this.addNotificationMessage(this.client_notifications.two_f_a);
} else {
Expand Down Expand Up @@ -1574,23 +1577,6 @@ export default class NotificationStore extends BaseStore {
});
};

showAccountSwitchToRealNotification = (loginid, currency) => {
const regulation = loginid?.startsWith('CR') ? localize('non-EU') : localize('EU');

this.addNotificationMessage({
key: 'switched_to_real',
header: localize('Switched to real account'),
message: (
<Localize
i18n_default_text='To access the cashier, you are now in your {{regulation}} {{currency}} ({{loginid}}) account.'
values={{ loginid, currency, regulation }}
/>
),
type: 'info',
should_show_again: true,
});
};

async getP2pCompletedOrders() {
await WS.wait('authorize');
const response = await WS.send?.({ p2p_order_list: 1, active: 0 });
Expand All @@ -1599,4 +1585,27 @@ export default class NotificationStore extends BaseStore {
this.p2p_completed_orders = response?.p2p_order_list?.list || [];
}
}

showSuccessWalletsUpgradeNotification = () => {
const { client } = this.root_store;
const { logout } = client;
this.addNotificationMessage({
key: 'success_wallets_upgrade',
header: localize('Your Wallets are ready'),
message: localize(
'To complete the upgrade, please log out and log in again to add more accounts and make transactions with your Wallets.'
),
action: {
onClick: async () => {
await logout();
this.removeNotificationMessage({
key: this.client_notifications.failed_wallets_upgrade.key,
should_show_again: false,
});
},
text: localize('Log out'),
},
type: 'announce',
});
};
}
1 change: 1 addition & 0 deletions packages/stores/src/mockStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ const mock = (): TStores & { is_mock: boolean } => {
setP2POrderProps: jest.fn(),
showAccountSwitchToRealNotification: jest.fn(),
setP2PRedirectTo: jest.fn(),
showSuccessWalletsUpgradeNotification: jest.fn(),
},
portfolio: {
active_positions: [],
Expand Down
1 change: 1 addition & 0 deletions packages/stores/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ type TNotificationStore = {
setP2POrderProps: () => void;
showAccountSwitchToRealNotification: (loginid: string, currency: string) => void;
setP2PRedirectTo: () => void;
showSuccessWalletsUpgradeNotification: () => void;
};

type TTradersHubStore = {
Expand Down

0 comments on commit f7d20a6

Please sign in to comment.