import { useQuery } from '@tanstack/react-query' import { useState } from 'react' import { Search, Filter, RefreshCw, ExternalLink, CheckCircle, Clock, XCircle, Activity } from 'lucide-react' import { api } from '../lib/api' import { clsx } from 'clsx' type IssueStatus = 'pending' | 'analyzing' | 'analyzed' | 'fix_generated' | 'pr_created' | 'accepted' | 'rejected' | 'failed' interface Issue { id: string jira_key: string title: string status: IssueStatus module?: string confidence?: number created_at: string pr_url?: string } const statusConfig: Record = { pending: { label: 'Pendente', color: 'bg-gray-100 text-gray-800', icon: }, analyzing: { label: 'Analisando', color: 'bg-blue-100 text-blue-800', icon: }, analyzed: { label: 'Analisado', color: 'bg-purple-100 text-purple-800', icon: }, fix_generated: { label: 'Fix Gerado', color: 'bg-indigo-100 text-indigo-800', icon: }, pr_created: { label: 'PR Criado', color: 'bg-cyan-100 text-cyan-800', icon: }, accepted: { label: 'Aceito', color: 'bg-green-100 text-green-800', icon: }, rejected: { label: 'Rejeitado', color: 'bg-red-100 text-red-800', icon: }, failed: { label: 'Falhou', color: 'bg-red-100 text-red-800', icon: }, } export default function Issues() { const [search, setSearch] = useState('') const [statusFilter, setStatusFilter] = useState('') const { data, isLoading, refetch } = useQuery({ queryKey: ['issues', statusFilter], queryFn: () => api.get('/api/issues', { params: { status: statusFilter || undefined } }).then(r => r.data), }) const issues: Issue[] = data?.items || [] const filteredIssues = issues.filter(issue => issue.jira_key.toLowerCase().includes(search.toLowerCase()) || issue.title.toLowerCase().includes(search.toLowerCase()) ) return (
{/* Filters */}
setSearch(e.target.value)} className="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" />
{/* Issues Table */}
{isLoading ? (
) : filteredIssues.length === 0 ? (

Nenhuma issue encontrada

Issues do JIRA aparecerão aqui após configurar os webhooks

) : ( {filteredIssues.map(issue => { const status = statusConfig[issue.status] return ( ) })}
JIRA Key Título Módulo Status Confiança Ações
{issue.jira_key} {issue.title} {issue.module || '-'} {status.icon} {status.label} {issue.confidence ? (
{(issue.confidence * 100).toFixed(0)}%
) : '-'}
{issue.pr_url && ( PR )}
)}
) }