import { useState } from 'react'; import { Copy, Check, type LucideIcon } from 'lucide-react'; interface CopyableFieldProps { value: string; icon?: LucideIcon; label?: string; } export default function CopyableField({ value, icon: Icon, label }: CopyableFieldProps) { const [copied, setCopied] = useState(false); const handleCopy = () => { navigator.clipboard.writeText(value).then(() => { setCopied(true); setTimeout(() => setCopied(false), 1500); }).catch(() => { // Clipboard API can fail in non-secure contexts or when permission is denied }); }; return (
{Icon && } {value}
); }