dashboard: reimaginacao
Signed-off-by: Rodrigo B. de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
80df7310f3
commit
4d22c07151
2 files changed
+48
No files matched your search
@@ -2,11 +2,29 @@ import React from 'react';
|
|||||||
import { useAuth } from '../../contexts/AuthContext';
|
import { useAuth } from '../../contexts/AuthContext';
|
||||||
import { useTarefas } from '../../hooks/useTarefas';
|
import { useTarefas } from '../../hooks/useTarefas';
|
||||||
import { Tarefa } from '../../types/entities';
|
import { Tarefa } from '../../types/entities';
|
||||||
|
import { PencilIcon, TrashIcon } from '@heroicons/react/24/outline';
|
||||||
|
|
||||||
export const WorkflowTarefas: React.FC = () => {
|
export const WorkflowTarefas: React.FC = () => {
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
const { tarefas, isLoading, deleteTarefa } = useTarefas();
|
const { tarefas, isLoading, deleteTarefa } = useTarefas();
|
||||||
|
|
||||||
|
const canDelete = user && ['ADVOGADO_ADMIN', 'ADVOGADO'].includes(user.perfil);
|
||||||
|
|
||||||
|
const handleEdit = (tarefa: Tarefa) => {
|
||||||
|
// Implemente a lógica de edição conforme necessário
|
||||||
|
alert(`Editar tarefa: ${tarefa.titulo}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDelete = async (id: string) => {
|
||||||
|
if (!window.confirm('Tem certeza que deseja excluir esta tarefa?')) return;
|
||||||
|
try {
|
||||||
|
await deleteTarefa.mutateAsync(id);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erro ao excluir tarefa:', error);
|
||||||
|
alert('Erro ao excluir tarefa');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="bg-white dark:bg-gray-800 shadow rounded-lg p-4 text-center text-gray-500 dark:text-gray-400">
|
<div className="bg-white dark:bg-gray-800 shadow rounded-lg p-4 text-center text-gray-500 dark:text-gray-400">
|
||||||
@@ -33,6 +51,24 @@ export const WorkflowTarefas: React.FC = () => {
|
|||||||
}`}>
|
}`}>
|
||||||
{tarefa.status.replace('_', ' ')}
|
{tarefa.status.replace('_', ' ')}
|
||||||
</span>
|
</span>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<button
|
||||||
|
onClick={() => handleEdit(tarefa)}
|
||||||
|
className="text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300"
|
||||||
|
title="Editar"
|
||||||
|
>
|
||||||
|
<PencilIcon className="h-5 w-5" />
|
||||||
|
</button>
|
||||||
|
{canDelete && (
|
||||||
|
<button
|
||||||
|
onClick={() => handleDelete(tarefa.id)}
|
||||||
|
className="text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300"
|
||||||
|
title="Excluir"
|
||||||
|
>
|
||||||
|
<TrashIcon className="h-5 w-5" />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -168,6 +168,18 @@ export const TarefaModal: React.FC<TarefaModalProps> = ({ isOpen, onClose, taref
|
|||||||
<option value="URGENTE">Urgente</option>
|
<option value="URGENTE">Urgente</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
{/* Campo para alterar o status da tarefa conforme banco de dados */}
|
||||||
|
<select
|
||||||
|
{...register('status')}
|
||||||
|
className="w-full p-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"
|
||||||
|
>
|
||||||
|
<option value="PENDENTE">Pendente</option>
|
||||||
|
{/* Exibe 'Em andamento' sem underline */}
|
||||||
|
<option value="EM_ANDAMENTO">Em andamento</option>
|
||||||
|
<option value="CONCLUIDA">Concluída</option>
|
||||||
|
<option value="CANCELADA">Cancelada</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
<select
|
<select
|
||||||
{...register('responsavelId')}
|
{...register('responsavelId')}
|
||||||
className="w-full p-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"
|
className="w-full p-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"
|
||||||
|
|||||||
Reference in new issue
Block a user