'use client' import { createContext, useContext, useState, ReactNode } from 'react' import { X, CheckCircle, AlertCircle, Info } from 'lucide-react' type ToastType = 'success' | 'error' | 'info' interface Toast { id: number message: string type: ToastType } interface ToastContextType { showToast: (message: string, type?: ToastType) => void } const ToastContext = createContext(undefined) export function ToastProvider({ children }: { children: ReactNode }) { const [toasts, setToasts] = useState([]) const showToast = (message: string, type: ToastType = 'info') => { const id = Date.now() setToasts((prev) => [...prev, { id, message, type }]) setTimeout(() => { setToasts((prev) => prev.filter((toast) => toast.id !== id)) }, 3000) } const removeToast = (id: number) => { setToasts((prev) => prev.filter((toast) => toast.id !== id)) } return ( {children}
{toasts.map((toast) => (
{toast.type === 'success' && } {toast.type === 'error' && } {toast.type === 'info' && }

{toast.message}

))}
) } export function useToast() { const context = useContext(ToastContext) if (!context) { throw new Error('useToast must be used within ToastProvider') } return context }