import React, { useEffect, useState } from 'react'; import { useAuth } from '../../contexts/AuthContext'; interface Benchmarking { ajuizados15dias: number; emTramitacao: number; } export const BenchmarkingEscritorio: React.FC = () => { const { token } = useAuth(); const [benchmarking, setBenchmarking] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { async function fetchBenchmarking() { try { setLoading(true); setError(null); const res = await fetch('/api/benchmarking', { headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json', }, }); if (!res.ok) throw new Error('Erro ao buscar benchmarking'); const data = await res.json(); setBenchmarking(data); } catch (err: any) { setError(err.message); } finally { setLoading(false); } } fetchBenchmarking(); }, [token]); if (loading) return
Carregando benchmarking...
; if (error) return
{error}
; if (!benchmarking) return null; return (
Processos ajuizados (últimos 15 dias): {benchmarking.ajuizados15dias}
Processos em tramitação: {benchmarking.emTramitacao}
); };