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:
27
src/app/(dashboard)/teacher/elective/[id]/edit/loading.tsx
Normal file
27
src/app/(dashboard)/teacher/elective/[id]/edit/loading.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Card, CardContent, CardHeader } from "@/shared/components/ui/card"
|
||||
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||
|
||||
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-64" />
|
||||
</div>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<Skeleton className="h-5 w-32" />
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{Array.from({ length: 6 }).map((_, i) => (
|
||||
<div key={i} className="space-y-2">
|
||||
<Skeleton className="h-4 w-24" />
|
||||
<Skeleton className="h-9 w-full" />
|
||||
</div>
|
||||
))}
|
||||
<Skeleton className="h-10 w-32" />
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
52
src/app/(dashboard)/teacher/elective/[id]/edit/page.tsx
Normal file
52
src/app/(dashboard)/teacher/elective/[id]/edit/page.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import { notFound } from "next/navigation"
|
||||
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 { getElectiveCourseById } from "@/modules/elective/data-access"
|
||||
import { getGrades, getStaffOptions, getSubjectOptions } from "@/modules/school/data-access"
|
||||
import { ElectiveCourseForm } from "@/modules/elective/components/elective-course-form"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
export default async function TeacherEditElectiveCoursePage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ id: string }>
|
||||
}): Promise<JSX.Element> {
|
||||
const t = await getTranslations("elective")
|
||||
const ctx = await requirePermission(Permissions.ELECTIVE_MANAGE)
|
||||
const { id } = await params
|
||||
|
||||
const [course, subjects, grades, teachers] = await Promise.all([
|
||||
getElectiveCourseById(id),
|
||||
getSubjectOptions(),
|
||||
getGrades(),
|
||||
getStaffOptions(),
|
||||
])
|
||||
|
||||
if (!course) notFound()
|
||||
|
||||
// 教师只能编辑自己教授的课程(防止跨教师越权编辑)
|
||||
if (course.teacherId && course.teacherId !== ctx.userId) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col space-y-8 p-8">
|
||||
<div>
|
||||
<h2 className="text-2xl font-bold tracking-tight">{t("title.edit")}</h2>
|
||||
<p className="text-muted-foreground">{t("description.edit")}</p>
|
||||
</div>
|
||||
<ElectiveCourseForm
|
||||
mode="edit"
|
||||
course={course}
|
||||
subjects={subjects}
|
||||
grades={grades.map((g) => ({ id: g.id, name: g.name }))}
|
||||
teachers={teachers.map((teacher) => ({ id: teacher.id, name: teacher.name }))}
|
||||
backHref="/teacher/elective"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
27
src/app/(dashboard)/teacher/elective/create/loading.tsx
Normal file
27
src/app/(dashboard)/teacher/elective/create/loading.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Card, CardContent, CardHeader } from "@/shared/components/ui/card"
|
||||
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||
|
||||
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-64" />
|
||||
</div>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<Skeleton className="h-5 w-32" />
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{Array.from({ length: 6 }).map((_, i) => (
|
||||
<div key={i} className="space-y-2">
|
||||
<Skeleton className="h-4 w-24" />
|
||||
<Skeleton className="h-9 w-full" />
|
||||
</div>
|
||||
))}
|
||||
<Skeleton className="h-10 w-32" />
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
36
src/app/(dashboard)/teacher/elective/create/page.tsx
Normal file
36
src/app/(dashboard)/teacher/elective/create/page.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
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 { getGrades, getStaffOptions, getSubjectOptions } from "@/modules/school/data-access"
|
||||
import { ElectiveCourseForm } from "@/modules/elective/components/elective-course-form"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
export default async function TeacherCreateElectiveCoursePage(): Promise<JSX.Element> {
|
||||
const t = await getTranslations("elective")
|
||||
await requirePermission(Permissions.ELECTIVE_MANAGE)
|
||||
|
||||
const [subjects, grades, teachers] = await Promise.all([
|
||||
getSubjectOptions(),
|
||||
getGrades(),
|
||||
getStaffOptions(),
|
||||
])
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col space-y-8 p-8">
|
||||
<div>
|
||||
<h2 className="text-2xl font-bold tracking-tight">{t("title.create")}</h2>
|
||||
<p className="text-muted-foreground">{t("description.create")}</p>
|
||||
</div>
|
||||
<ElectiveCourseForm
|
||||
mode="create"
|
||||
subjects={subjects}
|
||||
grades={grades.map((g) => ({ id: g.id, name: g.name }))}
|
||||
teachers={teachers.map((teacher) => ({ id: teacher.id, name: teacher.name }))}
|
||||
backHref="/teacher/elective"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -11,10 +11,10 @@ export default function TeacherElectiveError({ reset }: { error: Error & { diges
|
||||
<div className="flex h-full flex-col items-center justify-center space-y-4 p-8">
|
||||
<EmptyState
|
||||
icon={AlertCircle}
|
||||
title={t("errors.unexpected")}
|
||||
description={t("errors.unexpected")}
|
||||
title={t("errors.title")}
|
||||
description={t("errors.description")}
|
||||
action={{
|
||||
label: t("actions.save"),
|
||||
label: t("actions.retry"),
|
||||
onClick: () => reset(),
|
||||
}}
|
||||
className="border-none shadow-none h-auto"
|
||||
|
||||
@@ -50,8 +50,8 @@ export default async function TeacherElectivePage({
|
||||
<ElectiveCourseList
|
||||
courses={courses}
|
||||
canManage
|
||||
createHref="/admin/elective/create"
|
||||
editBaseHref="/admin/elective"
|
||||
createHref="/teacher/elective/create"
|
||||
editBaseHref="/teacher/elective"
|
||||
/>
|
||||
</ElectivePageLayout>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user