Files
memind/ops/src/pages/ReportsPage.tsx
T
John 2e14873f2d Initial commit: Memind H5 portal with MindSpace, Plaza, and agent jobs.
Track application source and tests; exclude local env, user workspaces, and runtime data via .gitignore.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-15 15:04:43 -07:00

57 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { useEffect, useState } from 'react';
import { fetchReports, processReport } from '../api/client';
export function ReportsPage() {
const [reports, setReports] = useState<Awaited<ReturnType<typeof fetchReports>>['reports']>([]);
const [error, setError] = useState<string | null>(null);
const load = async () => {
try {
const data = await fetchReports();
setReports(data.reports);
} catch (err) {
setError(err instanceof Error ? err.message : '加载失败');
}
};
useEffect(() => {
void load();
}, []);
return (
<div className="grid">
{error ? <p className="alert">{error}</p> : null}
{reports.map((report) => (
<div key={report.id} className="card">
<h3>
{report.target_type} · {report.reason}
{report.target_report_count > 3 ? (
<span className="alert"> · ({report.target_report_count})</span>
) : null}
</h3>
<p>{report.detail || '无补充说明'}</p>
<p style={{ color: '#68716c', fontSize: 12 }}> ID{report.target_id}</p>
<div style={{ display: 'flex', gap: 8, marginTop: 12 }}>
<button
type="button"
className="btn danger"
onClick={() =>
void processReport(report.id, 'hide_post', 'hide from report queue').then(load)
}
>
</button>
<button
type="button"
className="btn secondary"
onClick={() => void processReport(report.id, 'dismiss').then(load)}
>
</button>
</div>
</div>
))}
</div>
);
}