"use client" import { useState, useEffect } from "react" import { motion } from "framer-motion" import { GatoMascota } from "@/components/child/gato-mascota" const ALL_SKILLS = [ { id: "vocal-a", label: "Letra A", emoji: "✈️" }, { id: "vocal-e", label: "Letra E", emoji: "🐘" }, { id: "vocal-i", label: "Letra I", emoji: "🏔️" }, { id: "vocal-o", label: "Letra O", emoji: "🐻" }, { id: "vocal-u", label: "Letra U", emoji: "🍇" }, { id: "numero-1", label: "Número 1", emoji: "1️⃣" }, { id: "numero-2", label: "Número 2", emoji: "2️⃣" }, { id: "numero-3", label: "Número 3", emoji: "3️⃣" }, { id: "numero-4", label: "Número 4", emoji: "4️⃣" }, { id: "numero-5", label: "Número 5", emoji: "5️⃣" }, ] const CHILD_ID_KEY = "edueasy_child_id" export default function LogrosPage() { const [milestones, setMilestones] = useState([]) const [loading, setLoading] = useState(true) useEffect(() => { const childId = localStorage.getItem(CHILD_ID_KEY) if (!childId) { setLoading(false) return } fetch(`/api/milestones?childId=${childId}`) .then((r) => r.json()) .then((data) => { if (Array.isArray(data)) { setMilestones(data.map((m: any) => m.skillCode)) } }) .catch(() => {}) .finally(() => setLoading(false)) }, []) const completedCount = milestones.length return (

{completedCount} de {ALL_SKILLS.length} completados

{loading ? (

Cargando...

) : (
{ALL_SKILLS.map((skill, i) => { const completed = milestones.includes(skill.id) return ( {skill.emoji} {skill.label} ) })}
)}
) }