import React, { useEffect, useState } from "react"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { Copy, Smartphone, QrCode } from "lucide-react"; import { useToast } from "@/hooks/use-toast"; interface QrCodeModalProps { open: boolean; onOpenChange: (open: boolean) => void; sessionId: string; } const QrCodeModal: React.FC = ({ open, onOpenChange, sessionId, }) => { const { toast } = useToast(); const [qrCodeUrl, setQrCodeUrl] = useState(""); const [phoneUrl, setPhoneUrl] = useState(""); useEffect(() => { if (sessionId) { // Get current host URL - in production this would be the deployed URL const currentHost = window.location.origin; const phonePageUrl = `${currentHost}/phone-camera?sessionId=${sessionId}`; setPhoneUrl(phonePageUrl); // Generate QR code using a public QR code API const qrApiUrl = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(phonePageUrl)}`; setQrCodeUrl(qrApiUrl); } }, [sessionId]); const copyToClipboard = async () => { try { await navigator.clipboard.writeText(phoneUrl); toast({ title: "URL Copied!", description: "Phone camera URL has been copied to clipboard.", }); } catch (error) { toast({ title: "Copy Failed", description: "Could not copy URL to clipboard.", variant: "destructive", }); } }; return (
Add Phone Camera Scan the QR code with your phone to add a camera feed to your recording session.
{/* QR Code Display */}
{qrCodeUrl ? (
QR Code for phone camera
) : (
)}
{/* Instructions */}

How to connect your phone camera:

  1. Open your phone's camera app
  2. Scan the QR code above
  3. Allow camera permissions when prompted
  4. Your phone camera feed will appear in the recording interface
{/* Manual URL Option */}

Or open this URL manually on your phone:

{/* Close Button */}
); }; export default QrCodeModal;