import { X } from "lucide-react" import { toast } from "sonner" import { ReactNode, useEffect, useRef } from "react" import { cn } from "@frontend/lib/utils" export default function Notification({ id, message, duration, icon, className, label, }: { id: number | string message: string | ReactNode duration: number icon: ReactNode className: string label: string }) { const loaderRef = useRef(null) useEffect(() => { if (loaderRef.current && duration) { loaderRef.current.style.width = "100%" loaderRef.current.getBoundingClientRect() loaderRef.current.style.width = "0%" } }, [duration]) return (
{icon}
{label}
toast.dismiss(id)} size={20} className="ml-auto cursor-pointer" />
{message}
{duration && (
)}
) }