import type { JSX } from "react" import { getAuthContext } from "@/shared/lib/auth-guard" import { getParam, type SearchParams } from "@/shared/lib/search-params" import { getDiagnosticReports } from "@/modules/diagnostic/data-access-reports" import { ReportList } from "@/modules/diagnostic/components/report-list" import type { DiagnosticReportType, DiagnosticReportStatus } from "@/modules/diagnostic/types" export const dynamic = "force-dynamic" const VALID_REPORT_TYPES: ReadonlySet = new Set([ "individual", "class", "grade", ]) const VALID_REPORT_STATUSES: ReadonlySet = new Set([ "draft", "published", "archived", ]) function parseReportType(v?: string): DiagnosticReportType | undefined { return v && VALID_REPORT_TYPES.has(v) ? (v as DiagnosticReportType) : undefined } function parseReportStatus(v?: string): DiagnosticReportStatus | undefined { return v && VALID_REPORT_STATUSES.has(v) ? (v as DiagnosticReportStatus) : undefined } export default async function TeacherDiagnosticPage({ searchParams, }: { searchParams: Promise }): Promise { const sp = await searchParams const ctx = await getAuthContext() const reportType = getParam(sp, "reportType") const status = getParam(sp, "status") const reports = await getDiagnosticReports({ reportType: reportType && reportType !== "all" ? parseReportType(reportType) : undefined, status: status && status !== "all" ? parseReportStatus(status) : undefined, }) // 学生角色仅查看自己的报告;其他角色查看全部 const visibleReports = ctx.dataScope.type === "class_members" ? reports.filter((r) => r.studentId === ctx.userId) : reports return (

Learning Diagnostic

View and manage diagnostic reports based on knowledge point mastery.

) }