import { defineStore } from "pinia"; import { Notif } from "../interfaces"; import { NotifType } from "../composables/enums"; const useNotifStore = defineStore("notification", { state: () => ({ notifs: [], }), actions: { showNotification(new_text: string, new_type?: NotifType) { this.notifs.push({ text: new_text, type: new_type, }); setTimeout(() => { this.notifs.shift(); }, 3000); }, }, }); class Notification { constructor(text: string, type?: NotifType) { useNotifStore().showNotification(text, type); } } export { useNotifStore, Notification, NotifType };