import { useCallback, useEffect, useRef, useState, type MouseEvent } from "react"; import { Check } from "lucide-react"; import { copyTextToClipboard } from "@/lib/clipboard"; import { cn } from "@/lib/utils"; export function CaseCopyableToken({ value, label, className, containerClassName, truncate = true, stopPropagation, }: { value: string; label: string; className?: string; containerClassName?: string; truncate?: boolean; stopPropagation?: boolean; }) { const [copied, setCopied] = useState(false); const timerRef = useRef>(undefined); useEffect(() => () => clearTimeout(timerRef.current), []); const handleCopy = useCallback((event: MouseEvent) => { if (stopPropagation) { event.preventDefault(); event.stopPropagation(); } void copyTextToClipboard(value).then(() => { setCopied(true); clearTimeout(timerRef.current); timerRef.current = setTimeout(() => setCopied(false), 1500); }); }, [stopPropagation, value]); return ( {copied ? ( Copied ) : null} ); } export function CaseIdentifierKey({ identifier, caseKey, className, stopPropagation, }: { identifier: string; caseKey?: string | null; className?: string; stopPropagation?: boolean; }) { return ( {caseKey ? ( ) : null} ); }