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:12:10 -03:00
1 parent af2f0ed649
commit f782fb36ad
3 files changed
+33 -6

No files matched your search

+11 -2
View File
@@ -8,14 +8,23 @@ interface Atendimento {
status: string;
}
function isValidJWT(token?: string) {
return !!token && token.split('.').length === 3;
}
export const AtendimentosDia: React.FC = () => {
const { token } = useAuth();
const { user, 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);
@@ -35,7 +44,7 @@ export const AtendimentosDia: React.FC = () => {
}
}
fetchAtendimentos();
}, [token]);
}, [user, token]);
if (loading) return <div>Carregando atendimentos...</div>;
if (error) return <div className="text-red-600">{error}</div>;
@@ -6,14 +6,23 @@ interface Benchmarking {
emTramitacao: number;
}
function isValidJWT(token?: string) {
return !!token && token.split('.').length === 3;
}
export const BenchmarkingEscritorio: React.FC = () => {
const { token } = useAuth();
const { user, 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);
@@ -33,7 +42,7 @@ export const BenchmarkingEscritorio: React.FC = () => {
}
}
fetchBenchmarking();
}, [token]);
}, [user, token]);
if (loading) return <div>Carregando benchmarking...</div>;
if (error) return <div className="text-red-600">{error}</div>;
@@ -8,14 +8,23 @@ interface Evento {
descricao: string;
}
function isValidJWT(token?: string) {
return !!token && token.split('.').length === 3;
}
export const CalendarioAtendimentos: React.FC = () => {
const { token } = useAuth();
const { user, 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);
@@ -35,7 +44,7 @@ export const CalendarioAtendimentos: React.FC = () => {
}
}
fetchEventos();
}, [token]);
}, [user, token]);
// Simulação de calendário mensal
const diasMes = Array.from({ length: 30 }, (_, i) => i + 1);