- Botón 'Volver' en todas las sesiones de ejercicios (ExerciseSession) - Botón 'Cambiar perfil' en las 3 home pages (Isabella/Francesca/Sebastián) - Páginas inline de Isabella migradas a ExerciseSession (elimina código duplicado) - APIs con try/catch: curriculum/next, dashboard/summary, fsrs/next, children - Validación childId en curriculum/next (404 si no existe) - /api/health endpoint para Docker healthcheck - .env.example, .dockerignore, README.md creados - docker-compose.yml con healthcheck en app service - Test E2E: health endpoint + childId validation - 62/62 tests pasan, TS exit 0
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server"
|
|
import { prisma } from "@/lib/db"
|
|
import { getNextExercise } from "@/lib/curriculum/engine"
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const childId = request.nextUrl.searchParams.get("childId")
|
|
const topic = request.nextUrl.searchParams.get("topic") || "lectura"
|
|
if (!childId) {
|
|
return NextResponse.json({ error: "childId required" }, { status: 400 })
|
|
}
|
|
|
|
const child = await prisma.child.findUnique({
|
|
where: { id: childId },
|
|
select: { profile: true },
|
|
})
|
|
|
|
if (!child) {
|
|
return NextResponse.json({ error: "child not found" }, { status: 404 })
|
|
}
|
|
|
|
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 })
|
|
} catch (error) {
|
|
console.error("[curriculum/next] error:", error)
|
|
return NextResponse.json({ error: "Internal error" }, { status: 500 })
|
|
}
|
|
}
|