import { defineStore } from 'pinia' import { ref } from 'vue' export interface Toast { id: number kind: 'success' | 'error' message: string } export const useToastStore = defineStore('toast', () => { const items = ref([]) let next = 1 function push(kind: Toast['kind'], message: string) { const id = next++ items.value.push({ id, kind, message }) setTimeout(() => (items.value = items.value.filter((t) => t.id !== id)), 4000) } return { items, success: (m: string) => push('success', m), error: (m: string) => push('error', m), } })