import Link from "next/link" import { notFound } from "next/navigation" import { BookOpen, Building2, CalendarDays, ChevronLeft, Mail, PenTool, School, User, } from "lucide-react" import { getTranslations } from "next-intl/server" import { getStudentClassById, getStudentSchedule } from "@/modules/classes/data-access" import { getCurrentStudentUser } from "@/modules/users/data-access" import { Badge } from "@/shared/components/ui/badge" import { Button } from "@/shared/components/ui/button" import { Card, CardContent, CardHeader, CardTitle } from "@/shared/components/ui/card" import { EmptyState } from "@/shared/components/ui/empty-state" export const dynamic = "force-dynamic" const WEEKDAY_KEYS: Record = { 1: "mon", 2: "tue", 3: "wed", 4: "thu", 5: "fri", 6: "sat", 7: "sun", } export default async function StudentClassDetailPage({ params, }: { params: Promise<{ classId: string }> }) { const { classId } = await params const student = await getCurrentStudentUser() if (!student) return notFound() const t = await getTranslations("student") const [classInfo, schedule] = await Promise.all([ getStudentClassById(student.id, classId), getStudentSchedule(student.id), ]) if (!classInfo) return notFound() // Filter schedule items for this class const classSchedule = schedule .filter((s) => s.classId === classId) .sort((a, b) => a.weekday - b.weekday || a.startTime.localeCompare(b.startTime)) return (

{classInfo.name}

{t("classDetail.grade", { grade: classInfo.grade })} {classInfo.homeroom && ( <> {classInfo.homeroom} )} {classInfo.room && ( <> {t("classDetail.room", { room: classInfo.room })} )} {t("classDetail.active")}
{/* Teacher Info */} {t("classDetail.teacher")} {classInfo.teacherName ? (
{classInfo.teacherName}
) : (

{t("classDetail.noTeacher")}

)} {classInfo.teacherEmail && ( )}
{/* School Info */} {t("classDetail.school")} {classInfo.schoolName ? (
{classInfo.schoolName}
) : (

{t("classDetail.schoolNotAvailable")}

)} {classInfo.grade && (
{t("classDetail.grade", { grade: classInfo.grade })}
)}
{/* Class Info */} {t("classDetail.classroom")} {classInfo.room ? (
{t("classDetail.room", { room: classInfo.room })}
) : (

{t("classDetail.roomNotAssigned")}

)} {classInfo.homeroom && (
{t("classDetail.homeroom", { homeroom: classInfo.homeroom })}
)}
{/* Schedule */} {t("classDetail.classSchedule")} {classSchedule.length === 0 ? ( ) : (
{classSchedule.map((s) => (
{t(`weekdays.${WEEKDAY_KEYS[s.weekday]}`)}

{s.course}

{s.location && (

{s.location}

)}
{s.startTime} - {s.endTime}
))}
)}
) }