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,5 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import type { JSX } from "react"
|
||||
import { AlertCircle } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
|
||||
@@ -10,7 +11,7 @@ export default function StudentGradesError({
|
||||
}: {
|
||||
error: Error & { digest?: string }
|
||||
reset: () => void
|
||||
}) {
|
||||
}): JSX.Element {
|
||||
const t = useTranslations("student")
|
||||
return (
|
||||
<div className="flex h-full flex-col items-center justify-center space-y-4 p-8">
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import type { JSX } from "react"
|
||||
import { Card, CardContent, CardHeader } from "@/shared/components/ui/card"
|
||||
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||
|
||||
export default function Loading() {
|
||||
export default function Loading(): JSX.Element {
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
<div className="space-y-2">
|
||||
|
||||
@@ -3,11 +3,14 @@ import { requirePermission } from "@/shared/lib/auth-guard"
|
||||
import { Permissions } from "@/shared/types/permissions"
|
||||
import { getStudentGradeSummary } from "@/modules/grades/data-access"
|
||||
import { getRankingTrend, getClassAverageTrend } from "@/modules/grades/data-access-ranking"
|
||||
import { getStudentPositionInClassDistribution, getStudentGrowthArchive } from "@/modules/grades/data-access-analytics"
|
||||
import { getSubjectOptions } from "@/modules/school/data-access"
|
||||
import { StudentGradeSummary } from "@/modules/grades/components/student-grade-summary"
|
||||
import { GradeFilters } from "@/modules/grades/components/grade-filters"
|
||||
import { GradeTrendCard } from "@/modules/grades/components/grade-trend-card"
|
||||
import { RankingTrendCard } from "@/modules/grades/components/ranking-trend-card"
|
||||
import { GradeDistributionChart } from "@/modules/grades/components/grade-distribution-chart"
|
||||
import { GrowthArchiveChart } from "@/modules/grades/components/growth-archive-chart"
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||
import { UserX } from "lucide-react"
|
||||
import { getParam, type SearchParams } from "@/shared/lib/search-params"
|
||||
@@ -21,7 +24,7 @@ export default async function StudentGradesPage({
|
||||
}) {
|
||||
const ctx = await requirePermission(Permissions.GRADE_RECORD_READ)
|
||||
const t = await getTranslations("grades")
|
||||
const [sp, summary, rankingTrend, classAverageTrend, subjectOptions] = await Promise.all([
|
||||
const [sp, summary, rankingTrend, classAverageTrend, subjectOptions, classDistribution, growthArchive] = await Promise.all([
|
||||
searchParams,
|
||||
getStudentGradeSummary(ctx.userId, ctx.dataScope),
|
||||
// v3-P1-3:接入排名趋势图
|
||||
@@ -30,6 +33,10 @@ export default async function StudentGradesPage({
|
||||
getClassAverageTrend(ctx.userId, undefined, undefined, ctx.dataScope),
|
||||
// v3-P2-1:获取科目列表用于过滤器
|
||||
getSubjectOptions(),
|
||||
// P3-9:获取学生所在班级的分布 + 本人位置标注
|
||||
getStudentPositionInClassDistribution(ctx.userId, ctx.dataScope),
|
||||
// P3-4:获取学生纵向成长档案(跨学年/学期聚合)
|
||||
getStudentGrowthArchive(ctx.userId, ctx.dataScope),
|
||||
])
|
||||
|
||||
if (!summary) {
|
||||
@@ -82,6 +89,16 @@ export default async function StudentGradesPage({
|
||||
<RankingTrendCard trend={rankingTrend} />
|
||||
</div>
|
||||
)}
|
||||
{/* P3-9:班级分布 + 学生位置标注(隐私保护视图) */}
|
||||
{classDistribution && (
|
||||
<GradeDistributionChart
|
||||
data={classDistribution.distribution}
|
||||
highlightBucketIndex={classDistribution.studentBucketIndex}
|
||||
studentScore={classDistribution.studentNormalizedScore}
|
||||
/>
|
||||
)}
|
||||
{/* P3-4:学生纵向成长档案(跨学年/学期聚合) */}
|
||||
<GrowthArchiveChart data={growthArchive} />
|
||||
<StudentGradeSummary summary={filteredSummary} />
|
||||
</div>
|
||||
)
|
||||
|
||||
38
src/app/(dashboard)/student/grades/report-card/error.tsx
Normal file
38
src/app/(dashboard)/student/grades/report-card/error.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
"use client"
|
||||
|
||||
import type { JSX } from "react"
|
||||
import { useEffect } from "react"
|
||||
import { AlertTriangle } from "lucide-react"
|
||||
import { Button } from "@/shared/components/ui/button"
|
||||
import { useTranslations } from "next-intl"
|
||||
|
||||
/**
|
||||
* P3-1: 学生报告卡路由错误边界。
|
||||
*/
|
||||
export default function Error({
|
||||
error,
|
||||
reset,
|
||||
}: {
|
||||
error: Error & { digest?: string }
|
||||
reset: () => void
|
||||
}): JSX.Element {
|
||||
const t = useTranslations("grades")
|
||||
useEffect(() => {
|
||||
console.error("[ReportCard] Route error:", error)
|
||||
}, [error])
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col items-center justify-center gap-4 p-12">
|
||||
<AlertTriangle className="h-10 w-10 text-destructive" aria-hidden="true" />
|
||||
<div className="text-center">
|
||||
<h2 className="text-lg font-semibold">{t("reportCard.errorTitle")}</h2>
|
||||
<p className="mt-1 text-sm text-muted-foreground">
|
||||
{t("reportCard.errorDescription")}
|
||||
</p>
|
||||
</div>
|
||||
<Button onClick={reset} variant="outline">
|
||||
{t("reportCard.retry")}
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
15
src/app/(dashboard)/student/grades/report-card/loading.tsx
Normal file
15
src/app/(dashboard)/student/grades/report-card/loading.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Loader2 } from "lucide-react"
|
||||
import { getTranslations } from "next-intl/server"
|
||||
|
||||
/**
|
||||
* P3-1: 学生报告卡路由加载状态。
|
||||
*/
|
||||
export default async function Loading() {
|
||||
const t = await getTranslations("grades")
|
||||
return (
|
||||
<div className="flex h-full flex-col items-center justify-center gap-3 p-12">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-muted-foreground" aria-hidden="true" />
|
||||
<p className="text-sm text-muted-foreground">{t("reportCard.loading")}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
96
src/app/(dashboard)/student/grades/report-card/page.tsx
Normal file
96
src/app/(dashboard)/student/grades/report-card/page.tsx
Normal file
@@ -0,0 +1,96 @@
|
||||
import type { JSX } from "react"
|
||||
import { ArrowLeft } from "lucide-react"
|
||||
import Link from "next/link"
|
||||
import { getTranslations } from "next-intl/server"
|
||||
|
||||
import { Button } from "@/shared/components/ui/button"
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||
import { Permissions } from "@/shared/types/permissions"
|
||||
import { getParam, type SearchParams } from "@/shared/lib/search-params"
|
||||
|
||||
import { getReportCardData } from "@/modules/grades/lib/report-card"
|
||||
import { ReportCardView } from "@/modules/grades/components/report-card-view"
|
||||
import { ReportCardPrintAction } from "@/modules/grades/components/report-card-print-action"
|
||||
import { getAcademicYears } from "@/modules/school/data-access"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
/**
|
||||
* P3-1: 学生视角的成绩报告卡页面。
|
||||
*
|
||||
* 路由:/student/grades/report-card
|
||||
* 查询参数:
|
||||
* - academicYearId?: 指定学年(不传则使用当前活跃学年)
|
||||
* - semester?: "1" | "2"(不传则全部学期)
|
||||
*
|
||||
* 权限:GRADE_RECORD_READ(学生 scope 自动限制为本人)
|
||||
*/
|
||||
export default async function StudentReportCardPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<SearchParams>
|
||||
}): Promise<JSX.Element> {
|
||||
const sp = await searchParams
|
||||
const ctx = await requirePermission(Permissions.GRADE_RECORD_READ)
|
||||
const t = await getTranslations("grades")
|
||||
|
||||
const academicYearIdParam = getParam(sp, "academicYearId")
|
||||
const semesterParam = getParam(sp, "semester")
|
||||
const academicYearId =
|
||||
academicYearIdParam && academicYearIdParam !== "all"
|
||||
? academicYearIdParam
|
||||
: undefined
|
||||
const semester =
|
||||
semesterParam === "1" || semesterParam === "2" ? semesterParam : undefined
|
||||
|
||||
// 学生视角下 studentId 即为 ctx.userId(class_members scope)
|
||||
const [data, academicYears] = await Promise.all([
|
||||
getReportCardData(ctx.userId, ctx.dataScope, {
|
||||
academicYearId,
|
||||
semester,
|
||||
}),
|
||||
getAcademicYears(),
|
||||
])
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<div className="h-full flex-1 flex-col space-y-6 p-8 md:flex">
|
||||
<Button asChild variant="ghost" size="sm" className="w-fit">
|
||||
<Link href="/student/grades">
|
||||
<ArrowLeft className="mr-2 h-4 w-4" aria-hidden="true" />
|
||||
{t("reportCard.backToGrades")}
|
||||
</Link>
|
||||
</Button>
|
||||
<EmptyState
|
||||
title={t("reportCard.emptyTitle")}
|
||||
description={t("reportCard.emptyDescription")}
|
||||
icon={ArrowLeft}
|
||||
className="border-none shadow-none"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4 p-6">
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<Button asChild variant="ghost" size="sm">
|
||||
<Link href="/student/grades">
|
||||
<ArrowLeft className="mr-2 h-4 w-4" aria-hidden="true" />
|
||||
{t("reportCard.backToGrades")}
|
||||
</Link>
|
||||
</Button>
|
||||
<ReportCardPrintAction />
|
||||
</div>
|
||||
|
||||
<ReportCardView data={data} />
|
||||
|
||||
<p className="text-center text-xs text-muted-foreground">
|
||||
{t("reportCard.academicYearsCount", {
|
||||
count: academicYears.length,
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user