Files
fabdash/frontend/src/store/useToastStore.js

16 lines
389 B
JavaScript
Raw Normal View History

2026-03-05 15:39:21 -06:00
import { create } from 'zustand'
let _id = 0
const useToastStore = create((set) => ({
toasts: [],
addToast: ({ message, undoFn, duration = 30 }) => {
const id = ++_id
set(s => ({ toasts: [...s.toasts, { id, message, undoFn, duration }] }))
return id
},
removeToast: (id) => set(s => ({ toasts: s.toasts.filter(t => t.id !== id) })),
}))
export default useToastStore