"use client"; import { useState } from "react"; import Link from "next/link"; import { cn } from "@/lib/utils"; import { addDays, dowOf, todayStr } from "@/lib/dates"; import { subjectMeta } from "@/lib/subjects"; import { PlayBtn } from "@/components/play-audio"; import { Button } from "@/components/ui/button"; import type { OverviewData } from "./dashboard"; // 学习概览:按孩子的月日历,展示每日 打卡/语法/周检测,点某天看当日具体任务 export function OverviewTab({ data }: { data: OverviewData }) { const [kidId, setKidId] = useState(data.kids[0]?.id); const [selected, setSelected] = useState(todayStr()); const kid = data.kids.find((k) => k.id === kidId) ?? data.kids[0]; if (!kid) return null; const today = todayStr(); const ym = today.slice(0, 7); const first = `${ym}-01`; const daysInMonth = new Date(Number(ym.slice(0, 4)), Number(ym.slice(5, 7)), 0).getDate(); const lead = (dowOf(first) + 6) % 7; // 周一开头的前导空位数 const dates = Array.from({ length: daysInMonth }, (_, i) => `${ym}-${String(i + 1).padStart(2, "0")}`); return (
语法进度
{kid.grammar.done}/{kid.grammar.total}
待掌握错题
{kid.wrongOpen}
最近周测
{kid.weeklyLatest ? `${kid.weeklyLatest.score}分` : "—"}
打卡完成 打卡部分 语法点亮 周检测
{selected} {selected === today ? "(今天)" : ""} 的学习详情
{(() => { const cell = kid.days[selected]; if (!cell) return这一天暂无记录。
; return (打卡任务
{cell.tasks.length === 0 ? (无打卡任务
) : (英语语法检测
{cell.gtests.length === 0 ? (当天未做语法检测
) : ({g.title} · {g.score} 分 {g.passed ? "✅" : "❌"}
))}单词跟读录音
{cell.recs.length === 0 ? (当天无跟读录音
) : (