import { Tooltip } from "@heroui/react"; import React, { ReactNode } from "react"; import { NavLink } from "react-router"; import { cn } from "#/utils/utils"; export interface TooltipButtonProps { children: ReactNode; tooltip: string; onClick?: () => void; href?: string; navLinkTo?: string; ariaLabel: string; testId?: string; className?: React.HTMLAttributes["className"]; disabled?: boolean; } export function TooltipButton({ children, tooltip, onClick, href, navLinkTo, ariaLabel, testId, className, disabled = false, }: TooltipButtonProps) { const handleClick = (e: React.MouseEvent) => { if (onClick && !disabled) { onClick(); e.preventDefault(); } }; const buttonContent = ( ); let content; if (navLinkTo && !disabled) { content = ( cn( "hover:opacity-80", isActive ? "text-white" : "text-[#9099AC]", className, ) } aria-label={ariaLabel} data-testid={testId} > {children} ); } else if (navLinkTo && disabled) { // If disabled and has navLinkTo, render a button that looks like a NavLink but doesn't navigate content = ( ); } else if (href && !disabled) { content = ( {children} ); } else if (href && disabled) { // If disabled and has href, render a button that looks like a link but doesn't navigate content = ( ); } else { content = buttonContent; } return ( {content} ); }