// * Packages import { Link } from "@inertiajs/react"; import { ButtonHTMLAttributes, CSSProperties, MouseEventHandler, ReactNode, } from "react"; import { VariantProps } from "class-variance-authority"; // * Components shadcn import { Button, buttonVariants } from "@/components/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; type ButtonVariant = VariantProps["variant"]; type ButtonSize = VariantProps["size"]; type ButtonType = ButtonHTMLAttributes["type"]; type BtnOptionnalLinkWithTooltipProps = { link?: string | null; content: ReactNode; tooltipContent: ReactNode; className?: string; type?: ButtonType; size?: ButtonSize; variant?: ButtonVariant; externalLink?: boolean; disabled?: boolean; style?: CSSProperties; onClick?: MouseEventHandler; }; export default function BtnOptionnalLinkWithTooltip({ link = null, content, tooltipContent, className = "", type = "button", size = "icon", variant = "default", externalLink = false, disabled = false, style, onClick, ...props }: BtnOptionnalLinkWithTooltipProps) { let innerContent: ReactNode = content; if (link !== null) { if (externalLink) { innerContent = disabled ? ( ) : ( {content} ); } else { innerContent = {content}; } } return ( {tooltipContent} ); }