import { useParams, Link } from "react-router-dom"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Progress } from "@/components/ui/progress"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Button } from "@/components/ui/button"; import { useCourse, useChapters, useGrades, useCourseCompletion } from "@/hooks/queries"; import { ArrowLeft, BookOpen, Lock, ChevronRight, Play, CheckCircle2, Trophy } from "lucide-react"; export default function StudentCourseDetail() { const { id } = useParams(); const courseId = Number(id); const { data: course, isLoading: lc } = useCourse(courseId); const { data: chapters = [], isLoading: lch } = useChapters(courseId); const { data: gradesData, isLoading: lg } = useGrades({ course_id: courseId }); const { data: completion } = useCourseCompletion(courseId); const gradeRecords = gradesData ?? []; if (lc || lch || lg) return
{course.code} · {chapters.length} chapters
Course Completed!
You've finished all {chapters.length} chapters.
{completedChapters} of {chapters.length} chapters completed
No chapters available yet.
{ch.name}
{!ch.is_unlocked &&{ch.material_count} materials {ch.description ? ` · ${ch.description.slice(0, 60)}${ch.description.length > 60 ? "..." : ""}` : ""}
No grades yet for this course.
) : gradeRecords.map(g => ({g.assignment_title}
{g.date}
{course.description || "No description available."}