import { ref } from "vue"; export type NotificationType = "success" | "error" | "info" | "warning"; export interface Notification { id: number; message: string; type: NotificationType; duration: number; } const notifications = ref([]); let notificationId = 0; export function useNotifications() { function showNotification( message: string, type: NotificationType = "success", duration = 2500, ): void { const id = ++notificationId; const notification: Notification = { id, message, type, duration, }; notifications.value.push(notification); // Auto-remove after duration setTimeout(() => { removeNotification(id); }, duration); } function removeNotification(id: number): void { notifications.value = notifications.value.filter((n) => n.id !== id); } return { notifications, showNotification, removeNotification, }; }