"use client"; import { useState } from "react"; import { Flag, Ban } from "lucide-react"; import { socialApi } from "@social/lib/api"; import { socialTx } from "@social/lib/socialTx"; const REASONS = [ "骚扰 / 不当言论", "虚假资料", "垃圾广告", "人身安全顾虑", "其他", ]; export default function ReportBlockPanel({ targetGuest, targetName, }: { targetGuest: string; targetName: string; }) { const [open, setOpen] = useState<"report" | "block" | null>(null); const [reason, setReason] = useState(REASONS[0]); const [detail, setDetail] = useState(""); const [busy, setBusy] = useState(false); const [msg, setMsg] = useState(""); const submitReport = async () => { if (busy) return; setBusy(true); setMsg(""); try { await socialApi.reportUser({ targetGuest, targetName, reason, detail, }); setMsg(socialTx("已提交举报,处理结果会通知你")); setOpen(null); } catch (e) { setMsg(e instanceof Error ? e.message : socialTx("提交失败")); } finally { setBusy(false); } }; const submitBlock = async () => { if (busy) return; setBusy(true); setMsg(""); try { await socialApi.blockUser(targetGuest, reason); setMsg(socialTx("已屏蔽,双方将不再互相看到")); setOpen(null); } catch (e) { setMsg(e instanceof Error ? e.message : socialTx("操作失败")); } finally { setBusy(false); } }; return (
{msg ?

{msg}

: null} {open ? (
{open === "report" ? (