File size: 2,533 Bytes
b87cbc7
2b62b0c
b87cbc7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { MaterialIcon } from "@/components/ui/MaterialIcon";
import { Card, CardContent } from "@pram/ui/components/card";
import { formatTime } from "@/lib/time";

interface OverviewCardsProps {
  data: {
    totalAttempts: number;
    completedAttempts: number;
    abandonedAttempts: number;
    avgScorePct: number;
    totalTimeSpentSec: number;
    totalQuestionsAnswered: number;
    totalCorrectAnswers: number;
    overallAccuracyPct: number;
  } | undefined;
}

export function OverviewCards({ data }: OverviewCardsProps) {
  if (!data) return null;

  const cards = [
    {
      label: "Total Latihan",
      value: data.totalAttempts,
      icon: "school",
      color: "text-[var(--matcha-600)]",
      bg: "bg-[var(--matcha-300)]/20",
    },
    {
      label: "Selesai",
      value: data.completedAttempts,
      icon: "check_circle",
      color: "text-[var(--matcha-600)]",
      bg: "bg-[var(--matcha-300)]/20",
    },
    {
      label: "Rata-rata Skor",
      value: `${data.avgScorePct}%`,
      icon: "trending_up",
      color: "text-[var(--lemon-700)]",
      bg: "bg-[var(--lemon-300)]/20",
    },
    {
      label: "Akurasi",
      value: `${data.overallAccuracyPct}%`,
      icon: "target",
      color: "text-[var(--ube-600)]",
      bg: "bg-[var(--ube-300)]/20",
    },
    {
      label: "Waktu Total",
      value: formatTime(data.totalTimeSpentSec),
      icon: "timer",
      color: "text-[var(--slushie-600)]",
      bg: "bg-[var(--slushie-300)]/20",
    },
    {
      label: "Soal Dijawab",
      value: data.totalQuestionsAnswered,
      icon: "quiz",
      color: "text-[var(--pomegranate-600)]",
      bg: "bg-[var(--pomegranate-300)]/20",
    },
  ];

  return (
    <div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4">
      {cards.map((card) => (
        <Card
          key={card.label}
          className="clay-shadow bg-[var(--pure-white)] border-2 border-[var(--oat-border)] rounded-[var(--radius-xl)]"
        >
          <CardContent className="p-4">
            <div className={`inline-flex items-center justify-center w-10 h-10 rounded-[var(--radius-lg)] ${card.bg} mb-3`}>
              <MaterialIcon name={card.icon} className={card.color} />
            </div>
            <div className="text-2xl font-headline font-extrabold text-[var(--clay-black)]">
              {card.value}
            </div>
            <div className="text-xs text-[var(--warm-charcoal)] mt-1">{card.label}</div>
          </CardContent>
        </Card>
      ))}
    </div>
  );
}