"use client" import { useState } from "react" import { getAuth } 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 auth = getAuth() const { data: session } = auth?.useSession() ?? { data: null } 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