"use client" import { useState } from "react" import { authClient } from "@/lib/auth-client" import { useRouter } from "next/navigation" import { GatoMascota } from "@/components/child/gato-mascota" export default function PairingPage() { const [code, setCode] = useState("") const [loading, setLoading] = useState(false) const [error, setError] = useState("") const [paired, setPaired] = useState(false) const { data: session } = authClient.useSession() const router = useRouter() const handlePairing = async (e: React.FormEvent) => { e.preventDefault() setLoading(true) setError("") const res = await fetch("/api/pairing", { method: "POST", body: JSON.stringify({ pairingCode: code, deviceFingerprint: navigator.userAgent }), }) const data = await res.json() if (data.error) { setError(data.error) setLoading(false) return } setPaired(true) setLoading(false) } if (!session) { return (

Iniciá sesión primero para emparejar

) } return (

Emparejar iPad

{paired ? (
) : (

Ingresá el código de 8 caracteres que aparece en el iPad

setCode(e.target.value.toUpperCase())} placeholder="Código de 8 letras" maxLength={8} className="w-full rounded-xl border border-border bg-white px-4 py-3 text-center text-2xl tracking-widest uppercase focus:outline-none focus:ring-2 focus:ring-primary" required /> {error &&

{error}

}
)}
) }