Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create success toast message for wallets #8763

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -306,6 +306,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 @@ -332,6 +332,7 @@ type TNotificationStore = {
setP2POrderProps: () => void;
showAccountSwitchToRealNotification: (loginid: string, currency: string) => void;
setP2PRedirectTo: () => void;
showSuccessWalletsUpgradeNotification: () => void;
};

type TTradersHubStore = {
Expand Down