diff --git a/services/frontend/src/app/(dashboard)/dashboard/page.tsx b/services/frontend/src/app/(dashboard)/dashboard/page.tsx index 37a2196..91224ea 100644 --- a/services/frontend/src/app/(dashboard)/dashboard/page.tsx +++ b/services/frontend/src/app/(dashboard)/dashboard/page.tsx @@ -10,38 +10,21 @@ import { } from "lucide-react"; import { useState } from "react"; import { ChannelsSection } from "@/components/dashboard/channels-section"; -import { LiveStream } from "@/components/dashboard/live-stream"; -import type { ModQueueItem } from "@/components/dashboard/mod-queue"; -import { ModQueue } from "@/components/dashboard/mod-queue"; import { StatCard } from "@/components/dashboard/stat-card"; import { TopChannelsChart } from "@/components/dashboard/top-channels-chart"; import { UsersSection } from "@/components/dashboard/users-section"; import { SubNav } from "@/components/layout/sub-nav"; import { ErrorState, LoadingSkeleton } from "@/components/shared"; -import { useReview, useStats } from "@/hooks"; +import { useStats } from "@/hooks"; -type DashboardTab = "stats" | "live" | "users" | "channels"; +type DashboardTab = "stats" | "users" | "channels"; export default function DashboardPage() { const [tab, setTab] = useState("stats"); const { data: stats, isLoading, error, mutate: refetch } = useStats(); - const { data: review = [] } = useReview(); - - const modQueueItems: ModQueueItem[] = review.slice(0, 10).map((msg) => ({ - id: msg.id, - content: msg.content || msg.id, - username: msg.username, - metadata: msg.metadata ?? null, - severity: - msg.ai_severity && msg.ai_severity !== "none" - ? (msg.ai_severity as ModQueueItem["severity"]) - : "medium", - reason: msg.ai_analysis ?? "AI moderation flag", - })); const subNavTabs = [ { id: "stats", label: "Stats", icon: }, - { id: "live", label: "Live", icon: }, { id: "users", label: "Users", icon: }, { id: "channels", label: "Channels", icon: }, ]; @@ -108,13 +91,6 @@ export default function DashboardPage() { )} - {tab === "live" && ( -
- - -
- )} - {tab === "users" && } {tab === "channels" && } diff --git a/services/frontend/src/components/dashboard/live-stream.tsx b/services/frontend/src/components/dashboard/live-stream.tsx deleted file mode 100644 index 33df372..0000000 --- a/services/frontend/src/components/dashboard/live-stream.tsx +++ /dev/null @@ -1,97 +0,0 @@ -"use client"; - -import { useEffect, useRef, useState } from "react"; -import { GlassCard } from "@/components/glass/card"; -import { renderMessageContent } from "@/lib/format"; -import type { MessageRecord } from "@/lib/types"; -import { cn } from "@/lib/utils"; -import { useWebSocket } from "@/lib/ws/context"; - -interface LiveMessage { - id: string; - content: string; - username: string; - channelName?: string; - timestamp: string; - flagged?: boolean; - metadata?: string | null; -} - -export function LiveStream() { - const [messages, setMessages] = useState([]); - const scrollRef = useRef(null); - const ws = useWebSocket(); - - useEffect(() => { - const unsub = ws.on("message_created", (data: MessageRecord) => { - // channel name lives inside the metadata JSON (channel.channelName) - let channelName: string | undefined; - try { - const meta = - typeof data.metadata === "string" - ? JSON.parse(data.metadata) - : data.metadata; - channelName = meta?.channel?.channelName; - } catch { - channelName = undefined; - } - const msg: LiveMessage = { - id: data.id, - content: data.content || "(attachment)", - username: data.username || "unknown", - channelName, - timestamp: new Date().toLocaleTimeString(), - flagged: data.ai_status === "flagged" || data.ai_status === "warn", - metadata: data.metadata ?? null, - }; - setMessages((prev) => [msg, ...prev].slice(0, 50)); - }); - return () => unsub(); - }, [ws]); - - return ( - -
- - - - - - Live Stream - -
-
- {messages.length === 0 ? ( -
- Waiting for messages... -
- ) : ( - messages.map((msg) => ( -
- - {msg.username} - - - {renderMessageContent(msg.content, msg.metadata)} - - - {msg.timestamp} - -
- )) - )} -
-
- ); -} diff --git a/services/frontend/src/components/dashboard/mod-queue.tsx b/services/frontend/src/components/dashboard/mod-queue.tsx deleted file mode 100644 index d4425c1..0000000 --- a/services/frontend/src/components/dashboard/mod-queue.tsx +++ /dev/null @@ -1,86 +0,0 @@ -"use client"; - -import { AlertCircle, Check, Trash2 } from "lucide-react"; -import { GlassCard } from "@/components/glass/card"; -import { renderMessageContent } from "@/lib/format"; -import { cn } from "@/lib/utils"; - -export interface ModQueueItem { - id: string; - content: string; - username: string; - severity: "low" | "medium" | "high" | "critical"; - reason: string; - metadata?: string | null; -} - -export function ModQueue({ items = [] }: { items?: ModQueueItem[] }) { - const severityColor = { - low: "text-accent-amber border-accent-amber/30", - medium: "text-accent-purple border-accent-purple/30", - high: "text-destructive border-destructive/40", - critical: "text-destructive border-destructive/60 bg-destructive/10", - }; - - return ( - -
- - - Mod Queue - - {items.length > 0 && ( - - {items.length} pending - - )} -
-
- {items.length === 0 ? ( -
- No flagged messages -
- ) : ( - items.map((item) => ( -
-
- - {item.username} - - - {item.severity} - -
-

- {renderMessageContent(item.content, item.metadata)} -

-

- {item.reason} -

-
- - -
-
- )) - )} -
-
- ); -}