Files
NextEdu/src/app/(dashboard)/teacher/course-plans/page.tsx
SpecialX 1a9377222c feat(app): add error/loading boundaries and update dashboard routes
- Add error.tsx and loading.tsx boundaries for admin, parent, student, teacher routes

- Add dashboard-error-fallback and dashboard-loading-skeleton components

- Add student/learning page, parent/leave routes, teacher textbook components

- Update existing app routes across auth, dashboard, and API endpoints

- Update proxy middleware and next-auth type declarations
2026-06-23 17:38:28 +08:00

54 lines
1.6 KiB
TypeScript

import type { JSX } from "react"
import { requirePermission } from "@/shared/lib/auth-guard"
import { Permissions } from "@/shared/types/permissions"
import { getParam, type SearchParams } from "@/shared/lib/search-params"
import { getCoursePlans } from "@/modules/course-plans/data-access"
import { CoursePlanList } from "@/modules/course-plans/components/course-plan-list"
import type { CoursePlanStatus } from "@/modules/course-plans/types"
export const dynamic = "force-dynamic"
const VALID_STATUSES: ReadonlySet<string> = new Set([
"planning",
"active",
"completed",
"paused",
])
function parseStatus(v?: string): CoursePlanStatus | undefined {
return v && VALID_STATUSES.has(v) ? (v as CoursePlanStatus) : undefined
}
export default async function TeacherCoursePlansPage({
searchParams,
}: {
searchParams: Promise<SearchParams>
}): Promise<JSX.Element> {
const ctx = await requirePermission(Permissions.COURSE_PLAN_READ)
const teacherId = ctx.userId
const sp = await searchParams
const statusParam = getParam(sp, "status")
const status = parseStatus(statusParam)
const plans = teacherId
? await getCoursePlans({ teacherId, status })
: []
return (
<div className="flex h-full flex-col space-y-8 p-8">
<div className="space-y-1">
<h1 className="text-2xl font-bold tracking-tight">My Course Plans</h1>
<p className="text-muted-foreground">
View your course teaching plans and weekly schedules.
</p>
</div>
<CoursePlanList
plans={plans}
detailBaseHref="/teacher/course-plans"
initialStatus={status}
/>
</div>
)
}