MyCrypto/common/actions/notifications.js

48 lines
883 B
JavaScript
Raw Normal View History

2017-06-21 16:31:59 -07:00
// @flow
export type NOTIFICATION_LEVEL = 'danger' | 'warning' | 'success' | 'info';
export type Notification = {
2017-07-03 20:28:56 -07:00
level: NOTIFICATION_LEVEL,
msg: string,
duration?: number
2017-06-21 16:31:59 -07:00
};
export type ShowNotificationAction = {
2017-07-03 20:28:56 -07:00
type: 'SHOW_NOTIFICATION',
payload: Notification
2017-06-21 16:31:59 -07:00
};
2017-06-22 14:16:21 -07:00
export type CloseNotificationAction = {
2017-07-03 20:28:56 -07:00
type: 'CLOSE_NOTIFICATION',
payload: Notification
2017-06-21 16:31:59 -07:00
};
2017-07-03 20:28:56 -07:00
export type NotificationsAction =
| ShowNotificationAction
| CloseNotificationAction;
2017-06-21 16:31:59 -07:00
export function showNotification(
2017-07-03 20:28:56 -07:00
level: NOTIFICATION_LEVEL = 'info',
msg: string,
duration?: number
2017-06-21 16:31:59 -07:00
): ShowNotificationAction {
2017-07-03 20:28:56 -07:00
return {
type: 'SHOW_NOTIFICATION',
payload: {
level,
msg,
duration
}
};
2017-06-21 16:31:59 -07:00
}
2017-07-03 20:28:56 -07:00
export function closeNotification(
notification: Notification
): CloseNotificationAction {
return {
type: 'CLOSE_NOTIFICATION',
payload: notification
};
2017-06-21 16:31:59 -07:00
}