import React, { useState } from "react"; import { Flag, X } from "lucide-react"; import { reportUser } from "../../api/client"; import type { ReportReasonType } from "../../types"; interface ReportModalProps { isOpen: boolean; onClose: () => void; subjectDid: string; subjectUri?: string; subjectHandle?: string; } const REASONS: { value: ReportReasonType; label: string; description: string; }[] = [ { value: "spam", label: "Spam", description: "Unwanted repetitive content" }, { value: "violation", label: "Rule violation", description: "Violates community guidelines", }, { value: "misleading", label: "Misleading", description: "False or misleading information", }, { value: "rude", label: "Rude or harassing", description: "Targeting or harassing a user", }, { value: "sexual", label: "Inappropriate content", description: "Sexual or explicit material", }, { value: "other", label: "Other", description: "Something else not listed above", }, ]; export default function ReportModal({ isOpen, onClose, subjectDid, subjectUri, subjectHandle, }: ReportModalProps) { const [selectedReason, setSelectedReason] = useState( null, ); const [additionalText, setAdditionalText] = useState(""); const [submitting, setSubmitting] = useState(false); const [submitted, setSubmitted] = useState(false); if (!isOpen) return null; const handleSubmit = async () => { if (!selectedReason) return; setSubmitting(true); const success = await reportUser({ subjectDid: subjectDid, subjectUri: subjectUri, reasonType: selectedReason, reasonText: additionalText || undefined, }); setSubmitting(false); if (success) { setSubmitted(true); setTimeout(() => { onClose(); setSubmitted(false); setSelectedReason(null); setAdditionalText(""); }, 1500); } }; const handleClose = () => { onClose(); setSelectedReason(null); setAdditionalText(""); setSubmitted(false); }; return (
e.stopPropagation()} > {submitted ? (

Report submitted

Thank you. We'll review this shortly.

) : ( <>

Report {subjectHandle ? `@${subjectHandle}` : "user"}

{subjectUri && (

Reporting specific content

)}

What's the issue?

{REASONS.map((reason) => ( ))}
{selectedReason && (