Add files via upload
This commit is contained in:
15
frontend/src/store/useToastStore.js
Normal file
15
frontend/src/store/useToastStore.js
Normal file
@@ -0,0 +1,15 @@
|
||||
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
|
||||
Reference in New Issue
Block a user