first commit
This commit is contained in:
commit
c9fb67e751
423 files changed
+53287
No files matched your search
@@ -0,0 +1,68 @@
|
||||
import { useQuery } from 'react-query';
|
||||
import api from '../services/api';
|
||||
|
||||
export const useDashboardStats = () => {
|
||||
const queryKeys = {
|
||||
processos: 'dashboard-processos-stats',
|
||||
tarefas: 'dashboard-tarefas-stats',
|
||||
atendimentos: 'dashboard-atendimentos-stats',
|
||||
financeiro: 'dashboard-financeiro-stats',
|
||||
prazos: 'dashboard-prazos',
|
||||
atividades: 'dashboard-atividades'
|
||||
};
|
||||
|
||||
const processosStats = useQuery(queryKeys.processos, async () => {
|
||||
try {
|
||||
const response = await api.get('/dashboard/processos/stats');
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Erro ao buscar estatísticas:', error);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
const tarefasStats = useQuery(queryKeys.tarefas, async () => {
|
||||
try {
|
||||
const response = await api.get('/dashboard/tarefas/stats');
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Erro ao buscar estatísticas de tarefas:', error);
|
||||
return {
|
||||
pendentes: 0,
|
||||
atrasadas: 0,
|
||||
concluidas: 0,
|
||||
total: 0,
|
||||
taxaConclusao: 0
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
const atendimentosStats = useQuery(queryKeys.atendimentos, async () => {
|
||||
const response = await api.get('/dashboard/atendimentos/stats');
|
||||
return response.data;
|
||||
});
|
||||
|
||||
const financeiroStats = useQuery(queryKeys.financeiro, async () => {
|
||||
const response = await api.get('/dashboard/financeiro/stats');
|
||||
return response.data;
|
||||
});
|
||||
|
||||
const proximosPrazos = useQuery(queryKeys.prazos, async () => {
|
||||
const response = await api.get('/dashboard/prazos/proximos');
|
||||
return response.data;
|
||||
});
|
||||
|
||||
const atividades = useQuery(queryKeys.atividades, async () => {
|
||||
const response = await api.get('/dashboard/atividades');
|
||||
return response.data;
|
||||
});
|
||||
|
||||
return {
|
||||
processosStats,
|
||||
tarefasStats,
|
||||
atendimentosStats,
|
||||
financeiroStats,
|
||||
proximosPrazos,
|
||||
atividades
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user