diff --git a/backend/schemas.py b/backend/schemas.py index 29f790f..754d4f6 100644 --- a/backend/schemas.py +++ b/backend/schemas.py @@ -287,8 +287,8 @@ class PerformanceNicknameRead(PerformanceNicknameBase): # --- Report Schemas --- class ReportBase(SQLModel): - target_type: str - target_id: int + entity_type: str + entity_id: int reason: str class ReportCreate(ReportBase): diff --git a/frontend/components/moderation/report-dialog.tsx b/frontend/components/moderation/report-dialog.tsx new file mode 100644 index 0000000..0d7ba6b --- /dev/null +++ b/frontend/components/moderation/report-dialog.tsx @@ -0,0 +1,121 @@ +"use client" + +import { useState } from "react" +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog" +import { Button } from "@/components/ui/button" +import { Label } from "@/components/ui/label" +import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group" +import { Flag } from "lucide-react" +import { getApiUrl } from "@/lib/api-config" +import { Textarea } from "@/components/ui/textarea" + +interface ReportDialogProps { + entityType: "comment" | "review" | "nickname" + entityId: number + trigger?: React.ReactNode +} + +export function ReportDialog({ entityType, entityId, trigger }: ReportDialogProps) { + const [open, setOpen] = useState(false) + const [reason, setReason] = useState("spam") + const [details, setDetails] = useState("") + const [loading, setLoading] = useState(false) + + const handleSubmit = async () => { + const token = localStorage.getItem("token") + if (!token) return + + setLoading(true) + try { + const res = await fetch(`${getApiUrl()}/moderation/reports`, { + method: "POST", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${token}` + }, + body: JSON.stringify({ + entity_type: entityType, + entity_id: entityId, + reason: reason, + details: details // Schema might not have details yet, check backend + }) + }) + + if (res.ok) { + setOpen(false) + alert("Report submitted. Thank you for helping keep the community safe.") + } else { + alert("Failed to submit report.") + } + } catch (error) { + console.error(error) + } finally { + setLoading(false) + } + } + + return ( + + + {trigger || ( + + )} + + + + Report Content + + Help us understand what's wrong with this content. + + + +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + {reason === "other" && ( +