feat(app): add error/loading boundaries across all dashboard routes and new routes
- Add error.tsx and loading.tsx boundaries for admin, parent, student, teacher routes - Add admin announcements edit, audit-logs overview, curriculum-map, invitation-codes, permissions, questions, roles routes - Add admin elective detail and components, files, course-plans, users, scheduling boundaries - Add messages group-compose route - Add parent course-plans, elective, grades report-card, practice routes - Add student course-plans, elective detail, error-book dialogs, grades report-card, learning study-path, leave, schedule boundaries - Add teacher attendance report, classes boundaries, course-plans boundaries, elective, exams analytics/edit-rich/all/create/new, grades report-card, homework boundaries, leave, lesson-plans calendar - Add auth loading, onboarding loading, api cron
This commit is contained in:
@@ -1,9 +1,19 @@
|
||||
import type { JSX } from "react"
|
||||
import { getTranslations } from "next-intl/server"
|
||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||
import { Permissions } from "@/shared/types/permissions"
|
||||
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 {
|
||||
DiagnosticServiceProvider,
|
||||
} from "@/modules/diagnostic/services/diagnostic-service-context"
|
||||
import { defaultDiagnosticService } from "@/modules/diagnostic/services/default-diagnostic-service"
|
||||
import { createMonitoredDiagnosticService } from "@/modules/diagnostic/services/monitored-diagnostic-service"
|
||||
import {
|
||||
DiagnosticMonitorProvider,
|
||||
} from "@/modules/diagnostic/services/diagnostic-monitor-context"
|
||||
import { noopDiagnosticMonitor } from "@/modules/diagnostic/services/diagnostic-monitor"
|
||||
import type { DiagnosticReportType, DiagnosticReportStatus } from "@/modules/diagnostic/types"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
@@ -20,12 +30,12 @@ const VALID_REPORT_STATUSES: ReadonlySet<string> = new Set([
|
||||
"archived",
|
||||
])
|
||||
|
||||
function parseReportType(v?: string): DiagnosticReportType | undefined {
|
||||
return v && VALID_REPORT_TYPES.has(v) ? (v as DiagnosticReportType) : undefined
|
||||
function isReportType(v: string): v is DiagnosticReportType {
|
||||
return VALID_REPORT_TYPES.has(v)
|
||||
}
|
||||
|
||||
function parseReportStatus(v?: string): DiagnosticReportStatus | undefined {
|
||||
return v && VALID_REPORT_STATUSES.has(v) ? (v as DiagnosticReportStatus) : undefined
|
||||
function isReportStatus(v: string): v is DiagnosticReportStatus {
|
||||
return VALID_REPORT_STATUSES.has(v)
|
||||
}
|
||||
|
||||
export default async function TeacherDiagnosticPage({
|
||||
@@ -35,33 +45,44 @@ export default async function TeacherDiagnosticPage({
|
||||
}): Promise<JSX.Element> {
|
||||
const sp = await searchParams
|
||||
const ctx = await requirePermission(Permissions.DIAGNOSTIC_READ)
|
||||
const t = await getTranslations("diagnostic")
|
||||
|
||||
const reportType = getParam(sp, "reportType")
|
||||
const status = getParam(sp, "status")
|
||||
const reportTypeParam = getParam(sp, "reportType")
|
||||
const statusParam = getParam(sp, "status")
|
||||
|
||||
const reports = await getDiagnosticReports(
|
||||
{
|
||||
reportType: reportType && reportType !== "all" ? parseReportType(reportType) : undefined,
|
||||
status: status && status !== "all" ? parseReportStatus(status) : undefined,
|
||||
},
|
||||
ctx.dataScope,
|
||||
const reportType =
|
||||
reportTypeParam && reportTypeParam !== "all" && isReportType(reportTypeParam)
|
||||
? reportTypeParam
|
||||
: undefined
|
||||
const status =
|
||||
statusParam && statusParam !== "all" && isReportStatus(statusParam)
|
||||
? statusParam
|
||||
: undefined
|
||||
|
||||
const reports = await getDiagnosticReports({ reportType, status }, ctx.dataScope)
|
||||
|
||||
// v2-P2-2: 移除客户端 filter,DataScope 过滤已在 data-access 层完成
|
||||
// class_members scope 的学生已通过 filters.studentId 在 data-access 层过滤
|
||||
|
||||
// v2-P2-7: 包装默认服务以添加监控埋点(默认 no-op,生产环境可注入真实实现)
|
||||
const monitoredService = createMonitoredDiagnosticService(
|
||||
defaultDiagnosticService,
|
||||
noopDiagnosticMonitor,
|
||||
)
|
||||
|
||||
// 学生角色仅查看自己的报告;其他角色查看全部
|
||||
const visibleReports =
|
||||
ctx.dataScope.type === "class_members"
|
||||
? reports.reports.filter((r) => r.studentId === ctx.userId)
|
||||
: reports.reports
|
||||
|
||||
return (
|
||||
<div className="h-full flex-1 flex-col space-y-8 p-8 md:flex">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold tracking-tight">Learning Diagnostic</h1>
|
||||
<h1 className="text-2xl font-bold tracking-tight">{t("title.teacherReportList")}</h1>
|
||||
<p className="text-muted-foreground">
|
||||
View and manage diagnostic reports based on knowledge point mastery.
|
||||
{t("title.teacherReportListDesc")}
|
||||
</p>
|
||||
</div>
|
||||
<ReportList reports={visibleReports} />
|
||||
<DiagnosticMonitorProvider monitor={noopDiagnosticMonitor}>
|
||||
<DiagnosticServiceProvider service={monitoredService}>
|
||||
<ReportList reports={reports.reports} />
|
||||
</DiagnosticServiceProvider>
|
||||
</DiagnosticMonitorProvider>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user