| // src/components/conference/JoinConferenceModal.tsx | |
| import { useState } from "react"; | |
| import { X, Copy, Mail } from "lucide-react"; | |
| import { toast } from "react-toastify"; | |
| interface JoinConferenceModalProps { | |
| isOpen: boolean; | |
| onClose: () => void; | |
| roomId: string; | |
| onEmailInvite?: (email: string, inviteLink: string) => Promise<void>; | |
| } | |
| export function JoinConferenceModal({ isOpen, onClose, roomId, onEmailInvite }: JoinConferenceModalProps) { | |
| const [copied, setCopied] = useState(false); | |
| const [email, setEmail] = useState(""); | |
| const [sending, setSending] = useState(false); | |
| const joinLink = `${window.location.origin}/conference/room/${roomId}`; | |
| const handleCopy = async () => { | |
| try { | |
| await navigator.clipboard.writeText(joinLink); | |
| setCopied(true); | |
| toast.success("Invite link copied!"); | |
| setTimeout(() => setCopied(false), 2000); | |
| } catch (err) { | |
| toast.error("Could not copy link. Please copy manually."); | |
| } | |
| }; | |
| const handleEmailInvite = async () => { | |
| if (!email || !onEmailInvite) return; | |
| if (!/^[^\s@]+@([^\s@.,]+\.)+[^\s@.,]{2,}$/.test(email)) { | |
| toast.error("Enter a valid email address"); | |
| return; | |
| } | |
| setSending(true); | |
| try { | |
| await onEmailInvite(email, joinLink); | |
| toast.success(`Invite sent to ${email}`); | |
| setEmail(""); | |
| } catch { | |
| toast.error("Failed to send invite"); | |
| } finally { | |
| setSending(false); | |
| } | |
| }; | |
| if (!isOpen) return null; | |
| return ( | |
| <div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4" onClick={onClose}> | |
| <div | |
| className="bg-white dark:bg-gray-800 rounded-2xl max-w-md w-full p-6 shadow-xl" | |
| onClick={(e) => e.stopPropagation()} | |
| > | |
| <div className="flex items-center justify-between mb-4"> | |
| <h2 className="text-lg font-bold">Invite to Conference</h2> | |
| <button onClick={onClose} className="text-gray-500 hover:text-gray-700"> | |
| <X className="w-5 h-5" /> | |
| </button> | |
| </div> | |
| <p className="text-sm text-gray-500 mb-3"> | |
| Copy and share this link with others to join the video call. | |
| </p> | |
| {/* Link + copy button */} | |
| <div className="flex gap-2 mb-4"> | |
| <input | |
| readOnly | |
| value={joinLink} | |
| className="flex-1 text-sm p-2 border rounded-lg bg-gray-50 dark:bg-gray-700" | |
| /> | |
| <button onClick={handleCopy} className="btn btn-primary btn-sm gap-1"> | |
| <Copy className="w-4 h-4" /> | |
| {copied ? "Copied" : "Copy"} | |
| </button> | |
| </div> | |
| {/* Email invite (if callback provided) */} | |
| {onEmailInvite && ( | |
| <div className="border-t border-gray-200 dark:border-gray-700 pt-4"> | |
| <label className="block text-sm font-medium mb-1">Send via email</label> | |
| <div className="flex gap-2"> | |
| <input | |
| type="email" | |
| value={email} | |
| onChange={(e) => setEmail(e.target.value)} | |
| placeholder="colleague@example.com" | |
| className="flex-1 text-sm p-2 border rounded-lg dark:bg-gray-700" | |
| /> | |
| <button | |
| onClick={handleEmailInvite} | |
| disabled={sending || !email} | |
| className="btn btn-secondary btn-sm gap-1" | |
| > | |
| <Mail className="w-4 h-4" /> | |
| {sending ? "Sending..." : "Send"} | |
| </button> | |
| </div> | |
| </div> | |
| )} | |
| </div> | |
| </div> | |
| ); | |
| } | |
Xet Storage Details
- Size:
- 3.58 kB
- Xet hash:
- 1e5cdeb90d172505bdc81df657ab1d4144f4217f5a3aaa6eec4b368114ae00ca
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.