"use client" import Link from "next/link" import { BarChart3 } from "lucide-react" import { useTranslations } from "next-intl" import { Button } from "@/shared/components/ui/button" 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 t = useTranslations("dashboard") 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 ( {t("quickActions.viewAll")} ) : null } >
{latestGrade ? (
{t("chart.latest")}:{" "} {Math.round(latestGrade.percentage)}%
{t("chart.points")}:{" "} {latestGrade.score}/{latestGrade.maxScore}
) : null}
{!hasRecentGrades ? null : (
{t("table.assignment")} {t("table.score")} {t("table.when")} {grades.recent.map((r) => ( {r.assignmentTitle} {r.score}/{r.maxScore} ({Math.round(r.percentage)}%) {formatDate(r.submittedAt)} ))}
)}
) }