From 1e08f559ff66f0f4d8d50c2d889e0885257db165 Mon Sep 17 00:00:00 2001 From: "Rodrigo B. de Sousa Martins" Date: Tue, 15 Jul 2025 19:17:47 -0300 Subject: [PATCH] dashboard: reimaginacao Signed-off-by: Rodrigo B. de Sousa Martins --- src/components/dashboard/AtendimentosDia.tsx | 13 ++----------- .../dashboard/BenchmarkingEscritorio.tsx | 13 ++----------- .../dashboard/CalendarioAtendimentos.tsx | 13 ++----------- src/components/dashboard/DashboardLayout.tsx | 14 +------------- src/components/dashboard/WorkflowTarefas.tsx | 10 ---------- 5 files changed, 7 insertions(+), 56 deletions(-) diff --git a/src/components/dashboard/AtendimentosDia.tsx b/src/components/dashboard/AtendimentosDia.tsx index b3c7c5d..68fd956 100644 --- a/src/components/dashboard/AtendimentosDia.tsx +++ b/src/components/dashboard/AtendimentosDia.tsx @@ -8,23 +8,14 @@ interface Atendimento { status: string; } -function isValidJWT(token?: string) { - return !!token && token.split('.').length === 3; -} - export const AtendimentosDia: React.FC = () => { - const { user, token } = useAuth(); + const { token } = useAuth(); const [atendimentos, setAtendimentos] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { async function fetchAtendimentos() { - if (!user || !isValidJWT(token)) { - setError('Usuário não autenticado ou token inválido. Faça login novamente.'); - setLoading(false); - return; - } try { setLoading(true); setError(null); @@ -44,7 +35,7 @@ export const AtendimentosDia: React.FC = () => { } } fetchAtendimentos(); - }, [user, token]); + }, [token]); if (loading) return
Carregando atendimentos...
; if (error) return
{error}
; diff --git a/src/components/dashboard/BenchmarkingEscritorio.tsx b/src/components/dashboard/BenchmarkingEscritorio.tsx index 4283b72..3b8679d 100644 --- a/src/components/dashboard/BenchmarkingEscritorio.tsx +++ b/src/components/dashboard/BenchmarkingEscritorio.tsx @@ -6,23 +6,14 @@ interface Benchmarking { emTramitacao: number; } -function isValidJWT(token?: string) { - return !!token && token.split('.').length === 3; -} - export const BenchmarkingEscritorio: React.FC = () => { - const { user, token } = useAuth(); + const { token } = useAuth(); const [benchmarking, setBenchmarking] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { async function fetchBenchmarking() { - if (!user || !isValidJWT(token)) { - setError('Usuário não autenticado ou token inválido. Faça login novamente.'); - setLoading(false); - return; - } try { setLoading(true); setError(null); @@ -42,7 +33,7 @@ export const BenchmarkingEscritorio: React.FC = () => { } } fetchBenchmarking(); - }, [user, token]); + }, [token]); if (loading) return
Carregando benchmarking...
; if (error) return
{error}
; diff --git a/src/components/dashboard/CalendarioAtendimentos.tsx b/src/components/dashboard/CalendarioAtendimentos.tsx index 3703b4b..96065d3 100644 --- a/src/components/dashboard/CalendarioAtendimentos.tsx +++ b/src/components/dashboard/CalendarioAtendimentos.tsx @@ -8,23 +8,14 @@ interface Evento { descricao: string; } -function isValidJWT(token?: string) { - return !!token && token.split('.').length === 3; -} - export const CalendarioAtendimentos: React.FC = () => { - const { user, token } = useAuth(); + const { token } = useAuth(); const [eventos, setEventos] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { async function fetchEventos() { - if (!user || !isValidJWT(token)) { - setError('Usuário não autenticado ou token inválido. Faça login novamente.'); - setLoading(false); - return; - } try { setLoading(true); setError(null); @@ -44,7 +35,7 @@ export const CalendarioAtendimentos: React.FC = () => { } } fetchEventos(); - }, [user, token]); + }, [token]); // Simulação de calendário mensal const diasMes = Array.from({ length: 30 }, (_, i) => i + 1); diff --git a/src/components/dashboard/DashboardLayout.tsx b/src/components/dashboard/DashboardLayout.tsx index 630525c..c88dd3f 100644 --- a/src/components/dashboard/DashboardLayout.tsx +++ b/src/components/dashboard/DashboardLayout.tsx @@ -5,20 +5,8 @@ import { CalendarioAtendimentos } from './CalendarioAtendimentos'; import { BenchmarkingEscritorio } from './BenchmarkingEscritorio'; import { AtendimentosDia } from './AtendimentosDia'; -function isValidJWT(token?: string) { - return !!token && token.split('.').length === 3; -} - export const DashboardLayout: React.FC = () => { - const { user, token } = useAuth(); - - if (!user || !isValidJWT(token)) { - return ( -
- Usuário não autenticado ou token inválido. Faça login novamente. -
- ); - } + const { user } = useAuth(); return (
diff --git a/src/components/dashboard/WorkflowTarefas.tsx b/src/components/dashboard/WorkflowTarefas.tsx index 714d3a5..aaf6b15 100644 --- a/src/components/dashboard/WorkflowTarefas.tsx +++ b/src/components/dashboard/WorkflowTarefas.tsx @@ -7,11 +7,6 @@ interface Tarefa { status: string; } -function isValidJWT(token?: string) { - // JWT tem 3 partes separadas por ponto e cada parte deve ser base64 - return !!token && token.split('.').length === 3; -} - export const WorkflowTarefas: React.FC = () => { const { token } = useAuth(); const [tarefas, setTarefas] = useState([]); @@ -20,11 +15,6 @@ export const WorkflowTarefas: React.FC = () => { useEffect(() => { async function fetchTarefas() { - if (!isValidJWT(token)) { - setError('Token de autenticação inválido ou ausente. Faça login novamente.'); - setLoading(false); - return; - } try { setLoading(true); setError(null);