import { useState } from 'react'; import { Modal } from './ui/Modal'; import { Button } from './ui/Button'; import { GradientButton } from './ui/GradientButton'; import { api } from '../api/client'; import type { ReportReason } from '../types'; interface ReportModalProps { isOpen: boolean; onClose: () => void; targetType: 'LISTING' | 'USER'; targetId: string; } const REASONS: { value: ReportReason; label: string }[] = [ { value: 'SPAM', label: 'Spam' }, { value: 'INAPPROPRIATE', label: 'Inappropriate content' }, { value: 'SCAM', label: 'Scam / Fraud' }, { value: 'COUNTERFEIT', label: 'Counterfeit item' }, { value: 'PROHIBITED_ITEM', label: 'Prohibited item' }, { value: 'HARASSMENT', label: 'Harassment' }, { value: 'OTHER', label: 'Other' }, ]; export function ReportModal({ isOpen, onClose, targetType, targetId }: ReportModalProps) { const [reason, setReason] = useState(''); const [description, setDescription] = useState(''); const [submitting, setSubmitting] = useState(false); const [success, setSuccess] = useState(false); const [error, setError] = useState(''); const handleSubmit = async () => { if (!reason) return; setSubmitting(true); setError(''); try { await api.post('/reports', { targetType, targetId, reason, description: description || undefined }); setSuccess(true); setTimeout(() => { onClose(); setSuccess(false); setReason(''); setDescription(''); }, 1500); } catch (err) { setError(err instanceof Error ? err.message : 'Failed to submit report'); } finally { setSubmitting(false); } }; return ( {success ? (

Report submitted. Thank you!

) : ( <> {error &&

{error}

}

Why are you reporting this?

{REASONS.map((r) => ( ))}