feat: multi-profile system with Francesca and Sebastian curricula
- Add Profile enum (ISABELLA, FRANCESCA, SEBASTIAN) to Child model - Add ?profile= query param override to /api/curriculum/next - Pass profile prop from profile-specific pages to ExerciseSession - Fix curriculum import paths (engine uses @/curriculum/ alias) - Clear stale curriculumCache on dev reload - Fix self-referential prerequisites in Francesca etapa-1 - Fix prerequisite chains in Francesca etapa-2,3,4 and Sebastian etapa-2,3 - Add Francesca curriculum: 2-3 digit sums, subtractions, multiplications, short readings - Add Sebastian curriculum: 2-3 digit sums, interactive exercises, Argentine history, flags - All 44 E2E tests pass, TypeScript compiles cleanly
This commit is contained in:
@@ -1,13 +1,20 @@
|
||||
import { NextRequest, NextResponse } from "next/server"
|
||||
import { prisma } from "@/lib/db"
|
||||
import { getNextExercise } from "@/lib/curriculum/engine"
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const childId = request.nextUrl.searchParams.get("childId")
|
||||
const topic = (request.nextUrl.searchParams.get("topic") || "lectura") as "lectura" | "numeros"
|
||||
const topic = request.nextUrl.searchParams.get("topic") || "lectura"
|
||||
if (!childId) {
|
||||
return NextResponse.json({ error: "childId required" }, { status: 400 })
|
||||
}
|
||||
|
||||
const exercise = await getNextExercise(childId, topic)
|
||||
const child = await prisma.child.findUnique({
|
||||
where: { id: childId },
|
||||
select: { profile: true },
|
||||
})
|
||||
|
||||
const profile = (request.nextUrl.searchParams.get("profile") || child?.profile || "ISABELLA").toUpperCase()
|
||||
const exercise = await getNextExercise(childId, topic, profile)
|
||||
return NextResponse.json(exercise || { id: null, done: true })
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import ExerciseSession from "@/components/child/exercise-session"
|
||||
|
||||
export default function FrancescaLecturas() {
|
||||
return (
|
||||
<ExerciseSession
|
||||
topic="lecturas"
|
||||
profile="FRANCESCA"
|
||||
loadingMessage="Preparando lecturas..."
|
||||
completeMessage="¡Terminaste las lecturas por ahora!"
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import ExerciseSession from "@/components/child/exercise-session"
|
||||
|
||||
export default function FrancescaMate() {
|
||||
return (
|
||||
<ExerciseSession
|
||||
topic="matematicas"
|
||||
profile="FRANCESCA"
|
||||
loadingMessage="Preparando matemáticas..."
|
||||
completeMessage="¡Terminaste las matemáticas por ahora!"
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
"use client"
|
||||
|
||||
import { useEffect, useState } from "react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { GatoMascota } from "@/components/child/gato-mascota"
|
||||
import AudioUnlock from "@/components/child/audio-unlock"
|
||||
|
||||
const FRANCESCA_KEY = "edueasy_child_francesca"
|
||||
|
||||
const activities = [
|
||||
{ id: "matematicas", label: "Matemáticas", icon: "🔢", description: "Sumas, restas y multiplicaciones" },
|
||||
{ id: "lecturas", label: "Lecturas cortas", icon: "📖", description: "Leé textos chiquitos" },
|
||||
{ id: "logros", label: "Mis logros", icon: "⭐", color: "bg-warning" },
|
||||
{ id: "pairing", label: "iPad nuevo", icon: "🔗", color: "bg-secondary" },
|
||||
]
|
||||
|
||||
export default function FrancescaHome() {
|
||||
const router = useRouter()
|
||||
const [audioReady, setAudioReady] = useState(false)
|
||||
const [paired, setPaired] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
setPaired(!!localStorage.getItem(FRANCESCA_KEY))
|
||||
}, [])
|
||||
|
||||
if (!audioReady) {
|
||||
return <AudioUnlock onUnlock={() => setAudioReady(true)} />
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex-1 flex flex-col items-center justify-center p-6 gap-8">
|
||||
<GatoMascota mood="happy" message="¡Hola Francesca! ¿Qué querés practicar hoy?" />
|
||||
|
||||
{!paired ? (
|
||||
<div className="text-center max-w-xs space-y-4">
|
||||
<p className="text-foreground/60">Todavía no estás conectada. Pedile a mamá que te empareje.</p>
|
||||
<button
|
||||
onClick={() => router.push("/child/pairing?profile=francesca")}
|
||||
className="bg-primary text-primary-foreground touch-target-lg rounded-2xl px-8 py-4 text-xl font-display font-bold"
|
||||
>
|
||||
Ir a emparejar
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col gap-4 w-full max-w-md">
|
||||
{activities.map((a) => (
|
||||
<button
|
||||
key={a.id}
|
||||
onClick={() => router.push(`/francesca/${a.id}`)}
|
||||
className={`${a.color || "bg-accent"} text-primary-foreground touch-target-lg rounded-2xl flex items-center gap-4 px-6 py-5 text-xl font-display font-semibold shadow-md active:scale-95 transition-transform`}
|
||||
>
|
||||
<span className="text-2xl">{a.icon}</span>
|
||||
<div className="text-left">
|
||||
<div>{a.label}</div>
|
||||
{a.description && (
|
||||
<div className="text-sm opacity-80">{a.description}</div>
|
||||
)}
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
+31
-3
@@ -3,6 +3,12 @@
|
||||
import { useEffect } from "react"
|
||||
import { useRouter } from "next/navigation"
|
||||
|
||||
const PROFILES = [
|
||||
{ id: "isabella", label: "Isabella", emoji: "👧", color: "bg-pink-500" },
|
||||
{ id: "francesca", label: "Francesca", emoji: "👦", color: "bg-blue-500" },
|
||||
{ id: "sebastian", label: "Sebastián", emoji: "🧒", color: "bg-green-500" },
|
||||
]
|
||||
|
||||
export default function RootPage() {
|
||||
const router = useRouter()
|
||||
|
||||
@@ -10,10 +16,32 @@ export default function RootPage() {
|
||||
const host = window.location.hostname
|
||||
if (host.includes("simulacro")) {
|
||||
router.replace("/parent")
|
||||
} else {
|
||||
router.replace("/child")
|
||||
return
|
||||
}
|
||||
|
||||
const params = new URLSearchParams(window.location.search)
|
||||
const preselected = params.get("profile")
|
||||
if (preselected && PROFILES.find(p => p.id === preselected)) {
|
||||
router.replace(`/child/${preselected}`)
|
||||
}
|
||||
}, [router])
|
||||
|
||||
return null
|
||||
return (
|
||||
<div className="min-h-dvh bg-background flex flex-col items-center justify-center p-6 gap-8">
|
||||
<h1 className="text-4xl font-display font-bold text-center">¿Quién sos?</h1>
|
||||
|
||||
<div className="flex flex-col gap-4 w-full max-w-sm">
|
||||
{PROFILES.map((p) => (
|
||||
<button
|
||||
key={p.id}
|
||||
onClick={() => router.push(`/child/${p.id}`)}
|
||||
className={`${p.color} text-white touch-target-lg rounded-2xl flex items-center gap-4 px-6 py-8 text-2xl font-display font-bold shadow-lg active:scale-95 transition-transform`}
|
||||
>
|
||||
<span className="text-4xl">{p.emoji}</span>
|
||||
<span>{p.label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import ExerciseSession from "@/components/child/exercise-session"
|
||||
|
||||
export default function SebastianBanderas() {
|
||||
return (
|
||||
<ExerciseSession
|
||||
topic="banderas"
|
||||
profile="SEBASTIAN"
|
||||
loadingMessage="Preparando banderas..."
|
||||
completeMessage="¡Terminaste las banderas por hoy!"
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import ExerciseSession from "@/components/child/exercise-session"
|
||||
|
||||
export default function SebastianHistoria() {
|
||||
return (
|
||||
<ExerciseSession
|
||||
topic="historia"
|
||||
profile="SEBASTIAN"
|
||||
loadingMessage="Preparando historia argentina..."
|
||||
completeMessage="¡Terminaste historia por ahora!"
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
"use client"
|
||||
|
||||
import { useEffect, useState } from "react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { GatoMascota } from "@/components/child/gato-mascota"
|
||||
import AudioUnlock from "@/components/child/audio-unlock"
|
||||
|
||||
const SEBASTIAN_KEY = "edueasy_child_sebastian"
|
||||
|
||||
const activities = [
|
||||
{ id: "sumas", label: "Sumas avanzadas", icon: "➕", description: "Sumas de 2 y 3 dígitos" },
|
||||
{ id: "historia", label: "Historia argentina", icon: "🇦🇷", description: "Personajes y eventos" },
|
||||
{ id: "banderas", label: "Banderas", icon: "🚩", description: "Provincias y símbolos" },
|
||||
{ id: "logros", label: "Mis logros", icon: "⭐", color: "bg-warning" },
|
||||
{ id: "pairing", label: "iPad nuevo", icon: "🔗", color: "bg-secondary" },
|
||||
]
|
||||
|
||||
export default function SebastianHome() {
|
||||
const router = useRouter()
|
||||
const [audioReady, setAudioReady] = useState(false)
|
||||
const [paired, setPaired] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
setPaired(!!localStorage.getItem(SEBASTIAN_KEY))
|
||||
}, [])
|
||||
|
||||
if (!audioReady) {
|
||||
return <AudioUnlock onUnlock={() => setAudioReady(true)} />
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex-1 flex flex-col items-center justify-center p-6 gap-8">
|
||||
<GatoMascota mood="happy" message="¡Hola Sebastián! ¿Qué querés explorar hoy?" />
|
||||
|
||||
{!paired ? (
|
||||
<div className="text-center max-w-xs space-y-4">
|
||||
<p className="text-foreground/60">Todavía no estás conectado. Pedile a mamá que te empareje.</p>
|
||||
<button
|
||||
onClick={() => router.push("/child/pairing?profile=sebastian")}
|
||||
className="bg-primary text-primary-foreground touch-target-lg rounded-2xl px-8 py-4 text-xl font-display font-bold"
|
||||
>
|
||||
Ir a emparejar
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col gap-4 w-full max-w-md">
|
||||
{activities.map((a) => (
|
||||
<button
|
||||
key={a.id}
|
||||
onClick={() => router.push(`/sebastian/${a.id}`)}
|
||||
className={`${a.color || "bg-accent"} text-primary-foreground touch-target-lg rounded-2xl flex items-center gap-4 px-6 py-5 text-xl font-display font-semibold shadow-md active:scale-95 transition-transform`}
|
||||
>
|
||||
<span className="text-2xl">{a.icon}</span>
|
||||
<div className="text-left">
|
||||
<div>{a.label}</div>
|
||||
{a.description && (
|
||||
<div className="text-sm opacity-80">{a.description}</div>
|
||||
)}
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import ExerciseSession from "@/components/child/exercise-session"
|
||||
|
||||
export default function SebastianSumas() {
|
||||
return (
|
||||
<ExerciseSession
|
||||
topic="sumas"
|
||||
profile="SEBASTIAN"
|
||||
loadingMessage="Preparando sumas..."
|
||||
completeMessage="¡Terminaste las sumas por ahora!"
|
||||
/>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user