"use client"; import { AlertTriangle, ArrowLeft, Ban, CheckCircle2, MessageSquare, Shield, User, VolumeX, Zap, } from "lucide-react"; import Link from "next/link"; import { useState } from "react"; import { assignCfhTicket, closeCfhTicket, quickAlert, quickKick, quickMute, updateCfhState, } from "@/actions/moderation"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Textarea } from "@/components/ui/textarea"; import { useServerAction } from "@/hooks/use-server-action"; const CFH_STATES: Record = { 0: { label: "Open", class: "bg-[var(--admin-error-subtle)] text-[var(--admin-error)]", }, 1: { label: "Picked", class: "bg-[var(--admin-warning-subtle)] text-[var(--admin-warning)]", }, 2: { label: "Closed", class: "bg-muted text-muted-foreground" }, }; interface UserInfo { id: number; username: string; look: string; rank: number; online: string; ipRegister: string; mail: string | null; } interface BanRecord { id: number; reason: string; type: string; staff: string; timestamp: number; } export function CfhDetail({ ticket, sender, reported, moderator, banHistory, canEdit, // biome-ignore lint/correctness/noUnusedFunctionParameters: part of the public component API currentUserId, listHref = "/admin/moderation/cfh", userLinkMode = "admin", }: { ticket: { id: number; state: number; type: number; timestamp: number; issue: string; roomId: number; category: number; score: number; }; sender: UserInfo | null; reported: UserInfo | null; moderator: UserInfo | null; banHistory: { count: number; recent: BanRecord[] }; canEdit: boolean; currentUserId: number; listHref?: string; userLinkMode?: "admin" | "public"; }) { const { run, isPending } = useServerAction(); const [alertMsg, setAlertMsg] = useState(""); const [muteDuration, setMuteDuration] = useState(10); const state = CFH_STATES[ticket.state] ?? CFH_STATES[0]; function userHref(user: UserInfo) { if (userLinkMode === "public") { return `/u/${encodeURIComponent(user.username)}`; } return `/admin/users/show/${user.id}`; } return (
{/* Header */}
CFH #{ticket.id} {state.label} Type {ticket.type} · Category {ticket.category}

Call For Help Report

{new Date(ticket.timestamp * 1000).toLocaleString()} · Room # {ticket.roomId}

{/* Main content */}
{/* Issue */} Report Message

{ticket.issue || "No description provided."}

{/* Users involved */}
{/* Sender */} Reporter {sender ? (

{sender.username}

Rank {sender.rank} ·{" "} {sender.online === "1" ? "Online" : "Offline"}

) : (

Unknown user

)}
{/* Reported */} Reported User {reported ? (

{reported.username}

Rank {reported.rank} ·{" "} {reported.online === "1" ? "Online" : "Offline"} ·{" "} {banHistory.count} bans

{/* Quick actions on reported user */} {canEdit && (
setMuteDuration(Number(e.target.value)) } className="h-7 text-xs" placeholder="Mute duration (min)" />