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:
20
src/app/(dashboard)/admin/course-plans/[id]/edit/error.tsx
Normal file
20
src/app/(dashboard)/admin/course-plans/[id]/edit/error.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
"use client"
|
||||
|
||||
import { useTranslations } from "next-intl"
|
||||
import { ClipboardList } from "lucide-react"
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||
|
||||
export default function EditCoursePlanError() {
|
||||
const t = useTranslations("coursePlans")
|
||||
return (
|
||||
<div className="p-8">
|
||||
<EmptyState
|
||||
icon={ClipboardList}
|
||||
title={t("errors.loadFailed")}
|
||||
description={t("errors.loadFailedDesc")}
|
||||
action={{ label: t("errors.retry"), onClick: () => window.location.reload() }}
|
||||
className="border-none shadow-none"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
28
src/app/(dashboard)/admin/course-plans/[id]/edit/loading.tsx
Normal file
28
src/app/(dashboard)/admin/course-plans/[id]/edit/loading.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||
|
||||
export default function EditCoursePlanLoading() {
|
||||
return (
|
||||
<div className="flex h-full flex-col space-y-8 p-8">
|
||||
<div className="space-y-2">
|
||||
<Skeleton className="h-8 w-[180px]" />
|
||||
<Skeleton className="h-4 w-[260px]" />
|
||||
</div>
|
||||
<div className="space-y-6">
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
{Array.from({ length: 6 }).map((_, i) => (
|
||||
<div key={i} className="space-y-2">
|
||||
<Skeleton className="h-4 w-[100px]" />
|
||||
<Skeleton className="h-10 w-full" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<Skeleton className="h-24 w-full" />
|
||||
<Skeleton className="h-24 w-full" />
|
||||
<div className="flex justify-end gap-2">
|
||||
<Skeleton className="h-10 w-[80px]" />
|
||||
<Skeleton className="h-10 w-[120px]" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -3,9 +3,11 @@ import type { Metadata } from "next"
|
||||
import type { JSX } from "react"
|
||||
import { getTranslations } from "next-intl/server"
|
||||
|
||||
import { getCoursePlanById, getSubjectOptions } from "@/modules/course-plans/data-access"
|
||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||
import { Permissions } from "@/shared/types/permissions"
|
||||
import { getCoursePlanById } from "@/modules/course-plans/data-access"
|
||||
import { getAdminClasses } from "@/modules/classes/data-access"
|
||||
import { getAcademicYears, getStaffOptions } from "@/modules/school/data-access"
|
||||
import { getAcademicYears, getStaffOptions, getSubjectOptions } from "@/modules/school/data-access"
|
||||
import { CoursePlanForm } from "@/modules/course-plans/components/course-plan-form"
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
@@ -24,10 +26,13 @@ export default async function EditCoursePlanPage({
|
||||
params: Promise<{ id: string }>
|
||||
}): Promise<JSX.Element> {
|
||||
const t = await getTranslations("coursePlans")
|
||||
// P0-2:admin 页面补充 requirePermission 校验
|
||||
const ctx = await requirePermission(Permissions.COURSE_PLAN_MANAGE)
|
||||
const { id } = await params
|
||||
|
||||
const [plan, classes, subjects, teachers, academicYears] = await Promise.all([
|
||||
getCoursePlanById(id),
|
||||
// P0-1:携带 scope 过滤
|
||||
getCoursePlanById(id, { userId: ctx.userId, isAdmin: true }),
|
||||
getAdminClasses(),
|
||||
getSubjectOptions(),
|
||||
getStaffOptions(),
|
||||
@@ -47,9 +52,10 @@ export default async function EditCoursePlanPage({
|
||||
plan={plan}
|
||||
classes={classes.map((c) => ({ id: c.id, name: c.name }))}
|
||||
subjects={subjects}
|
||||
teachers={teachers.map((t) => ({ id: t.id, name: t.name }))}
|
||||
teachers={teachers.map((tch) => ({ id: tch.id, name: tch.name }))}
|
||||
academicYears={academicYears.map((y) => ({ id: y.id, name: y.name }))}
|
||||
backHref={`/admin/course-plans/${plan.id}`}
|
||||
successHref={`/admin/course-plans/${plan.id}`}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
20
src/app/(dashboard)/admin/course-plans/[id]/error.tsx
Normal file
20
src/app/(dashboard)/admin/course-plans/[id]/error.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
"use client"
|
||||
|
||||
import { useTranslations } from "next-intl"
|
||||
import { ClipboardList } from "lucide-react"
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||
|
||||
export default function AdminCoursePlanDetailError() {
|
||||
const t = useTranslations("coursePlans")
|
||||
return (
|
||||
<div className="p-8">
|
||||
<EmptyState
|
||||
icon={ClipboardList}
|
||||
title={t("errors.loadFailed")}
|
||||
description={t("errors.loadFailedDesc")}
|
||||
action={{ label: t("errors.retry"), onClick: () => window.location.reload() }}
|
||||
className="border-none shadow-none"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
27
src/app/(dashboard)/admin/course-plans/[id]/loading.tsx
Normal file
27
src/app/(dashboard)/admin/course-plans/[id]/loading.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||
|
||||
export default function AdminCoursePlanDetailLoading() {
|
||||
return (
|
||||
<div className="flex h-full flex-col space-y-6 p-8">
|
||||
<div className="flex items-center justify-between">
|
||||
<Skeleton className="h-8 w-[240px]" />
|
||||
<div className="flex gap-2">
|
||||
<Skeleton className="h-9 w-[80px]" />
|
||||
<Skeleton className="h-9 w-[80px]" />
|
||||
</div>
|
||||
</div>
|
||||
<Skeleton className="h-4 w-full max-w-md" />
|
||||
<div className="grid gap-4 md:grid-cols-3">
|
||||
{Array.from({ length: 3 }).map((_, i) => (
|
||||
<Skeleton key={i} className="h-[100px] w-full" />
|
||||
))}
|
||||
</div>
|
||||
<div className="space-y-3">
|
||||
<Skeleton className="h-10 w-full" />
|
||||
{Array.from({ length: 4 }).map((_, i) => (
|
||||
<Skeleton key={i} className="h-12 w-full" />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -3,6 +3,8 @@ import type { Metadata } from "next"
|
||||
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 { getCoursePlanById } from "@/modules/course-plans/data-access"
|
||||
import { CoursePlanDetail } from "@/modules/course-plans/components/course-plan-detail"
|
||||
|
||||
@@ -21,8 +23,11 @@ export default async function CoursePlanDetailPage({
|
||||
}: {
|
||||
params: Promise<{ id: string }>
|
||||
}): Promise<JSX.Element> {
|
||||
// P0-2:admin 页面补充 requirePermission 校验
|
||||
const ctx = await requirePermission(Permissions.COURSE_PLAN_READ)
|
||||
const { id } = await params
|
||||
const plan = await getCoursePlanById(id)
|
||||
// P0-1/P0-3:携带 scope 过滤,admin 视角为全局
|
||||
const plan = await getCoursePlanById(id, { userId: ctx.userId, isAdmin: true })
|
||||
|
||||
if (!plan) notFound()
|
||||
|
||||
@@ -32,6 +37,7 @@ export default async function CoursePlanDetailPage({
|
||||
plan={plan}
|
||||
editHref={`/admin/course-plans/${plan.id}/edit`}
|
||||
backHref="/admin/course-plans"
|
||||
successHref="/admin/course-plans"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user