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

+9 -2
View File
@@ -1,4 +1,5 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { useAuth } from '../../contexts/AuthContext';
interface Atendimento { interface Atendimento {
id: string; id: string;
@@ -8,6 +9,7 @@ interface Atendimento {
} }
export const AtendimentosDia: React.FC = () => { export const AtendimentosDia: React.FC = () => {
const { token } = useAuth();
const [atendimentos, setAtendimentos] = useState<Atendimento[]>([]); const [atendimentos, setAtendimentos] = useState<Atendimento[]>([]);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
@@ -17,7 +19,12 @@ export const AtendimentosDia: React.FC = () => {
try { try {
setLoading(true); setLoading(true);
setError(null); setError(null);
const res = await fetch('/api/atendimentos-dia'); const res = await fetch('/api/atendimentos-dia', {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
});
if (!res.ok) throw new Error('Erro ao buscar atendimentos do dia'); if (!res.ok) throw new Error('Erro ao buscar atendimentos do dia');
const data = await res.json(); const data = await res.json();
setAtendimentos(data); setAtendimentos(data);
@@ -28,7 +35,7 @@ export const AtendimentosDia: React.FC = () => {
} }
} }
fetchAtendimentos(); fetchAtendimentos();
}, []); }, [token]);
if (loading) return <div>Carregando atendimentos...</div>; if (loading) return <div>Carregando atendimentos...</div>;
if (error) return <div className="text-red-600">{error}</div>; if (error) return <div className="text-red-600">{error}</div>;
@@ -1,4 +1,5 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { useAuth } from '../../contexts/AuthContext';
interface Benchmarking { interface Benchmarking {
ajuizados15dias: number; ajuizados15dias: number;
@@ -6,6 +7,7 @@ interface Benchmarking {
} }
export const BenchmarkingEscritorio: React.FC = () => { export const BenchmarkingEscritorio: React.FC = () => {
const { token } = useAuth();
const [benchmarking, setBenchmarking] = useState<Benchmarking | null>(null); const [benchmarking, setBenchmarking] = useState<Benchmarking | null>(null);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
@@ -15,7 +17,12 @@ export const BenchmarkingEscritorio: React.FC = () => {
try { try {
setLoading(true); setLoading(true);
setError(null); 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'); if (!res.ok) throw new Error('Erro ao buscar benchmarking');
const data = await res.json(); const data = await res.json();
setBenchmarking(data); setBenchmarking(data);
@@ -26,7 +33,7 @@ export const BenchmarkingEscritorio: React.FC = () => {
} }
} }
fetchBenchmarking(); fetchBenchmarking();
}, []); }, [token]);
if (loading) return <div>Carregando benchmarking...</div>; if (loading) return <div>Carregando benchmarking...</div>;
if (error) return <div className="text-red-600">{error}</div>; if (error) return <div className="text-red-600">{error}</div>;
@@ -1,4 +1,5 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { useAuth } from '../../contexts/AuthContext';
interface Evento { interface Evento {
id: string; id: string;
@@ -8,6 +9,7 @@ interface Evento {
} }
export const CalendarioAtendimentos: React.FC = () => { export const CalendarioAtendimentos: React.FC = () => {
const { token } = useAuth();
const [eventos, setEventos] = useState<Evento[]>([]); const [eventos, setEventos] = useState<Evento[]>([]);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
@@ -17,7 +19,12 @@ export const CalendarioAtendimentos: React.FC = () => {
try { try {
setLoading(true); setLoading(true);
setError(null); setError(null);
const res = await fetch('/api/eventos'); const res = await fetch('/api/eventos', {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
});
if (!res.ok) throw new Error('Erro ao buscar eventos'); if (!res.ok) throw new Error('Erro ao buscar eventos');
const data = await res.json(); const data = await res.json();
setEventos(data); setEventos(data);
@@ -28,7 +35,7 @@ export const CalendarioAtendimentos: React.FC = () => {
} }
} }
fetchEventos(); fetchEventos();
}, []); }, [token]);
// Simulação de calendário mensal // Simulação de calendário mensal
const diasMes = Array.from({ length: 30 }, (_, i) => i + 1); const diasMes = Array.from({ length: 30 }, (_, i) => i + 1);