import { Siren } from "lucide-react"; import type { ViolatorStat } from "../../api/analytics"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "../ui/card"; import { Badge } from "../ui/badge"; import { ScrollArea } from "../ui/scroll-area"; interface ViolatorTableProps { users: ViolatorStat[]; loading: boolean; } export function ViolatorTable({ users, loading }: ViolatorTableProps) { if (loading && !users?.length) { return ; } if (!users?.length) { return ( Tidak ada pelanggaran terdeteksi. ); } const maxScore = Math.max(...users.map((u) => u.violation_score), 1); function dangerLabel(score: number) { if (score >= 10) return { variant: "destructive" as const, text: "HIGH" }; if (score >= 5) return { variant: "warning" as const, text: "MED" }; return { variant: "secondary" as const, text: "LOW" }; } return (
Pelanggar Terbanyak Skor: flagged × 3 + warned × 1.
{users.length} pelanggar
{users.map((user, i) => { const danger = dangerLabel(user.violation_score); return ( ); })}
# User Warned Flagged Skor
{i + 1}
{user.avatar_url ? ( ) : (
{user.username.charAt(0).toUpperCase()}
)} {user.username} {danger.text}
{user.warned_count} {user.flagged_count}
= 10 ? "bg-gradient-to-r from-red-600 to-red-400" : user.violation_score >= 5 ? "bg-gradient-to-r from-amber-500 to-amber-400" : "bg-gradient-to-r from-yellow-500 to-yellow-400", )} style={{ width: `${(user.violation_score / maxScore) * 100}%` }} />
{user.violation_score}
); } import { cn } from "../../lib/utils"; function LoadingBox() { return ( Memuat data... ); }