'use client'; import { useState } from 'react'; import { X, AlertTriangle, Layers, Calendar, Target, User, Lightbulb, FileText } from 'lucide-react'; import type { IssueItem, SpanItem } from '../types'; import { DOMAIN_LABELS, INTENSITY_LABELS, VALENCE_LABELS, VALENCE_COLORS } from '../types'; import { useIssueSpans } from '@/hooks/useReviewIQAnalytics'; import { ReviewModal } from './ReviewModal'; interface IssueDetailModalProps { issue: IssueItem; onClose: () => void; } /** * Modal showing issue details and related spans. */ export function IssueDetailModal({ issue, onClose }: IssueDetailModalProps) { const { data: spans, loading, error } = useIssueSpans(issue.issue_id); const [selectedReview, setSelectedReview] = useState<{ reviewId: string; spanId: string; } | null>(null); return (
e.stopPropagation()} > {/* Header */}

{issue.subcode_name || issue.primary_subcode}

{issue.primary_subcode}
{issue.state.toUpperCase()}
{/* Content */}
{/* Issue Info Grid */}
URT Code
{issue.primary_subcode}
Domain
{DOMAIN_LABELS[issue.domain] || issue.domain}
Priority
{(issue.priority_score * 100).toFixed(0)}%
Intensity
{issue.max_intensity ? INTENSITY_LABELS[issue.max_intensity] || issue.max_intensity : 'N/A'}
{/* Entity */} {issue.entity && (
Related Entity

{issue.entity}

)} {/* Solution & Owner Section */} {(issue.solution || issue.default_owner) && (
{issue.solution && (
Recommended Solution {issue.solution_complexity && ( {issue.solution_complexity.charAt(0).toUpperCase() + issue.solution_complexity.slice(1)} Complexity )}

{issue.solution}

)} {issue.default_owner && (
Assign to:{' '} {issue.default_owner}
)}
)} {/* Related Spans */}

Related Spans ({issue.span_count})

{loading ? (
) : error ? (
Failed to load spans: {error}
) : spans.length === 0 ? (
No spans found for this issue
) : (
{spans.map((span: SpanItem) => (

{span.span_text}

{span.valence && ( {VALENCE_LABELS[span.valence] || span.valence} )} {span.intensity && ( {INTENSITY_LABELS[span.intensity] || span.intensity} )}
{span.urt_primary && ( {span.urt_primary} )} {span.review_time && ( {new Date(span.review_time).toLocaleDateString()} )} {span.entity && Entity: {span.entity}}
{/* View Full Review Button */} {span.source_review_id && ( )}
))}
)}
{/* Footer */}
{/* Review Modal for drill-down */} {selectedReview && ( setSelectedReview(null)} /> )}
); }