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:
@@ -0,0 +1,28 @@
|
||||
"use client"
|
||||
|
||||
import { AlertCircle } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||
|
||||
/**
|
||||
* teacher/homework/submissions/[submissionId]/error.tsx
|
||||
* 批改页错误边界(教师视图)。
|
||||
*/
|
||||
export default function SubmissionGradingError({ reset }: { error: Error & { digest?: string }; reset: () => void }) {
|
||||
const t = useTranslations("examHomework")
|
||||
return (
|
||||
<div className="flex h-full flex-col items-center justify-center space-y-4 p-8">
|
||||
<EmptyState
|
||||
icon={AlertCircle}
|
||||
title={t("homework.error.submissionNotFound")}
|
||||
description={t("homework.error.loadFailed")}
|
||||
action={{
|
||||
label: t("common.retry"),
|
||||
onClick: () => reset(),
|
||||
}}
|
||||
className="border-none shadow-none h-auto"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||
|
||||
/**
|
||||
* teacher/homework/submissions/[submissionId]/loading.tsx
|
||||
* 批改页骨架屏:标题 + 题目卡片骨架 + 右侧汇总卡片骨架。
|
||||
*/
|
||||
export default function Loading() {
|
||||
return (
|
||||
<div className="flex h-full flex-col space-y-4 p-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="space-y-2">
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<Skeleton className="h-4 w-96" />
|
||||
</div>
|
||||
<Skeleton className="h-9 w-32" />
|
||||
</div>
|
||||
<div className="grid h-[calc(100vh-12rem)] grid-cols-1 gap-6 lg:grid-cols-12">
|
||||
<div className="lg:col-span-9 space-y-4">
|
||||
{Array.from({ length: 3 }).map((_, i) => (
|
||||
<Skeleton key={i} className="h-40 w-full" />
|
||||
))}
|
||||
</div>
|
||||
<div className="lg:col-span-3 space-y-4">
|
||||
<Skeleton className="h-32 w-full" />
|
||||
<Skeleton className="h-24 w-full" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -7,46 +7,22 @@ import { HomeworkGradingView } from "@/modules/homework/components/homework-grad
|
||||
import { Button } from "@/shared/components/ui/button"
|
||||
import { ScanLine } from "lucide-react"
|
||||
import { formatDate } from "@/shared/lib/utils"
|
||||
import {
|
||||
AiClientProvider,
|
||||
type AiClientService,
|
||||
} from "@/modules/ai/context/ai-client-provider"
|
||||
import {
|
||||
suggestGradingAction,
|
||||
aiChatAction,
|
||||
suggestSimilarQuestionsAction,
|
||||
generateLessonContentAction,
|
||||
generateQuestionVariantAction,
|
||||
analyzeWeaknessAction,
|
||||
} from "@/modules/ai/actions"
|
||||
import { AiClientProvider } from "@/modules/ai/context/ai-client-provider"
|
||||
import { createCoreAiClientService } from "@/modules/ai/context/create-ai-client-service"
|
||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||
import { Permissions } from "@/shared/types/permissions"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
/**
|
||||
* 构建 AI 客户端服务(Server Action 引用集合)
|
||||
*
|
||||
* 通过 React Context 注入,客户端组件不直接 import actions,
|
||||
* 遵循依赖注入模式,便于测试时替换为 mock。
|
||||
*/
|
||||
function createAiClientService(): AiClientService {
|
||||
return {
|
||||
chat: aiChatAction,
|
||||
suggestSimilarQuestions: suggestSimilarQuestionsAction,
|
||||
suggestGrading: suggestGradingAction,
|
||||
generateLessonContent: generateLessonContentAction,
|
||||
generateQuestionVariant: generateQuestionVariantAction,
|
||||
analyzeWeakness: analyzeWeaknessAction,
|
||||
}
|
||||
}
|
||||
|
||||
export default async function HomeworkSubmissionGradingPage({ params }: { params: Promise<{ submissionId: string }> }): Promise<JSX.Element> {
|
||||
const { submissionId } = await params
|
||||
await requirePermission(Permissions.HOMEWORK_GRADE)
|
||||
const t = await getTranslations("examHomework")
|
||||
const submission = await getHomeworkSubmissionDetails(submissionId)
|
||||
|
||||
if (!submission) return notFound()
|
||||
|
||||
const aiClientService = createAiClientService()
|
||||
const aiClientService = createCoreAiClientService()
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col space-y-4 p-6">
|
||||
@@ -55,12 +31,12 @@ export default async function HomeworkSubmissionGradingPage({ params }: { params
|
||||
<h1 className="text-2xl font-bold tracking-tight line-clamp-2">{submission.assignmentTitle}</h1>
|
||||
<div className="flex items-center gap-4 text-sm text-muted-foreground mt-1">
|
||||
<span>
|
||||
Student: <span className="font-medium text-foreground">{submission.studentName}</span>
|
||||
{t("homework.grade.student")}: <span className="font-medium text-foreground">{submission.studentName}</span>
|
||||
</span>
|
||||
<span aria-hidden="true">•</span>
|
||||
<span className="tabular-nums">Submitted: {submission.submittedAt ? formatDate(submission.submittedAt) : "-"}</span>
|
||||
<span className="tabular-nums">{t("homework.grade.submitted")}: {submission.submittedAt ? formatDate(submission.submittedAt) : "-"}</span>
|
||||
<span aria-hidden="true">•</span>
|
||||
<span className="capitalize">Status: {submission.status}</span>
|
||||
<span className="capitalize">{t("homework.grade.status")}: {submission.status}</span>
|
||||
</div>
|
||||
</div>
|
||||
<Button asChild variant="outline" size="sm">
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
"use client"
|
||||
|
||||
import { AlertCircle } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||
|
||||
/**
|
||||
* teacher/homework/submissions/[submissionId]/scan-grading/error.tsx
|
||||
* 阅卷式批改页错误边界(教师视图)。
|
||||
*/
|
||||
export default function ScanGradingError({ reset }: { error: Error & { digest?: string }; reset: () => void }) {
|
||||
const t = useTranslations("examHomework")
|
||||
return (
|
||||
<div className="flex h-full flex-col items-center justify-center space-y-4 p-8">
|
||||
<EmptyState
|
||||
icon={AlertCircle}
|
||||
title={t("homework.error.submissionNotFound")}
|
||||
description={t("homework.error.loadFailed")}
|
||||
action={{
|
||||
label: t("common.retry"),
|
||||
onClick: () => reset(),
|
||||
}}
|
||||
className="border-none shadow-none h-auto"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||
|
||||
/**
|
||||
* teacher/homework/submissions/[submissionId]/scan-grading/loading.tsx
|
||||
* 阅卷式批改页骨架屏:标题 + 左侧题目 + 右侧扫描图区域骨架。
|
||||
*/
|
||||
export default function Loading() {
|
||||
return (
|
||||
<div className="flex h-full flex-col space-y-4 p-6">
|
||||
<div className="space-y-2">
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<Skeleton className="h-4 w-80" />
|
||||
</div>
|
||||
<div className="grid h-[calc(100vh-12rem)] grid-cols-1 gap-6 lg:grid-cols-2">
|
||||
<div className="space-y-4">
|
||||
{Array.from({ length: 3 }).map((_, i) => (
|
||||
<Skeleton key={i} className="h-40 w-full" />
|
||||
))}
|
||||
</div>
|
||||
<Skeleton className="h-full w-full" />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -3,6 +3,8 @@ import { notFound } from "next/navigation"
|
||||
|
||||
import { getHomeworkSubmissionDetails } from "@/modules/homework/data-access"
|
||||
import { HomeworkScanGradingView } from "@/modules/homework/components/homework-scan-grading-view"
|
||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||
import { Permissions } from "@/shared/types/permissions"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
@@ -12,6 +14,7 @@ export default async function HomeworkScanGradingPage({
|
||||
params: Promise<{ submissionId: string }>
|
||||
}): Promise<JSX.Element> {
|
||||
const { submissionId } = await params
|
||||
await requirePermission(Permissions.HOMEWORK_GRADE)
|
||||
const submission = await getHomeworkSubmissionDetails(submissionId)
|
||||
|
||||
if (!submission) return notFound()
|
||||
|
||||
28
src/app/(dashboard)/teacher/homework/submissions/error.tsx
Normal file
28
src/app/(dashboard)/teacher/homework/submissions/error.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
"use client"
|
||||
|
||||
import { AlertCircle } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||
|
||||
/**
|
||||
* teacher/homework/submissions/error.tsx
|
||||
* 提交列表错误边界(教师视图)。
|
||||
*/
|
||||
export default function SubmissionsListError({ reset }: { error: Error & { digest?: string }; reset: () => void }) {
|
||||
const t = useTranslations("examHomework")
|
||||
return (
|
||||
<div className="flex h-full flex-col items-center justify-center space-y-4 p-8">
|
||||
<EmptyState
|
||||
icon={AlertCircle}
|
||||
title={t("homework.error.notFound")}
|
||||
description={t("homework.error.loadFailed")}
|
||||
action={{
|
||||
label: t("common.retry"),
|
||||
onClick: () => reset(),
|
||||
}}
|
||||
className="border-none shadow-none h-auto"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
24
src/app/(dashboard)/teacher/homework/submissions/loading.tsx
Normal file
24
src/app/(dashboard)/teacher/homework/submissions/loading.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||
|
||||
/**
|
||||
* teacher/homework/submissions/loading.tsx
|
||||
* 提交列表骨架屏(教师视图):标题 + 表格行骨架。
|
||||
*/
|
||||
export default function Loading() {
|
||||
return (
|
||||
<div className="flex h-full flex-col space-y-8 p-8">
|
||||
<div className="space-y-2">
|
||||
<Skeleton className="h-8 w-48" />
|
||||
<Skeleton className="h-4 w-72" />
|
||||
</div>
|
||||
<div className="rounded-md border bg-card">
|
||||
<div className="p-4 space-y-3">
|
||||
<Skeleton className="h-10 w-full" />
|
||||
{Array.from({ length: 8 }).map((_, i) => (
|
||||
<Skeleton key={i} className="h-12 w-full" />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -16,6 +16,9 @@ import { type SearchParams } from "@/shared/lib/search-params"
|
||||
import { getHomeworkAssignmentReviewList } from "@/modules/homework/data-access"
|
||||
import { Inbox } from "lucide-react"
|
||||
import { getTeacherIdForMutations } from "@/modules/classes/data-access"
|
||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||
import { Permissions } from "@/shared/types/permissions"
|
||||
import { getTranslations } from "next-intl/server"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
@@ -23,8 +26,10 @@ const PAGE_SIZE = 10
|
||||
|
||||
export default async function SubmissionsPage({ searchParams }: { searchParams: Promise<SearchParams> }): Promise<JSX.Element> {
|
||||
const sp = await searchParams
|
||||
const ctx = await requirePermission(Permissions.HOMEWORK_GRADE)
|
||||
const t = await getTranslations("examHomework")
|
||||
const creatorId = await getTeacherIdForMutations()
|
||||
const assignments = await getHomeworkAssignmentReviewList({ creatorId })
|
||||
const assignments = await getHomeworkAssignmentReviewList({ creatorId, scope: ctx.dataScope })
|
||||
const hasAssignments = assignments.length > 0
|
||||
|
||||
// 分页计算
|
||||
@@ -38,17 +43,17 @@ export default async function SubmissionsPage({ searchParams }: { searchParams:
|
||||
<div className="h-full flex-1 flex-col space-y-8 p-8 md:flex">
|
||||
<div className="flex items-center justify-between space-y-2">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold tracking-tight">作业提交</h1>
|
||||
<h1 className="text-2xl font-bold tracking-tight">{t("homework.submissions.title")}</h1>
|
||||
<p className="text-muted-foreground">
|
||||
按作业查看提交与批改进度。
|
||||
{t("homework.submissions.description")}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!hasAssignments ? (
|
||||
<EmptyState
|
||||
title="暂无作业"
|
||||
description="还没有可批改的作业。"
|
||||
title={t("homework.list.empty")}
|
||||
description={t("homework.submissions.emptyDescription")}
|
||||
icon={Inbox}
|
||||
/>
|
||||
) : (
|
||||
@@ -56,13 +61,13 @@ export default async function SubmissionsPage({ searchParams }: { searchParams:
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>作业</TableHead>
|
||||
<TableHead>状态</TableHead>
|
||||
<TableHead>截止时间</TableHead>
|
||||
<TableHead className="text-right">应交</TableHead>
|
||||
<TableHead className="text-right">已交</TableHead>
|
||||
<TableHead className="text-right">已批</TableHead>
|
||||
<TableHead className="text-right">提交率</TableHead>
|
||||
<TableHead>{t("homework.submissions.columns.assignment")}</TableHead>
|
||||
<TableHead>{t("homework.list.columns.status")}</TableHead>
|
||||
<TableHead>{t("homework.list.columns.dueAt")}</TableHead>
|
||||
<TableHead className="text-right">{t("homework.grade.targets")}</TableHead>
|
||||
<TableHead className="text-right">{t("homework.grade.submittedCount")}</TableHead>
|
||||
<TableHead className="text-right">{t("homework.grade.gradedCount")}</TableHead>
|
||||
<TableHead className="text-right">{t("homework.list.columns.submissionRate")}</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
@@ -80,7 +85,7 @@ export default async function SubmissionsPage({ searchParams }: { searchParams:
|
||||
{a.sourceExamTitle ? (
|
||||
<div className="text-xs text-muted-foreground truncate max-w-[200px]">{a.sourceExamTitle}</div>
|
||||
) : (
|
||||
<div className="text-xs text-muted-foreground italic">快速作业</div>
|
||||
<div className="text-xs text-muted-foreground italic">{t("homework.submissions.quickAssignment")}</div>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
@@ -107,7 +112,7 @@ export default async function SubmissionsPage({ searchParams }: { searchParams:
|
||||
totalPages={totalPages}
|
||||
basePath="/teacher/homework/submissions"
|
||||
searchParams={sp}
|
||||
itemLabel="个作业"
|
||||
itemLabel={t("homework.list.pagination.itemLabel")}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user