2021-12-21 16:46:19 +01:00
|
|
|
import mitt from "mitt";
|
|
|
|
|
|
|
|
type NotifyEvents = {
|
2021-12-21 16:51:25 +01:00
|
|
|
notification: UpNotification;
|
2021-12-21 16:46:19 +01:00
|
|
|
};
|
|
|
|
|
2021-12-22 11:56:06 +01:00
|
|
|
export type UpNotificationLevel = "info" | "warning" | "error";
|
2021-12-21 16:51:25 +01:00
|
|
|
|
|
|
|
export interface INotification {
|
|
|
|
id: string;
|
2021-12-21 16:46:19 +01:00
|
|
|
content: string;
|
2021-12-22 11:56:06 +01:00
|
|
|
level: UpNotificationLevel;
|
2021-12-21 16:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export class UpNotification implements INotification {
|
|
|
|
id: string;
|
|
|
|
content: string;
|
2021-12-22 11:56:06 +01:00
|
|
|
level: UpNotificationLevel;
|
2021-12-21 16:51:25 +01:00
|
|
|
|
2021-12-22 11:56:06 +01:00
|
|
|
constructor(content: string, level?: UpNotificationLevel) {
|
2021-12-21 16:51:25 +01:00
|
|
|
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>();
|