import Link from "next/link"; import { redirect } from "next/navigation"; import { BackgroundBlobs } from "@/components/background-blobs"; import { getSessionUser } from "@/lib/auth"; import { listWrong } from "@/lib/wrongbook"; import type { QuizQ } from "@/lib/quiz-parse"; import { WrongRow } from "./wrong-row"; export default async function WrongBookPage() { const user = await getSessionUser(); if (!user) redirect("/join"); if (user.role !== "child") redirect("/parent"); const rows = await listWrong(user.id); const open = rows.filter((r) => !r.mastered).length; return (
← 返回

我的错题本

待掌握 {open} 题
{rows.length === 0 ? (

🎉

还没有错题,继续保持!

) : (
{rows.map((r) => { let q: QuizQ; try { q = JSON.parse(r.question) as QuizQ; } catch { return null; } return ( ); })}
)}
); }