// Exemplo de página de Nova Investigação // /app/investigations/new/page.tsx "use client" import { useState } from 'react' import { useRouter } from 'next/navigation' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' import { Label } from '@/components/ui/label' import { Badge } from '@/components/ui/badge' import { Checkbox } from '@/components/ui/checkbox' import { Calendar } from '@/components/ui/calendar' import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover' import { AlertCircle, Calendar as CalendarIcon, Sparkles, Search, TrendingUp } from 'lucide-react' import { format } from 'date-fns' import { ptBR } from 'date-fns/locale' import { toast } from 'sonner' import { useInvestigationStore } from '@/stores/investigationStore' // Órgãos principais para investigação const ORGAOS = [ { value: '26000', label: 'Ministério da Saúde', risk: 'high' }, { value: '20000', label: 'Presidência da República', risk: 'medium' }, { value: '25000', label: 'Ministério da Educação', risk: 'high' }, { value: '30000', label: 'Ministério da Justiça', risk: 'medium' }, { value: '22000', label: 'Ministério da Agricultura', risk: 'low' }, ] const ANALYSIS_TYPES = [ { id: 'price_anomalies', label: 'Anomalias de Preço', description: 'Detecta sobrepreço e superfaturamento', icon: '💰' }, { id: 'vendor_concentration', label: 'Concentração de Fornecedores', description: 'Identifica monopólios e cartéis', icon: '🏢' }, { id: 'temporal_patterns', label: 'Padrões Temporais', description: 'Analisa gastos suspeitos no tempo', icon: '📅' }, { id: 'duplicate_contracts', label: 'Contratos Duplicados', description: 'Encontra fracionamento irregular', icon: '📄' } ] export default function NewInvestigationPage() { const router = useRouter() const { createInvestigation } = useInvestigationStore() const [isLoading, setIsLoading] = useState(false) // Form state const [orgao, setOrgao] = useState('') const [dateRange, setDateRange] = useState<{ from: Date; to: Date }>({ from: new Date(2024, 0, 1), to: new Date() }) const [selectedAnalysis, setSelectedAnalysis] = useState([ 'price_anomalies', 'vendor_concentration' ]) const [depth, setDepth] = useState<'quick' | 'complete' | 'deep'>('complete') const handleSubmit = async () => { if (!orgao) { toast.error('Selecione um órgão para investigar') return } setIsLoading(true) try { const result = await createInvestigation({ orgao_codigo: orgao, periodo_inicio: format(dateRange.from, 'yyyy-MM-dd'), periodo_fim: format(dateRange.to, 'yyyy-MM-dd'), tipos_analise: selectedAnalysis, profundidade: depth }) toast.success('Investigação iniciada! Redirecionando...') router.push(`/investigations/${result.id}`) } catch (error) { toast.error('Erro ao iniciar investigação') setIsLoading(false) } } const selectedOrgao = ORGAOS.find(o => o.value === orgao) return (

Nova Investigação

Configure os parâmetros para analisar contratos e despesas públicas

Parâmetros da Investigação Nossos agentes de IA irão analisar os dados selecionados em busca de irregularidades {/* Seleção de Órgão */}
{selectedOrgao?.risk === 'high' && (

Este órgão tem histórico de irregularidades

)}
{/* Período */}
date && setDateRange({ ...dateRange, from: date })} initialFocus /> até date && setDateRange({ ...dateRange, to: date })} initialFocus />
{/* Tipos de Análise */}
{ANALYSIS_TYPES.map((type) => ( { setSelectedAnalysis( selectedAnalysis.includes(type.id) ? selectedAnalysis.filter(id => id !== type.id) : [...selectedAnalysis, type.id] ) }} > {}} className="mt-1" />
{type.icon} {type.label}

{type.description}

))}
{/* Profundidade */}
{/* Preview */} {orgao && selectedAnalysis.length > 0 && (

Prévia da Investigação

  • • Analisando contratos do(a) {selectedOrgao?.label}
  • • Período: {format(dateRange.from, 'MMMM/yyyy', { locale: ptBR })} até {format(dateRange.to, 'MMMM/yyyy', { locale: ptBR })}
  • • {selectedAnalysis.length} tipos de análise selecionados
  • • Tempo estimado: { depth === 'quick' ? '~2 minutos' : depth === 'complete' ? '~5 minutos' : '~10 minutos' }
)} {/* Botão de Submit */}

Ao iniciar, nossos agentes de IA começarão a análise em tempo real. Você poderá acompanhar o progresso na próxima tela.

) }