import { useState, useCallback } from "react" export interface Toast { id: string title?: string description?: string action?: React.ReactNode variant?: "default" | "destructive" } export function useToast() { const [toasts, setToasts] = useState([]) const toast = useCallback( ({ title, description, action, variant = "default", }: Omit) => { const id = Math.random().toString(36).substr(2, 9) const newToast: Toast = { id, title, description, action, variant } setToasts((prev) => [...prev, newToast]) // Auto-dismiss after 3 seconds setTimeout(() => { setToasts((prev) => prev.filter((t) => t.id !== id)) }, 3000) return id }, [] ) const dismiss = useCallback((toastId: string) => { setToasts((prev) => prev.filter((t) => t.id !== toastId)) }, []) return { toast, toasts, dismiss, } }