Add safety checks and null guards to ReportDetailModal

This commit is contained in:
2025-11-16 22:15:47 +00:00
parent 02fe58eb31
commit 5c8b66cb0c

View File

@@ -18,7 +18,7 @@ export function ReportDetailModal({ report, isOpen, onClose, onVerify, onDispute
const [showAuditLog, setShowAuditLog] = useState(false);
const [comment, setComment] = useState('');
if (!isOpen) return null;
if (!isOpen || !report) return null;
const handleVerify = () => {
if (onVerify) {
@@ -292,7 +292,7 @@ export function ReportDetailModal({ report, isOpen, onClose, onVerify, onDispute
<path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clipRule="evenodd" />
</svg>
<span className="text-sm text-gray-700">
<span className="font-semibold">{report.verificationCount}</span> verifications
<span className="font-semibold">{report.verificationCount || 0}</span> verifications
</span>
</div>
<div className="flex items-center gap-2">
@@ -300,13 +300,13 @@ export function ReportDetailModal({ report, isOpen, onClose, onVerify, onDispute
<path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clipRule="evenodd" />
</svg>
<span className="text-sm text-gray-700">
<span className="font-semibold">{report.disputeCount}</span> disputes
<span className="font-semibold">{report.disputeCount || 0}</span> disputes
</span>
</div>
</div>
{/* Auto-hide warning for disputed reports */}
{report.disputeCount >= 3 && (
{(report.disputeCount || 0) >= 3 && (
<div className="mt-3 p-3 bg-red-50 border border-red-200 rounded-lg flex items-start gap-2">
<svg className="w-5 h-5 text-red-600 flex-shrink-0 mt-0.5" fill="currentColor" viewBox="0 0 20 20">
<path fillRule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clipRule="evenodd" />