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:
@@ -15,6 +15,7 @@ import { GradeDistributionPanel } from "@/modules/school/components/grade-dashbo
|
||||
import { GradeHomeworkPanel } from "@/modules/school/components/grade-dashboard/grade-homework-panel"
|
||||
import { GradeExamsPanel } from "@/modules/school/components/grade-dashboard/grade-exams-panel"
|
||||
import { GradeProgressPanel } from "@/modules/school/components/grade-dashboard/grade-progress-panel"
|
||||
import { SchoolErrorBoundary } from "@/modules/school/components/school-error-boundary"
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||
import { ChipNav } from "@/shared/components/ui/chip-nav"
|
||||
import { BarChart3 } from "lucide-react"
|
||||
@@ -125,54 +126,56 @@ export default async function GradeDashboardPage({
|
||||
<p className="text-muted-foreground">{t("grades.gradeDashboard.description")}</p>
|
||||
</div>
|
||||
|
||||
<GradeInsightsFilters
|
||||
grades={grades.map((g) => ({ id: g.id, name: g.name, schoolName: g.school.name }))}
|
||||
currentGradeId={selected || "all"}
|
||||
buildHref={buildHref}
|
||||
/>
|
||||
|
||||
{!selected ? (
|
||||
<EmptyState
|
||||
icon={BarChart3}
|
||||
title={t("grades.gradeDashboard.selectToView")}
|
||||
description={t("grades.gradeDashboard.selectToViewDescription")}
|
||||
className="h-[360px] bg-card"
|
||||
<SchoolErrorBoundary>
|
||||
<GradeInsightsFilters
|
||||
grades={grades.map((g) => ({ id: g.id, name: g.name, schoolName: g.school.name }))}
|
||||
currentGradeId={selected || "all"}
|
||||
buildHref={buildHref}
|
||||
/>
|
||||
) : (
|
||||
<div className="space-y-6">
|
||||
<ChipNav
|
||||
options={tabOptions}
|
||||
currentId={tab}
|
||||
buildHref={buildTabHref}
|
||||
|
||||
{!selected ? (
|
||||
<EmptyState
|
||||
icon={BarChart3}
|
||||
title={t("grades.gradeDashboard.selectToView")}
|
||||
description={t("grades.gradeDashboard.selectToViewDescription")}
|
||||
className="h-[360px] bg-card"
|
||||
/>
|
||||
|
||||
{tab === "distribution" && distributionData && (
|
||||
<GradeDistributionPanel data={distributionData} />
|
||||
)}
|
||||
{tab === "homework" && homeworkData && (
|
||||
<GradeHomeworkPanel data={homeworkData} />
|
||||
)}
|
||||
{tab === "exams" && examsData && (
|
||||
<GradeExamsPanel data={examsData} />
|
||||
)}
|
||||
{tab === "progress" && progressData && (
|
||||
<GradeProgressPanel data={progressData} />
|
||||
)}
|
||||
|
||||
{/* Fallback: data was null (e.g. homework insights returned null) */}
|
||||
{((tab === "distribution" && !distributionData) ||
|
||||
(tab === "homework" && !homeworkData) ||
|
||||
(tab === "exams" && !examsData) ||
|
||||
(tab === "progress" && !progressData)) && (
|
||||
<EmptyState
|
||||
icon={BarChart3}
|
||||
title={t("grades.gradeDashboard.noData")}
|
||||
description={t("grades.gradeDashboard.noDataDescription")}
|
||||
className="h-[360px] bg-card"
|
||||
) : (
|
||||
<div className="space-y-6">
|
||||
<ChipNav
|
||||
options={tabOptions}
|
||||
currentId={tab}
|
||||
buildHref={buildTabHref}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{tab === "distribution" && distributionData && (
|
||||
<GradeDistributionPanel data={distributionData} />
|
||||
)}
|
||||
{tab === "homework" && homeworkData && (
|
||||
<GradeHomeworkPanel data={homeworkData} />
|
||||
)}
|
||||
{tab === "exams" && examsData && (
|
||||
<GradeExamsPanel data={examsData} />
|
||||
)}
|
||||
{tab === "progress" && progressData && (
|
||||
<GradeProgressPanel data={progressData} />
|
||||
)}
|
||||
|
||||
{/* Fallback: data was null (e.g. homework insights returned null) */}
|
||||
{((tab === "distribution" && !distributionData) ||
|
||||
(tab === "homework" && !homeworkData) ||
|
||||
(tab === "exams" && !examsData) ||
|
||||
(tab === "progress" && !progressData)) && (
|
||||
<EmptyState
|
||||
icon={BarChart3}
|
||||
title={t("grades.gradeDashboard.noData")}
|
||||
description={t("grades.gradeDashboard.noDataDescription")}
|
||||
className="h-[360px] bg-card"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</SchoolErrorBoundary>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,24 +2,38 @@
|
||||
|
||||
import { useEffect } from "react"
|
||||
import { BarChart3 } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||
|
||||
export default function Error() {
|
||||
export default function GradePracticeError({
|
||||
error,
|
||||
reset,
|
||||
}: {
|
||||
error: Error & { digest?: string }
|
||||
reset: () => void
|
||||
}): React.ReactNode {
|
||||
const t = useTranslations("practice")
|
||||
useEffect(() => {
|
||||
console.error("Grade practice analytics page error")
|
||||
}, [])
|
||||
console.error("Grade practice analytics page error:", error)
|
||||
}, [error])
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col space-y-8 p-8">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold tracking-tight">年级专项练习总览</h1>
|
||||
<p className="text-muted-foreground">加载年级练习数据时发生错误</p>
|
||||
<h1 className="text-2xl font-bold tracking-tight">
|
||||
{t("errors.pageErrorTitleGrade")}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">{t("errors.pageErrorGrade")}</p>
|
||||
</div>
|
||||
<EmptyState
|
||||
icon={BarChart3}
|
||||
title="加载失败"
|
||||
description="请刷新页面重试,或联系管理员检查数据访问权限。"
|
||||
title={t("errors.loadFailed")}
|
||||
description={t("errors.loadFailedDescription")}
|
||||
action={{
|
||||
label: t("errors.retry"),
|
||||
onClick: () => reset(),
|
||||
}}
|
||||
className="h-[360px] bg-card"
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user