31 lines
867 B
TypeScript
31 lines
867 B
TypeScript
import { Toast, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport } from "@/components/ui/toast";
|
|
import { useToast } from "@/components/ui/use-toast";
|
|
|
|
export function Toaster() {
|
|
const { toasts, dismiss } = useToast();
|
|
|
|
return (
|
|
<ToastProvider>
|
|
{toasts.map(({ id, title, description, action, ...props }) => (
|
|
<Toast
|
|
key={id}
|
|
{...props}
|
|
onOpenChange={open => {
|
|
if (!open) {
|
|
dismiss(id);
|
|
}
|
|
}}
|
|
>
|
|
<div className="flex flex-1 flex-col gap-1">
|
|
{title ? <ToastTitle>{title}</ToastTitle> : null}
|
|
{description ? <ToastDescription>{description}</ToastDescription> : null}
|
|
</div>
|
|
{action}
|
|
<ToastClose />
|
|
</Toast>
|
|
))}
|
|
<ToastViewport />
|
|
</ToastProvider>
|
|
);
|
|
}
|