V2 审计报告(docs/architecture/audit/dashboard-audit-report-v2.md)发现并修复: - P0 i18n:10 个子组件硬编码字符串全部接入 next-intl(teacher-quick-actions / teacher-classes-card / teacher-homework-card / teacher-schedule / recent-submissions / teacher-grade-trends / student-grades-card / student-today-schedule-card / student-upcoming-assignments-card / admin-dashboard),新增 ~50 个翻译键 - P1 共享抽象:新增 DashboardGreetingHeader 组件,消除 teacher/student 头部 90% 重复代码,两个 Header 改为薄包装 - P2 单测:为 6 个纯函数添加 31 个单元测试 (tests/integration/dashboard/dashboard-utils.test.ts) - P2 a11y:admin 表格 caption、teacher/student 视图语义化标签 (header / section aria-label / aside aria-label) - 同步架构图 004/005
73 lines
3.0 KiB
TypeScript
73 lines
3.0 KiB
TypeScript
import Link from "next/link"
|
|
import { Users } from "lucide-react"
|
|
import { getTranslations } from "next-intl/server"
|
|
|
|
import { Button } from "@/shared/components/ui/button"
|
|
import { Card, CardContent, CardHeader, CardTitle } from "@/shared/components/ui/card"
|
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
|
import type { TeacherClass } from "@/modules/classes/types"
|
|
|
|
export async function TeacherClassesCard({ classes }: { classes: TeacherClass[] }) {
|
|
const t = await getTranslations("dashboard")
|
|
|
|
return (
|
|
<Card>
|
|
<CardHeader className="flex flex-row items-center justify-between">
|
|
<CardTitle className="text-base flex items-center gap-2">
|
|
<Users className="h-4 w-4 text-muted-foreground" />
|
|
{t("sections.myClasses")}
|
|
</CardTitle>
|
|
<Button asChild variant="outline" size="sm">
|
|
<Link href="/teacher/classes/my">{t("quickActions.viewAll")}</Link>
|
|
</Button>
|
|
</CardHeader>
|
|
<CardContent className="grid gap-3">
|
|
{classes.length === 0 ? (
|
|
<EmptyState
|
|
icon={Users}
|
|
title={t("empty.noClassesYet")}
|
|
description={t("empty.noClassesDesc")}
|
|
action={{ label: t("quickActions.createClass"), href: "/teacher/classes/my" }}
|
|
className="border-none h-72"
|
|
/>
|
|
) : (
|
|
<div className="space-y-1">
|
|
{classes.slice(0, 6).map((c) => (
|
|
<Link
|
|
key={c.id}
|
|
href={`/teacher/classes/my/${encodeURIComponent(c.id)}`}
|
|
className="group flex items-center justify-between rounded-md border border-transparent px-3 py-2 hover:bg-muted/50 hover:border-border transition-colors"
|
|
>
|
|
<div className="min-w-0 flex-1 mr-3">
|
|
<div className="font-medium truncate group-hover:text-primary transition-colors">{c.name}</div>
|
|
<div className="text-xs text-muted-foreground truncate flex items-center gap-1.5">
|
|
<span className="inline-flex items-center rounded-sm bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground">
|
|
{c.grade}
|
|
</span>
|
|
{c.homeroom && (
|
|
<>
|
|
<span>·</span>
|
|
<span>{t("schedule.homeroom")}: {c.homeroom}</span>
|
|
</>
|
|
)}
|
|
{c.room && (
|
|
<>
|
|
<span>·</span>
|
|
<span>{t("schedule.room")} {c.room}</span>
|
|
</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
<div className="flex items-center text-xs text-muted-foreground tabular-nums">
|
|
<Users className="mr-1.5 h-3 w-3 opacity-70" />
|
|
{c.studentCount}
|
|
</div>
|
|
</Link>
|
|
))}
|
|
</div>
|
|
)}
|
|
</CardContent>
|
|
</Card>
|
|
)
|
|
}
|