import * as React from "react"; import { useToast } from "../hooks/use-toast"; import { Toast, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport, } from "./toast"; import { X } from "lucide-react"; export function Toaster() { const { toasts } = useToast(); return (
{toasts.map(({ id, title, description, action, type, variant, duration, ...props }) => { // Map toast type to variant if variant is not provided const toastVariant = variant || ( type === "success" ? "success" : type === "warning" ? "warning" : type === "info" ? "info" : type === "destructive" ? "destructive" : "default" ); return (
{title && {title}} {description && {description}}
{action}
); })}
); }