"use client"; import { ChevronRight } from "lucide-react"; import { Badge, GlassPanel } from "@/components/primitives"; import { SectionHeader } from "@/components/shared"; import { formatNumber, formatRelativeTime } from "@/lib/format"; import type { CategoryAction, ModerationTrends } from "@/lib/types"; const SEVERITY_TONE: Record< string, "signal" | "amber" | "vermilion" | "neutral" > = { critical: "vermilion", high: "vermilion", medium: "amber", low: "signal", none: "neutral", }; interface CategoryDrilldownProps { trends: ModerationTrends; selected?: string | null; actions?: CategoryAction[]; loading?: boolean; onSelect: (category: string | null) => void; } export function CategoryDrilldown({ trends, selected, actions, loading, onSelect, }: CategoryDrilldownProps) { const maxCat = trends.categories.reduce((m, c) => Math.max(m, c.count), 0); return ( {selected ? (
/ {selected} ( {loading ? "loading…" : formatNumber(actions?.length ?? 0)} actions)
) : (

Click a category to list the underlying moderation actions.

)} {!selected ? (
{trends.categories.map((c) => { const pct = maxCat > 0 ? Math.max(2, (c.count / maxCat) * 100) : 0; return ( ); })}
) : (
{loading &&

Loading…

} {!loading && actions && actions.length === 0 && (

No actions in this category.

)} {actions?.slice(0, 12).map((a) => (
{a.severity ?? "none"}
{a.action_type} {a.username && ( @{a.username} )} {a.created_at ? formatRelativeTime(a.created_at) : ""}
{a.content && (

{a.content}

)} {a.reason && (

Reason: {a.reason}

)}
))}
)}
); }