"use client" import Link from "next/link" import { BarChart3 } from "lucide-react" import { ChartCardShell } from "@/shared/components/charts/chart-card-shell" import { TrendLineChart } from "@/shared/components/charts/trend-line-chart" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/shared/components/ui/table" import { formatDate } from "@/shared/lib/utils" import type { StudentDashboardGradeProps } from "@/modules/homework/types" export function StudentGradesCard({ grades }: { grades: StudentDashboardGradeProps }) { const hasGradeTrend = grades.trend.length > 0 const hasRecentGrades = grades.recent.length > 0 const chartData = grades.trend.map((item) => ({ title: item.assignmentTitle, score: Math.round(item.percentage), fullTitle: item.assignmentTitle, submittedAt: formatDate(item.submittedAt), rawScore: item.score, maxScore: item.maxScore, })) const latestGrade = grades.trend[grades.trend.length - 1] return (
{latestGrade ? (
Latest:{" "} {Math.round(latestGrade.percentage)}%
Points:{" "} {latestGrade.score}/{latestGrade.maxScore}
) : null}
{!hasRecentGrades ? null : (
Assignment Score When {grades.recent.map((r) => ( {r.assignmentTitle} {r.score}/{r.maxScore} ({Math.round(r.percentage)}%) {formatDate(r.submittedAt)} ))}
)}
) }