"use client" import { useState } from "react" import { useRouter } from "next/navigation" import { GatoMascota } from "@/components/child/gato-mascota" import { speak } from "@/lib/speech" const CHILD_ID_KEY = "edueasy_child_id" export default function ChildPairingPage() { const [code, setCode] = useState("") const [loading, setLoading] = useState(false) const [error, setError] = useState("") const [paired, setPaired] = useState(false) const router = useRouter() const handlePair = async (e: React.FormEvent) => { e.preventDefault() setLoading(true) setError("") const deviceFingerprint = `child-${navigator.userAgent.slice(0, 64)}` const res = await fetch("/api/pairing", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ pairingCode: code.toUpperCase(), deviceFingerprint, }), }) const data = await res.json() if (data.error) { setError(data.error) setLoading(false) return } localStorage.setItem(CHILD_ID_KEY, data.childId) setPaired(true) speak("¡Emparejado! Ahora podemos aprender juntos") } if (paired) { return (