2024-01-22 22:58:55 +01:00
|
|
|
import mitt from 'mitt';
|
2021-12-21 16:46:19 +01:00
|
|
|
|
|
|
|
type NotifyEvents = {
|
2024-01-22 22:58:55 +01:00
|
|
|
notification: UpNotification;
|
2021-12-21 16:46:19 +01:00
|
|
|
};
|
|
|
|
|
2024-01-22 22:58:55 +01:00
|
|
|
export type UpNotificationLevel = 'info' | 'warning' | 'error';
|
2021-12-21 16:51:25 +01:00
|
|
|
|
|
|
|
export interface INotification {
|
2024-01-22 22:58:55 +01:00
|
|
|
id: string;
|
|
|
|
content: string;
|
|
|
|
level: UpNotificationLevel;
|
2021-12-21 16:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export class UpNotification implements INotification {
|
2024-01-22 22:58:55 +01:00
|
|
|
id: string;
|
|
|
|
content: string;
|
|
|
|
level: UpNotificationLevel;
|
2021-12-21 16:51:25 +01:00
|
|
|
|
2024-01-22 22:58:55 +01:00
|
|
|
constructor(content: string, level?: UpNotificationLevel) {
|
|
|
|
this.id = String(Math.random());
|
|
|
|
this.content = content;
|
|
|
|
this.level = level || 'info';
|
|
|
|
}
|
2021-12-21 16:46:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export const notify = mitt<NotifyEvents>();
|