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,13 +1,21 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { useParams, useNavigate, Link } from 'react-router-dom';
|
||||
import { DocumentIcon, PlusIcon, TrashIcon, EyeIcon, CogIcon } from '@heroicons/react/24/outline';
|
||||
import { DocumentoEditor } from './DocumentoEditor';
|
||||
import { api } from '../lib/api';
|
||||
import { toast } from 'react-toastify';
|
||||
import { useAuth } from '../contexts/AuthContext';
|
||||
import { Dialog } from '@headlessui/react';
|
||||
import { XMarkIcon } from '@heroicons/react/24/outline';
|
||||
import { DocumentoViewer } from './DocumentoViewer';
|
||||
import { Dialog } from "@headlessui/react";
|
||||
import {
|
||||
DocumentIcon,
|
||||
PlusIcon,
|
||||
TrashIcon,
|
||||
EyeIcon,
|
||||
CogIcon,
|
||||
XMarkIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useState, useEffect, useCallback } from "react";
|
||||
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
import { useAuth } from "../contexts/AuthContext";
|
||||
import { api } from "../lib/api";
|
||||
|
||||
import { DocumentoEditor } from "./DocumentoEditor";
|
||||
import { DocumentoViewer } from "./DocumentoViewer";
|
||||
|
||||
export function DocumentosPage() {
|
||||
const [isEditorOpen, setIsEditorOpen] = useState(false);
|
||||
@@ -23,7 +31,7 @@ export function DocumentosPage() {
|
||||
|
||||
const loadData = useCallback(async () => {
|
||||
if (!user) {
|
||||
navigate('/login');
|
||||
navigate("/login");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -31,12 +39,12 @@ export function DocumentosPage() {
|
||||
setIsLoading(true);
|
||||
await Promise.all([loadDocumentos(), loadModelos()]);
|
||||
} catch (error) {
|
||||
console.error('Erro ao carregar dados:', error);
|
||||
console.error("Erro ao carregar dados:", error);
|
||||
if (error?.response?.status === 401) {
|
||||
signOut(); // Usar a função do AuthContext
|
||||
navigate('/login');
|
||||
navigate("/login");
|
||||
} else {
|
||||
toast.error('Erro ao carregar dados');
|
||||
toast.error("Erro ao carregar dados");
|
||||
}
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
@@ -52,12 +60,12 @@ export function DocumentosPage() {
|
||||
if (processoId) params.processoId = processoId;
|
||||
if (atendimentoId) params.atendimentoId = atendimentoId;
|
||||
|
||||
const response = await api.get('/documentos', { params });
|
||||
const response = await api.get("/documentos", { params });
|
||||
setDocumentos(response.data);
|
||||
};
|
||||
|
||||
const loadModelos = async () => {
|
||||
const response = await api.get('/documentos-modelos');
|
||||
const response = await api.get("/documentos-modelos");
|
||||
setModelos(response.data);
|
||||
};
|
||||
|
||||
@@ -66,16 +74,16 @@ export function DocumentosPage() {
|
||||
if (processoId) data.processoId = processoId;
|
||||
if (atendimentoId) data.atendimentoId = atendimentoId;
|
||||
|
||||
await api.post('/documentos', data);
|
||||
toast.success('Documento salvo com sucesso');
|
||||
await api.post("/documentos", data);
|
||||
toast.success("Documento salvo com sucesso");
|
||||
await loadDocumentos();
|
||||
setIsEditorOpen(false);
|
||||
} catch (error) {
|
||||
console.error('Erro ao salvar documento:', error);
|
||||
console.error("Erro ao salvar documento:", error);
|
||||
if (error?.response?.status === 401) {
|
||||
toast.error('Sessão expirada. Por favor, faça login novamente.');
|
||||
toast.error("Sessão expirada. Por favor, faça login novamente.");
|
||||
} else {
|
||||
toast.error('Erro ao salvar documento');
|
||||
toast.error("Erro ao salvar documento");
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -83,30 +91,30 @@ export function DocumentosPage() {
|
||||
const handleDeleteDocumento = async (id) => {
|
||||
try {
|
||||
await api.delete(`/documentos/${id}`);
|
||||
toast.success('Documento excluído com sucesso');
|
||||
toast.success("Documento excluído com sucesso");
|
||||
await loadDocumentos();
|
||||
} catch (error) {
|
||||
console.error('Erro ao excluir documento:', error);
|
||||
console.error("Erro ao excluir documento:", error);
|
||||
if (error?.response?.status === 401) {
|
||||
toast.error('Sessão expirada. Por favor, faça login novamente.');
|
||||
toast.error("Sessão expirada. Por favor, faça login novamente.");
|
||||
} else {
|
||||
toast.error('Erro ao excluir documento');
|
||||
toast.error("Erro ao excluir documento");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleVisualizar = async (documento) => {
|
||||
try {
|
||||
const configRes = await api.get('/documentos/configuracoes');
|
||||
|
||||
const configRes = await api.get("/documentos/configuracoes");
|
||||
|
||||
setDocumentoVisualizado({
|
||||
...documento,
|
||||
escritorio: configRes.data
|
||||
escritorio: configRes.data,
|
||||
});
|
||||
setVisualizadorOpen(true);
|
||||
} catch (error) {
|
||||
console.error('Erro ao visualizar documento:', error);
|
||||
toast.error('Erro ao visualizar documento');
|
||||
console.error("Erro ao visualizar documento:", error);
|
||||
toast.error("Erro ao visualizar documento");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -126,17 +134,17 @@ export function DocumentosPage() {
|
||||
<PlusIcon className="w-5 h-5 mr-2" />
|
||||
Novo Documento
|
||||
</button>
|
||||
{user?.perfil === 'ADVOGADO_ADMIN' && (
|
||||
{user?.perfil === "ADVOGADO_ADMIN" && (
|
||||
<>
|
||||
<button
|
||||
onClick={() => navigate('/documentos/templates')}
|
||||
onClick={() => navigate("/documentos/templates")}
|
||||
className="inline-flex items-center px-4 py-2 border border-blue-600 text-blue-600 rounded-md hover:bg-blue-50 transition-colors"
|
||||
>
|
||||
<DocumentIcon className="w-5 h-5 mr-2" />
|
||||
Gerenciar Templates
|
||||
</button>
|
||||
<button
|
||||
onClick={() => navigate('/documentos/configuracoes')}
|
||||
onClick={() => navigate("/documentos/configuracoes")}
|
||||
className="inline-flex items-center px-4 py-2 border border-blue-600 text-blue-600 rounded-md hover:bg-blue-50 transition-colors"
|
||||
>
|
||||
<CogIcon className="w-5 h-5 mr-2" />
|
||||
@@ -153,8 +161,8 @@ export function DocumentosPage() {
|
||||
onClick={() => setTabValue(0)}
|
||||
className={`px-4 py-2 font-medium text-sm border-b-2 transition-colors duration-200 ${
|
||||
tabValue === 0
|
||||
? 'border-blue-500 text-blue-600'
|
||||
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
|
||||
? "border-blue-500 text-blue-600"
|
||||
: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"
|
||||
}`}
|
||||
>
|
||||
Documentos
|
||||
@@ -163,8 +171,8 @@ export function DocumentosPage() {
|
||||
onClick={() => setTabValue(1)}
|
||||
className={`ml-8 px-4 py-2 font-medium text-sm border-b-2 transition-colors duration-200 ${
|
||||
tabValue === 1
|
||||
? 'border-blue-500 text-blue-600'
|
||||
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
|
||||
? "border-blue-500 text-blue-600"
|
||||
: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"
|
||||
}`}
|
||||
>
|
||||
Modelos
|
||||
@@ -175,11 +183,16 @@ export function DocumentosPage() {
|
||||
{tabValue === 0 && (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{documentos.map((doc) => (
|
||||
<div key={doc.id} className="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden">
|
||||
<div
|
||||
key={doc.id}
|
||||
className="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden"
|
||||
>
|
||||
<div className="p-4">
|
||||
<div className="flex items-center mb-3">
|
||||
<DocumentIcon className="w-6 h-6 text-gray-500 mr-2" />
|
||||
<h3 className="font-semibold text-gray-900 dark:text-gray-100">{doc.nome}</h3>
|
||||
<h3 className="font-semibold text-gray-900 dark:text-gray-100">
|
||||
{doc.nome}
|
||||
</h3>
|
||||
</div>
|
||||
<p className="text-sm text-gray-600 dark:text-gray-400">
|
||||
Criado em: {new Date(doc.criadoEm).toLocaleDateString()}
|
||||
@@ -209,16 +222,21 @@ export function DocumentosPage() {
|
||||
{tabValue === 1 && (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{modelos.map((modelo) => (
|
||||
<div key={modelo.id} className="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden">
|
||||
<div
|
||||
key={modelo.id}
|
||||
className="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden"
|
||||
>
|
||||
<div className="p-4">
|
||||
<div className="flex items-center mb-3">
|
||||
<DocumentIcon className="w-6 h-6 text-gray-500 mr-2" />
|
||||
<h3 className="font-semibold text-gray-900 dark:text-gray-100">{modelo.nome}</h3>
|
||||
<h3 className="font-semibold text-gray-900 dark:text-gray-100">
|
||||
{modelo.nome}
|
||||
</h3>
|
||||
</div>
|
||||
<p className="text-sm text-gray-600 dark:text-gray-400 mb-4">{modelo.descricao}</p>
|
||||
<button
|
||||
className="w-full inline-flex items-center justify-center px-4 py-2 text-sm border border-blue-600 text-blue-600 rounded-md hover:bg-blue-50 dark:hover:bg-blue-900/20"
|
||||
>
|
||||
<p className="text-sm text-gray-600 dark:text-gray-400 mb-4">
|
||||
{modelo.descricao}
|
||||
</p>
|
||||
<button className="w-full inline-flex items-center justify-center px-4 py-2 text-sm border border-blue-600 text-blue-600 rounded-md hover:bg-blue-50 dark:hover:bg-blue-900/20">
|
||||
Usar Modelo
|
||||
</button>
|
||||
</div>
|
||||
@@ -242,4 +260,4 @@ export function DocumentosPage() {
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user