'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { Link2, ArrowRight, Loader2, AlertCircle, Clock, Shield } from 'lucide-react' export default function ConnectPage() { const [sessionCode, setSessionCode] = useState('') const [isConnecting, setIsConnecting] = useState(false) const [error, setError] = useState(null) const router = useRouter() const handleConnect = async (e: React.FormEvent) => { e.preventDefault() setIsConnecting(true) setError(null) const code = sessionCode.replace(/\s/g, '').toUpperCase() if (code.length !== 6) { setError('Please enter a valid 6-character session code') setIsConnecting(false) return } try { const res = await fetch('/api/connect', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ code }), }) const data = await res.json() if (!res.ok) { setError(data.error || 'Invalid or expired session code') setIsConnecting(false) return } router.push(`/viewer/${data.sessionId}?token=${data.viewerToken}`) } catch { setError('Network error. Please try again.') setIsConnecting(false) } } const formatCode = (value: string) => { const cleaned = value.replace(/[^A-Za-z0-9]/g, '').toUpperCase() if (cleaned.length <= 3) return cleaned return `${cleaned.slice(0, 3)} ${cleaned.slice(3, 6)}` } return (

Quick Connect

Enter a session code to connect to a remote machine

Enter Session Code Ask the person on the remote machine to generate a code from their RemoteLink agent
setSessionCode(formatCode(e.target.value))} maxLength={7} className="text-center text-3xl font-mono tracking-widest h-16 bg-secondary/50" autoComplete="off" autoFocus />
{error && (

{error}

)}

Codes expire

Session codes are valid for 10 minutes

Secure connection

All sessions are end-to-end encrypted

) }