"use client"; // This directive indicates that the component is client-side import { useState } from "react"; import { Button } from "../ui/button"; import { Check, Copy } from "lucide-react"; export default function CopyButton({ code }: { code: string }) { const [copied, setCopied] = useState(false); const copyCode = async () => { try { await navigator.clipboard.writeText(code); setCopied(true); setTimeout(() => setCopied(false), 2000); } catch (error) { console.error("Failed to copy!", error); } }; return ( ); }