import React, { useState, useEffect } from "react"; import { motion, AnimatePresence } from "framer-motion"; import { X, Copy, Check, Loader2 } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; export default function ShareLinkModal({ isOpen, onClose, shareLink, isLoading }) { const [copied, setCopied] = useState(false); useEffect(() => { if (!isOpen) { setCopied(false); } }, [isOpen]); const handleCopy = async () => { if (!shareLink) return; try { await navigator.clipboard.writeText(shareLink); setCopied(true); setTimeout(() => setCopied(false), 2000); } catch (err) { // Fallback for older browsers const textArea = document.createElement("textarea"); textArea.value = shareLink; textArea.style.position = "fixed"; textArea.style.opacity = "0"; document.body.appendChild(textArea); textArea.select(); try { document.execCommand("copy"); setCopied(true); setTimeout(() => setCopied(false), 2000); } catch (fallbackErr) { console.error("Failed to copy:", fallbackErr); } document.body.removeChild(textArea); } }; if (!isOpen) return null; return (
{/* Backdrop */} {/* Modal */} e.stopPropagation()} > {/* Header */}

Copy Share Link

{/* Content */}
{isLoading ? (

Generating share link...

) : shareLink ? (

Share this link with anyone you want to give access to this extraction. They'll need to sign in to view it.

) : (

No share link available

)}
); }