admin.nomadro.com gets sidebar L1/L2 social ops (paginated lists + entity detail); API adds soft-delete archives/stats and shared nomadro_pb for social/coffee/notify/work. Co-authored-by: Cursor <cursoragent@cursor.com>
123 lines
3.3 KiB
TypeScript
123 lines
3.3 KiB
TypeScript
"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 (
|
|
<section className="social-moderation">
|
|
<div className="social-moderation-actions">
|
|
<button
|
|
type="button"
|
|
className="social-btn"
|
|
onClick={() => setOpen(open === "report" ? null : "report")}
|
|
>
|
|
<Flag size={14} aria-hidden /> {socialTx("举报")}
|
|
</button>
|
|
<button
|
|
type="button"
|
|
className="social-btn"
|
|
onClick={() => setOpen(open === "block" ? null : "block")}
|
|
>
|
|
<Ban size={14} aria-hidden /> {socialTx("屏蔽")}
|
|
</button>
|
|
</div>
|
|
{msg ? <p className="social-muted">{msg}</p> : null}
|
|
{open ? (
|
|
<div className="social-moderation-sheet">
|
|
<label>
|
|
{socialTx("原因")}
|
|
<select value={reason} onChange={(e) => setReason(e.target.value)}>
|
|
{REASONS.map((r) => (
|
|
<option key={r} value={r}>
|
|
{socialTx(r)}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</label>
|
|
{open === "report" ? (
|
|
<label>
|
|
{socialTx("补充说明")}
|
|
<textarea
|
|
rows={3}
|
|
value={detail}
|
|
onChange={(e) => setDetail(e.target.value)}
|
|
maxLength={800}
|
|
/>
|
|
</label>
|
|
) : null}
|
|
<button
|
|
type="button"
|
|
className="social-btn coral"
|
|
disabled={busy}
|
|
onClick={() => void (open === "report" ? submitReport() : submitBlock())}
|
|
>
|
|
{busy
|
|
? socialTx("提交中…")
|
|
: open === "report"
|
|
? socialTx("提交举报")
|
|
: socialTx("确认屏蔽")}
|
|
</button>
|
|
</div>
|
|
) : null}
|
|
</section>
|
|
);
|
|
}
|