import { useState } from "react"; import { QRCodeSVG } from "qrcode.react"; import { useStore } from "../stores/useStore"; interface PublicRoomPanelProps { onCreateRoom: () => void; } export default function PublicRoomPanel({ onCreateRoom }: PublicRoomPanelProps) { const publicRoomCode = useStore((s) => s.publicRoomCode); const publicRoomUrl = useStore((s) => s.publicRoomUrl); const [showModal, setShowModal] = useState(false); const handleClick = () => { if (publicRoomCode && publicRoomUrl) { setShowModal(true); } else { onCreateRoom(); setShowModal(true); } }; return ( <> Public link Send to anyone → {showModal && ( setShowModal(false)} /> )} > ); } function PublicRoomModal({ code, url, onClose, }: { code: string | null; url: string | null; onClose: () => void; }) { const [copied, setCopied] = useState(false); const copyToClipboard = () => { if (!url) return; navigator.clipboard.writeText(url); setCopied(true); setTimeout(() => setCopied(false), 1500); }; return ( e.stopPropagation()} > Public link Receive from anyone {!code || !url ? ( Generating… ) : ( <> {code.toUpperCase()} {copied ? "Copied ✓" : url} Anyone with this code or link can send you files. Expires in 10 minutes. > )} Close ); }
Generating…
{code.toUpperCase()}
Anyone with this code or link can send you files. Expires in 10 minutes.