"use client"; import { useState } from "react"; import { Check, Copy } from "lucide-react"; import { Button } from "@/app/components/ui/button"; import { useT } from "@/app/lib/i18n/MessagesProvider"; /** A page address with a button that copies its full URL (this site's origin plus the path). */ export function CopyAddress({ address }: { address: string }) { const t = useT(); const [state, setState] = useState<"idle" | "copied" | "failed">("idle"); async function copy() { try { await navigator.clipboard.writeText(`${window.location.origin}${address}`); setState("copied"); setTimeout(() => setState("idle"), 2000); } catch { setState("failed"); } } return ( {address} {state !== "idle" ? ( {t(state === "copied" ? "QrCopied" : "CopyFailed")} ) : null} ); }