"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" && (