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:17:47 -03:00
1 parent 1ab7bd8f36
commit 1e08f559ff
5 files changed
+7 -56

No files matched your search

+2 -11
View File
@@ -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<Atendimento[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(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 <div>Carregando atendimentos...</div>;
if (error) return <div className="text-red-600">{error}</div>;
@@ -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<Benchmarking | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(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 <div>Carregando benchmarking...</div>;
if (error) return <div className="text-red-600">{error}</div>;
@@ -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<Evento[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(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);
+1 -13
View File
@@ -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 (
<div className="p-6 text-center text-red-600 font-bold">
Usuário não autenticado ou token inválido. Faça login novamente.
</div>
);
}
const { user } = useAuth();
return (
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6 p-6">
@@ -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<Tarefa[]>([]);
@@ -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);