"use client"; import { useState } from "react"; interface CopyButtonProps { code: string; } export function CopyButton({ code }: CopyButtonProps) { const [copied, setCopied] = useState(false); const handleCopy = async () => { try { await navigator.clipboard.writeText(code); setCopied(true); setTimeout(() => setCopied(false), 2000); } catch (error) { console.error("Failed to copy to clipboard:", error); // Optionally, you could set an error state or show a toast notification here } }; return ( ); }