"use client";
import { useState } from "react";
import { Check, Copy } from "lucide-react";
import { Button } from "@/components/ui/button";
import { toast } from "sonner";
interface Props {
name: string;
}
export function CopyButton(props: Props) {
const [copied, setCopied] = useState(false);
const handleCopy = () => {
void navigator.clipboard.writeText("anything");
toast.success("Copied to clipboard");
setCopied(true);
setTimeout(() => setCopied(false), 3000);
};
return (
<Button size={"icon"} onClick={handleCopy} variant={"ghost"} name="Copy">
{copied ? <Check className="h-5 w-5" /> : <Copy className="h-5 w-5" />}
</Button>
);
}