Files
NextEdu/src/app/(dashboard)/student/elective/page.tsx
SpecialX 30f4983d49 feat(student): 完成 student 模块 v4 剩余修复
- P1-4.2: 新增班级详情页 courses/[classId],展示教师/学校/教室信息与课表

- P2-2.5: 今日课表卡片高亮当前/下一节课(useMemo 实时计算)

- P2-3.9: 作业作答进度网格支持点击跳转题目(scrollIntoView)

- P2-3.10: 作业复习视图显示正确答案(选择/判断/文本题)

- P2-4.4: 课程列表支持按班级名/教师/学校搜索

- P2-5.2: 成绩页新增趋势折线图组件 GradeTrendCard

- P2-9.2/9.3: 诊断报告新增历史记录卡片与弱点练习入口

- P2-10.2: 选课列表支持搜索与选课模式筛选

- P2-11.3: 修复教材阅读页全屏溢出

- P3-1.5: 面包屑保留首个角色段作为根上下文

- P3-7.3: 课表项支持点击跳转至班级详情页(ScheduleList href)
2026-06-22 14:08:34 +08:00

55 lines
1.7 KiB
TypeScript

import { getAuthContext } from "@/shared/lib/auth-guard"
import { getAvailableCoursesForStudent, getStudentSelections } from "@/modules/elective/data-access-selections"
import { StudentSelectionView } from "@/modules/elective/components/student-selection-view"
import { ElectiveFilters } from "@/modules/elective/components/elective-filters"
export const dynamic = "force-dynamic"
type SearchParams = { [key: string]: string | string[] | undefined }
const getParam = (params: SearchParams, key: string) => {
const v = params[key]
return Array.isArray(v) ? v[0] : v
}
export default async function StudentElectivePage({
searchParams,
}: {
searchParams: Promise<SearchParams>
}) {
const ctx = await getAuthContext()
const studentId = ctx.userId
const [sp, availableCourses, mySelections] = await Promise.all([
searchParams,
getAvailableCoursesForStudent(studentId),
getStudentSelections(studentId),
])
const q = (getParam(sp, "q") || "").toLowerCase().trim()
const modeFilter = getParam(sp, "mode") || "all"
const filteredCourses = availableCourses.filter((c) => {
if (q && !c.name.toLowerCase().includes(q) && !(c.teacherName?.toLowerCase().includes(q) ?? false)) return false
if (modeFilter !== "all" && c.selectionMode !== modeFilter) return false
return true
})
return (
<div className="space-y-8">
<div>
<h2 className="text-2xl font-bold tracking-tight">Elective Courses</h2>
<p className="text-muted-foreground">
Browse available electives and manage your selections.
</p>
</div>
{availableCourses.length > 0 && <ElectiveFilters />}
<StudentSelectionView
availableCourses={filteredCourses}
mySelections={mySelections}
/>
</div>
)
}