dashboard: reimaginacao
Signed-off-by: Rodrigo B. de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
af2f0ed649
commit
f782fb36ad
3 files changed
+33
-6
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user