feat(dashboard): add moderation log page + message edit history

- Backend moderation module: GET /api/moderation/stats (per-status + failed rate)
  + GET /api/moderation/actions (filter by status/actionType, cursor paging),
  joins messages for target username + content
- Message GET /api/messages/detail/:id now returns edit_count + edit_history
  (old_content snapshots from message_edits, newest first)
- FE: new /moderation page — summary cards (total/executed/failed/pending +
  failed-rate), status+type filter chips, timeline rows with action icon,
  target user, reason, status badge, timestamps, error text
- FE: message detail shows 'Riwayat edit' panel with previous versions
This commit is contained in:
asepharyana
2026-08-05 11:11:10 +07:00
parent a309570d29
commit f999be4fa0
18 changed files with 664 additions and 2 deletions
@@ -1,6 +1,6 @@
"use client";
import { ArrowLeft, MessageSquare, MessagesSquare } from "lucide-react";
import { ArrowLeft, MessageSquare, MessagesSquare, Pencil } from "lucide-react";
import { GlassCard } from "@/components/glass/card";
import { getMessageChannelLabel, renderMessageContent } from "@/lib/format";
import type { AttachmentRecord, MessageRecord } from "@/lib/types";
@@ -52,6 +52,27 @@ export function MessageDetailView({
) || "(no text content)"}
</div>
{/* Edit history */}
{message.edit_history && message.edit_history.length > 0 && (
<div className="mb-4 space-y-2 rounded-lg border border-border/40 bg-card/30 p-3">
<p className="text-[10px] font-semibold uppercase tracking-wide text-text-secondary/50 flex items-center gap-1">
<Pencil className="size-3" />
Riwayat edit · {message.edit_history.length} versi sebelumnya
</p>
{message.edit_history.map((edit, i) => (
<div key={`${edit.edited_at}-${i}`} className="space-y-0.5">
<p className="text-[10px] font-mono text-text-secondary/40">
{new Date(edit.edited_at).toLocaleString("id-ID")}
</p>
<p className="text-xs leading-relaxed text-text-secondary/80 line-clamp-4 whitespace-pre-wrap">
{renderMessageContent(edit.old_content, message.metadata) ||
"(kosong)"}
</p>
</div>
))}
</div>
)}
{/* Attachments */}
{attachments && attachments.length > 0 && (
<div className="mb-4">