mirror of
https://github.com/strapi/strapi.git
synced 2025-08-06 15:53:11 +00:00
39 lines
617 B
JavaScript
39 lines
617 B
JavaScript
![]() |
/*
|
||
|
*
|
||
|
* NotificationProvider actions
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
import {
|
||
|
SHOW_NOTIFICATION,
|
||
|
HIDE_NOTIFICATION
|
||
|
} from './constants';
|
||
|
|
||
|
import { dispatch } from '../../app';
|
||
|
let nextNotificationId = 0;
|
||
|
|
||
|
export function showNotification(message, status) {
|
||
|
nextNotificationId++;
|
||
|
|
||
|
// Start timeout to hide the notification
|
||
|
((id) => {
|
||
|
setTimeout(() => {
|
||
|
dispatch(hideNotification(id));
|
||
|
}, 5000);
|
||
|
})(nextNotificationId);
|
||
|
|
||
|
return {
|
||
|
type: SHOW_NOTIFICATION,
|
||
|
message,
|
||
|
status,
|
||
|
id: nextNotificationId,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
export function hideNotification(id) {
|
||
|
return {
|
||
|
type: HIDE_NOTIFICATION,
|
||
|
id,
|
||
|
};
|
||
|
}
|