Lint errors
Signed-off-by: Rodrigo Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
9742d62ba2
commit
5acec6b71e
196 files changed
+10885
-6655
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { useMutation, useQueryClient } from "react-query";
|
||||
import axios from "axios";
|
||||
import { useMutation, useQueryClient } from "react-query";
|
||||
|
||||
export function useAudiencias(processoId: string) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
import { useContext } from 'react';
|
||||
import { AuthContext } from '../contexts/AuthContext';
|
||||
import { useContext } from "react";
|
||||
|
||||
import { AuthContext } from "../contexts/AuthContext";
|
||||
|
||||
export function useAuth() {
|
||||
const context = useContext(AuthContext);
|
||||
|
||||
|
||||
if (!context) {
|
||||
console.error('useAuth deve ser usado dentro de um AuthProvider');
|
||||
throw new Error('useAuth deve ser usado dentro de um AuthProvider');
|
||||
console.error("useAuth deve ser usado dentro de um AuthProvider");
|
||||
throw new Error("useAuth deve ser usado dentro de um AuthProvider");
|
||||
}
|
||||
|
||||
// Adicionar log para debug
|
||||
console.log('useAuth - Current user:', context.user);
|
||||
|
||||
console.log("useAuth - Current user:", context.user);
|
||||
|
||||
return context;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useQuery, useMutation, useQueryClient } from "react-query";
|
||||
import axios from "axios";
|
||||
import { useQuery, useMutation, useQueryClient } from "react-query";
|
||||
|
||||
import { Cliente } from "../types/entities";
|
||||
|
||||
export function useClientes() {
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
import { useMutation, useQueryClient } from 'react-query';
|
||||
import api from '../services/api';
|
||||
import { Comentario } from '../types/entities';
|
||||
import { useMutation, useQueryClient } from "react-query";
|
||||
|
||||
import api from "../services/api";
|
||||
import { Comentario } from "../types/entities";
|
||||
|
||||
export const useComentarios = (tarefaId: string) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const addComentario = useMutation(
|
||||
async (texto: string) => {
|
||||
const response = await api.post(`/tarefas/${tarefaId}/comentarios`, { texto });
|
||||
const response = await api.post(`/tarefas/${tarefaId}/comentarios`, {
|
||||
texto,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(['tarefas', tarefaId]);
|
||||
}
|
||||
}
|
||||
queryClient.invalidateQueries(["tarefas", tarefaId]);
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
addComentario
|
||||
addComentario,
|
||||
};
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import api from "../services/api";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,59 +1,60 @@
|
||||
import { useQuery } from 'react-query';
|
||||
import api from '../services/api';
|
||||
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'
|
||||
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');
|
||||
const response = await api.get("/dashboard/processos/stats");
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Erro ao buscar estatísticas:', 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');
|
||||
const response = await api.get("/dashboard/tarefas/stats");
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Erro ao buscar estatísticas de tarefas:', error);
|
||||
console.error("Erro ao buscar estatísticas de tarefas:", error);
|
||||
return {
|
||||
pendentes: 0,
|
||||
atrasadas: 0,
|
||||
concluidas: 0,
|
||||
total: 0,
|
||||
taxaConclusao: 0
|
||||
taxaConclusao: 0,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
const atendimentosStats = useQuery(queryKeys.atendimentos, async () => {
|
||||
const response = await api.get('/dashboard/atendimentos/stats');
|
||||
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');
|
||||
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');
|
||||
const response = await api.get("/dashboard/prazos/proximos");
|
||||
return response.data;
|
||||
});
|
||||
|
||||
const atividades = useQuery(queryKeys.atividades, async () => {
|
||||
const response = await api.get('/dashboard/atividades');
|
||||
const response = await api.get("/dashboard/atividades");
|
||||
return response.data;
|
||||
});
|
||||
|
||||
@@ -63,6 +64,6 @@ export const useDashboardStats = () => {
|
||||
atendimentosStats,
|
||||
financeiroStats,
|
||||
proximosPrazos,
|
||||
atividades
|
||||
atividades,
|
||||
};
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import { datajudApi } from "../services/datajud";
|
||||
import { DatajudResponse } from "../types/datajud";
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import api from "../services/api";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMutation, useQueryClient } from "react-query";
|
||||
import axios from "axios";
|
||||
import { useMutation, useQueryClient } from "react-query";
|
||||
|
||||
export function usePartesProcesso(processoId: string) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
import { useDatajud } from "./useDatajud";
|
||||
|
||||
export function useProcessoMovimentacoes(processo: any) {
|
||||
|
||||
+24
-21
@@ -1,16 +1,17 @@
|
||||
import { useQuery, useMutation, useQueryClient } from 'react-query';
|
||||
import api from '../services/api';
|
||||
import { Processo } from '../types/entities';
|
||||
import { useQuery, useMutation, useQueryClient } from "react-query";
|
||||
|
||||
import api from "../services/api";
|
||||
import { Processo } from "../types/entities";
|
||||
|
||||
export const useProcessos = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const { data: processos = [], isLoading } = useQuery<Processo[]>(
|
||||
'processos',
|
||||
"processos",
|
||||
async () => {
|
||||
const response = await api.get('/processos');
|
||||
const response = await api.get("/processos");
|
||||
return response.data;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const getProcesso = async (id: string) => {
|
||||
@@ -21,14 +22,14 @@ export const useProcessos = () => {
|
||||
// Corrigido para usar createProcesso como mutação
|
||||
const createProcesso = useMutation(
|
||||
async (data: Partial<Processo>) => {
|
||||
const response = await api.post('/processos', data);
|
||||
const response = await api.post("/processos", data);
|
||||
return response.data;
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries('processos');
|
||||
}
|
||||
}
|
||||
queryClient.invalidateQueries("processos");
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
// Corrigido para usar updateProcesso como mutação
|
||||
@@ -39,9 +40,9 @@ export const useProcessos = () => {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries('processos');
|
||||
}
|
||||
}
|
||||
queryClient.invalidateQueries("processos");
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
// Corrigido para usar deleteProcesso como mutação
|
||||
@@ -51,21 +52,23 @@ export const useProcessos = () => {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries('processos');
|
||||
}
|
||||
}
|
||||
queryClient.invalidateQueries("processos");
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const updateResultado = useMutation(
|
||||
async ({ id, resultado }: { id: string; resultado: string }) => {
|
||||
const response = await api.patch(`/processos/${id}/resultado`, { resultado });
|
||||
const response = await api.patch(`/processos/${id}/resultado`, {
|
||||
resultado,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries('processos');
|
||||
}
|
||||
}
|
||||
queryClient.invalidateQueries("processos");
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
@@ -75,6 +78,6 @@ export const useProcessos = () => {
|
||||
createProcesso,
|
||||
updateProcesso,
|
||||
deleteProcesso, // Retornando a mutação
|
||||
updateResultado
|
||||
updateResultado,
|
||||
};
|
||||
};
|
||||
@@ -1,40 +1,51 @@
|
||||
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
||||
import api from '../services/api';
|
||||
import { ProcessoAdministrativo } from '../types/processoAdministrativo';
|
||||
import { useMutation, useQuery, useQueryClient } from "react-query";
|
||||
|
||||
import api from "../services/api";
|
||||
import { ProcessoAdministrativo } from "../types/processoAdministrativo";
|
||||
|
||||
export function useProcessosAdministrativos() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const { data: processos, isLoading, error } = useQuery<ProcessoAdministrativo[]>(
|
||||
'processos-administrativos',
|
||||
const {
|
||||
data: processos,
|
||||
isLoading,
|
||||
error,
|
||||
} = useQuery<ProcessoAdministrativo[]>(
|
||||
"processos-administrativos",
|
||||
async () => {
|
||||
const response = await api.get('/processos-administrativos');
|
||||
const response = await api.get("/processos-administrativos");
|
||||
return response.data;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const createProcesso = useMutation(
|
||||
async (data: Partial<ProcessoAdministrativo>) => {
|
||||
const response = await api.post('/processos-administrativos', data);
|
||||
const response = await api.post("/processos-administrativos", data);
|
||||
return response.data;
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries('processos-administrativos');
|
||||
queryClient.invalidateQueries("processos-administrativos");
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const updateProcesso = useMutation(
|
||||
async ({ id, data }: { id: string; data: Partial<ProcessoAdministrativo> }) => {
|
||||
async ({
|
||||
id,
|
||||
data,
|
||||
}: {
|
||||
id: string;
|
||||
data: Partial<ProcessoAdministrativo>;
|
||||
}) => {
|
||||
const response = await api.put(`/processos-administrativos/${id}`, data);
|
||||
return response.data;
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries('processos-administrativos');
|
||||
queryClient.invalidateQueries("processos-administrativos");
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const deleteProcesso = useMutation(
|
||||
@@ -43,9 +54,9 @@ export function useProcessosAdministrativos() {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries('processos-administrativos');
|
||||
queryClient.invalidateQueries("processos-administrativos");
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
import { useMutation, useQueryClient } from 'react-query';
|
||||
import api from '../services/api';
|
||||
import { SubTarefa } from '../types/entities';
|
||||
import { useMutation, useQueryClient } from "react-query";
|
||||
|
||||
import api from "../services/api";
|
||||
import { SubTarefa } from "../types/entities";
|
||||
|
||||
export const useSubtarefas = (tarefaId: string) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const toggleSubtarefa = useMutation(
|
||||
async ({ id, concluida }: { id: string; concluida: boolean }) => {
|
||||
const response = await api.patch(`/tarefas/${tarefaId}/subtarefas/${id}`, { concluida });
|
||||
const response = await api.patch(
|
||||
`/tarefas/${tarefaId}/subtarefas/${id}`,
|
||||
{ concluida },
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(['tarefas', tarefaId]);
|
||||
}
|
||||
}
|
||||
queryClient.invalidateQueries(["tarefas", tarefaId]);
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
toggleSubtarefa
|
||||
toggleSubtarefa,
|
||||
};
|
||||
};
|
||||
+43
-28
@@ -1,25 +1,29 @@
|
||||
import { useQuery, useMutation, useQueryClient } from 'react-query';
|
||||
import api from '../services/api';
|
||||
import { Tarefa } from '../types/entities';
|
||||
import { useQuery, useMutation, useQueryClient } from "react-query";
|
||||
|
||||
import api from "../services/api";
|
||||
import { Tarefa } from "../types/entities";
|
||||
|
||||
export const useTarefas = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const { data: tarefas = [], isLoading } = useQuery<Tarefa[]>('tarefas', async () => {
|
||||
const response = await api.get('/tarefas');
|
||||
return response.data;
|
||||
});
|
||||
const { data: tarefas = [], isLoading } = useQuery<Tarefa[]>(
|
||||
"tarefas",
|
||||
async () => {
|
||||
const response = await api.get("/tarefas");
|
||||
return response.data;
|
||||
},
|
||||
);
|
||||
|
||||
const createTarefa = useMutation(
|
||||
async (data: Partial<Tarefa>) => {
|
||||
const response = await api.post('/tarefas', data);
|
||||
const response = await api.post("/tarefas", data);
|
||||
return response.data;
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries('tarefas');
|
||||
}
|
||||
}
|
||||
queryClient.invalidateQueries("tarefas");
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const updateTarefa = useMutation(
|
||||
@@ -29,21 +33,32 @@ export const useTarefas = () => {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries('tarefas');
|
||||
}
|
||||
}
|
||||
queryClient.invalidateQueries("tarefas");
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const updateStatus = useMutation(
|
||||
async ({ id, status, progresso }: { id: string; status: string; progresso?: number }) => {
|
||||
const response = await api.patch(`/tarefas/${id}/status`, { status, progresso });
|
||||
async ({
|
||||
id,
|
||||
status,
|
||||
progresso,
|
||||
}: {
|
||||
id: string;
|
||||
status: string;
|
||||
progresso?: number;
|
||||
}) => {
|
||||
const response = await api.patch(`/tarefas/${id}/status`, {
|
||||
status,
|
||||
progresso,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries('tarefas');
|
||||
}
|
||||
}
|
||||
queryClient.invalidateQueries("tarefas");
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const deleteTarefa = useMutation(
|
||||
@@ -52,22 +67,22 @@ export const useTarefas = () => {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries('tarefas');
|
||||
queryClient.invalidateQueries("tarefas");
|
||||
},
|
||||
onMutate: async (deletedId) => {
|
||||
await queryClient.cancelQueries('tarefas');
|
||||
const previousTarefas = queryClient.getQueryData<any[]>('tarefas');
|
||||
queryClient.setQueryData('tarefas', (old: any[] = []) =>
|
||||
old.filter(tarefa => tarefa.id !== deletedId)
|
||||
await queryClient.cancelQueries("tarefas");
|
||||
const previousTarefas = queryClient.getQueryData<any[]>("tarefas");
|
||||
queryClient.setQueryData("tarefas", (old: any[] = []) =>
|
||||
old.filter((tarefa) => tarefa.id !== deletedId),
|
||||
);
|
||||
return { previousTarefas };
|
||||
},
|
||||
onError: (err, variables, context: any) => {
|
||||
if (context?.previousTarefas) {
|
||||
queryClient.setQueryData('tarefas', context.previousTarefas);
|
||||
queryClient.setQueryData("tarefas", context.previousTarefas);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
@@ -76,6 +91,6 @@ export const useTarefas = () => {
|
||||
createTarefa,
|
||||
updateTarefa,
|
||||
updateStatus,
|
||||
deleteTarefa
|
||||
deleteTarefa,
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user