/* USAGE: import { toast } from 'sonner'; import { ToastInner } from '@/components/misc/toast-inner'; import { Button } from '@/components/ui/button'; */ 'use client'; import { toast } from 'sonner'; import { X } from 'lucide-react'; import React from 'react'; import { Label } from '@/components/ui/label'; import { Button } from '@/components/ui/button'; import * as Icons from 'lucide-react'; interface ToastInnerProps { title: string; description?: string; buttonText?: string; onAction?: () => void; toastId: string | number; variant?: | 'default' | 'success' | 'error' | 'info' | 'warning' | 'notification'; iconName?: keyof typeof Icons; closeOnAction?: boolean; } const variantConfig = { default: { bgColor: 'bg-neutral-150', defaultIcon: 'Info', }, success: { bgColor: 'bg-green-200', defaultIcon: 'CheckCircle', }, error: { bgColor: 'bg-red-200', defaultIcon: 'XCircle', }, info: { bgColor: 'bg-blue-200', defaultIcon: 'Info', }, warning: { bgColor: 'bg-yellow-200', defaultIcon: 'AlertTriangle', }, notification: { bgColor: 'bg-neutral-150', defaultIcon: 'BellRing', }, }; export const ToastInner: React.FC = ({ title, description, buttonText, onAction, toastId, variant = 'default', iconName, closeOnAction = true, }) => { const bgColor = variantConfig[variant].bgColor; // fallback to variant's default icon if iconName is not provided const iconKey = (iconName || variantConfig[variant].defaultIcon) as keyof typeof Icons; const Icon = Icons[iconKey] as React.ComponentType; return (
{/* Close Button */}
{variant !== 'default' && (
)} {/* Text Content */}
{title}
{description && }
{/* Action Button */}
{onAction && buttonText && ( )}
); };