From ef88e717fdabe011f17dc9fa7688ef5264c48c7b Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 18 Oct 2025 18:59:22 +0000 Subject: [PATCH] Wire report submission to API cgen-2b431ae23c6c4a67a83b7c01fc6d3fb9 --- client/pages/Community.tsx | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/client/pages/Community.tsx b/client/pages/Community.tsx index ba6e575f..54b23a09 100644 --- a/client/pages/Community.tsx +++ b/client/pages/Community.tsx @@ -1724,7 +1724,7 @@ export default function Community() { ); const handleReportSubmit = useCallback( - (submitEvent: FormEvent) => { + async (submitEvent: FormEvent) => { submitEvent.preventDefault(); const trimmedDetails = reportForm.details.trim(); @@ -1740,12 +1740,31 @@ export default function Community() { return; } - aethexToast.system( - "Report submitted. Our moderation team will review shortly.", - ); - setReportForm({ reason: "", details: "" }); + try { + const resp = await fetch("/api/moderation/reports", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + reporter_id: (profile as any)?.id || null, + target_type: "other", + target_id: null, + reason: reportForm.reason, + details: trimmedDetails, + }), + }); + if (!resp.ok) { + const msg = await resp.text(); + throw new Error(msg || "Failed to submit report"); + } + aethexToast.system( + "Report submitted. Our moderation team will review shortly.", + ); + setReportForm({ reason: "", details: "" }); + } catch (e: any) { + aethexToast.system(String(e?.message || e)); + } }, - [reportForm], + [reportForm, profile], ); if (isLoading) {