import { Copy, Share2 } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { useState, useEffect } from "react"; export default function CopyLink() { const [link, setLink] = useState(""); const updateLink = () => { const url = decodeURIComponent(window.location.href); setLink(url); }; useEffect(() => { updateLink(); // Listen for custom event window.addEventListener("url-changed", updateLink); return () => { window.removeEventListener("url-changed", updateLink); }; }, []); const handleCopy = async () => { try { await navigator.clipboard.writeText(link); alert("Link copied!"); } catch (err) { console.error("Failed to copy!", err); } }; return ( Share link Anyone who has this link will be able to view this.
); }