dashboard: reimaginacao

Signed-off-by: Rodrigo B. de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
rodrigo committed 2025-07-15 19:07:35 -03:00
1 parent 7e868dbc46
commit 6b89a61dd7
3 files changed
+27 -6

No files matched your search

@@ -1,4 +1,5 @@
import React, { useEffect, useState } from 'react';
import { useAuth } from '../../contexts/AuthContext';
interface Benchmarking {
ajuizados15dias: number;
@@ -6,6 +7,7 @@ interface Benchmarking {
}
export const BenchmarkingEscritorio: React.FC = () => {
const { token } = useAuth();
const [benchmarking, setBenchmarking] = useState<Benchmarking | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
@@ -15,7 +17,12 @@ export const BenchmarkingEscritorio: React.FC = () => {
try {
setLoading(true);
setError(null);
const res = await fetch('/api/benchmarking');
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);
@@ -26,7 +33,7 @@ export const BenchmarkingEscritorio: React.FC = () => {
}
}
fetchBenchmarking();
}, []);
}, [token]);
if (loading) return <div>Carregando benchmarking...</div>;
if (error) return <div className="text-red-600">{error}</div>;