import { ref } from "vue"; import { defineStore } from "pinia"; export interface Toast { id: number; message: string; type: "success" | "error" | "warning"; } let nextId = 0; export const useToastStore = defineStore("toast", () => { const toasts = ref([]); function show(message: string, type: "success" | "error" | "warning" = "success") { const id = nextId++; toasts.value.push({ id, message, type }); setTimeout(() => { toasts.value = toasts.value.filter((t) => t.id !== id); }, 4000); } function dismiss(id: number) { toasts.value = toasts.value.filter((t) => t.id !== id); } return { toasts, show, dismiss }; });