import { Check, Copy } from "lucide-react"; import { useState } from "react"; import { toast } from "@/client/lib/toast"; type Props = { value: string; copyValue?: string; label?: string; mono?: boolean; }; export function Copyable({ value, copyValue, label, mono = true }: Props) { const [copied, setCopied] = useState(false); const handleCopy = () => { void navigator.clipboard.writeText(copyValue ?? value).then( () => { setCopied(true); window.setTimeout(() => setCopied(false), 1400); toast.success(`Copied${label ? ` ${label}` : ""}.`); }, () => toast.error(`Could not copy${label ? ` ${label}` : ""}.`), ); }; return (
{value}
); }