AI Resource Pro / website · airesourcepro.com / src / components / ui / toaster.tsx
| 1 | "use client" |
| 2 | |
| 3 | import { |
| 4 | Toast, |
| 5 | ToastClose, |
| 6 | ToastDescription, |
| 7 | ToastProvider, |
| 8 | ToastTitle, |
| 9 | ToastViewport, |
| 10 | } from "@/components/ui/toast" |
| 11 | import { useToast } from "@/components/ui/use-toast" |
| 12 | |
| 13 | export function Toaster() { |
| 14 | const { toasts } = useToast() |
| 15 | |
| 16 | return ( |
| 17 | <ToastProvider> |
| 18 | {toasts.map(function ({ id, title, description, action, variant, ...props }) { |
| 19 | return ( |
| 20 | <Toast |
| 21 | key={id} |
| 22 | variant={variant} |
| 23 | {...props} |
| 24 | > |
| 25 | <div className="grid gap-1"> |
| 26 | {title && <ToastTitle>{title}</ToastTitle>} |
| 27 | {description && ( |
| 28 | <ToastDescription>{description}</ToastDescription> |
| 29 | )} |
| 30 | </div> |
| 31 | {action} |
| 32 | <ToastClose /> |
| 33 | </Toast> |
| 34 | ) |
| 35 | })} |
| 36 | <ToastViewport /> |
| 37 | </ToastProvider> |
| 38 | ) |
| 39 | } |