import { X } from 'lucide-react' import { useEffect } from 'react' import { useTranslation } from 'react-i18next' import { cn } from '@/shared/lib/cn' import { useToastContext } from './toast-store' export function Toaster() { const { toasts, dismiss } = useToastContext() return (
{toasts.map((t) => ( ))}
) } function ToastItem({ id, message, variant, onDismiss, }: { id: number message: string variant: 'default' | 'success' | 'error' onDismiss: (id: number) => void }) { const { t } = useTranslation() useEffect(() => { const timeout = setTimeout(() => onDismiss(id), 4000) return () => clearTimeout(timeout) }, [id, onDismiss]) // Живой регион остаётся обычным контейнером, а закрытие висит на настоящей кнопке: обработчик // клика на самом сообщении недоступен с клавиатуры, и скринридер о нём никак не сообщает. return (
{message}
) }