diff --git a/client/pages/Staff.tsx b/client/pages/Staff.tsx index 828ab7a5..cb4f1664 100644 --- a/client/pages/Staff.tsx +++ b/client/pages/Staff.tsx @@ -40,6 +40,45 @@ export default function Staff() { }, [user, roles, hasAccess, loading, navigate]); const [activeTab, setActiveTab] = useState("overview"); + const [openReports, setOpenReports] = useState([]); + const [mentorshipAll, setMentorshipAll] = useState([]); + const [loadingData, setLoadingData] = useState(false); + + const refresh = async () => { + setLoadingData(true); + try { + const [r1, r2] = await Promise.all([ + fetch("/api/moderation/reports?status=open&limit=100"), + fetch("/api/mentorship/requests/all?limit=50&status=pending"), + ]); + const reports = r1.ok ? await r1.json() : []; + const m = r2.ok ? await r2.json() : []; + setOpenReports(Array.isArray(reports) ? reports : []); + setMentorshipAll(Array.isArray(m) ? m : []); + } catch (e) { + /* ignore */ + } finally { + setLoadingData(false); + } + }; + + useEffect(() => { + if (user && hasAccess) refresh(); + }, [user, hasAccess]); + + const updateReportStatus = async (id: string, status: "resolved" | "ignored" | "open") => { + try { + const resp = await fetch(`/api/moderation/reports/${encodeURIComponent(id)}/status`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ status }), + }); + if (resp.ok) { + aethexToast.success({ title: "Updated", description: `Report marked ${status}` }); + refresh(); + } + } catch {} + }; return ( @@ -68,11 +107,11 @@ export default function Staff() {
Open reports
-
0
+
{openReports.length}
Mentorship requests
-
0
+
{mentorshipAll.length}
@@ -113,7 +152,28 @@ export default function Staff() { Flagged content and actions -

No items in queue.

+ {loadingData && ( +

Loading…

+ )} + {!loadingData && openReports.length === 0 && ( +

No items in queue.

+ )} +
+ {openReports.map((r) => ( +
+
+
+
{r.reason}
+
{r.details}
+
+
+ + +
+
+
+ ))} +
@@ -125,7 +185,27 @@ export default function Staff() { Review recent mentor/mentee activity -

No requests to review.

+ {loadingData && ( +

Loading…

+ )} + {!loadingData && mentorshipAll.length === 0 && ( +

No requests to review.

+ )} +
+ {mentorshipAll.map((req) => ( +
+
+
+
{req.mentee?.full_name || req.mentee?.username} → {req.mentor?.full_name || req.mentor?.username}
+
{req.message || "No message"}
+
+
+ {req.status} +
+
+
+ ))} +