feature/T2026-05-031-y-T2026-05-030 #25
11
src/App.jsx
11
src/App.jsx
@@ -14,6 +14,7 @@ import LandingAnimated from './pages/LandingAnimated';
|
||||
import Expedientes from './pages/Expedientes';
|
||||
import Organization from './pages/Organization';
|
||||
import Users from './pages/Users';
|
||||
import UserForm from './pages/UserForm';
|
||||
import Reports from './pages/Reports';
|
||||
import Settings from './pages/Settings';
|
||||
import Importers from './pages/Importers';
|
||||
@@ -76,6 +77,16 @@ function AppContent() {
|
||||
<Users />
|
||||
</RequireAuth>
|
||||
} />
|
||||
<Route path="/users/new" element={
|
||||
<RequireAuth>
|
||||
<UserForm />
|
||||
</RequireAuth>
|
||||
} />
|
||||
<Route path="/users/:id/edit" element={
|
||||
<RequireAuth>
|
||||
<UserForm />
|
||||
</RequireAuth>
|
||||
} />
|
||||
<Route path="/reports" element={
|
||||
<RequireAuth>
|
||||
<Reports />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { fetchUsers, createUser, updateUser, deleteUser, getCurrentUser } from '../api/users.ts';
|
||||
import { useNotification } from '../context/NotificationContext';
|
||||
|
||||
@@ -47,6 +48,7 @@ export default function Users() {
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [itemsPerPage, setItemsPerPage] = useState(10);
|
||||
const { showMessage } = useNotification();
|
||||
const navigate = useNavigate();
|
||||
|
||||
// Estados para validación de contraseña
|
||||
const [passwordValidation, setPasswordValidation] = useState({
|
||||
@@ -552,44 +554,17 @@ export default function Users() {
|
||||
</div>
|
||||
<div className="flex flex-col sm:flex-row gap-2 sm:gap-3">
|
||||
<button
|
||||
onClick={() => { setShowCreateModal(true); setCreateType('agente'); }}
|
||||
onClick={() => navigate('/users/new')}
|
||||
type="button"
|
||||
className="inline-flex items-center justify-center px-4 py-2 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-700 hover:to-blue-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all duration-200 transform hover:scale-105"
|
||||
>
|
||||
<svg className="-ml-1 mr-2 h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
|
||||
</svg>
|
||||
<span className="hidden sm:inline">Nuevo Agente</span>
|
||||
<span className="sm:hidden">Agente</span>
|
||||
</button>
|
||||
<button
|
||||
onClick={async () => {
|
||||
setCreateType('importador');
|
||||
// Fetch importadores RFC
|
||||
try {
|
||||
const res = await fetch(`${import.meta.env.VITE_EFC_API_URL}/customs/importadores/`, { method: 'GET', headers: { 'Authorization': `Bearer ${localStorage.getItem('access')}` } });
|
||||
const data = await res.json();
|
||||
if (Array.isArray(data)) {
|
||||
setImportadores(data);
|
||||
} else {
|
||||
setImportadores([]);
|
||||
}
|
||||
} catch {
|
||||
setImportadores([]);
|
||||
}
|
||||
setShowCreateModal(true);
|
||||
}}
|
||||
type="button"
|
||||
className="inline-flex items-center justify-center px-4 py-2 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-gradient-to-r from-green-600 to-green-700 hover:from-green-700 hover:to-green-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 transition-all duration-200 transform hover:scale-105"
|
||||
>
|
||||
<svg className="-ml-1 mr-2 h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
|
||||
</svg>
|
||||
<span className="hidden sm:inline">Nuevo Importador</span>
|
||||
<span className="sm:hidden">Importador</span>
|
||||
<span className="hidden sm:inline">Nuevo Usuario</span>
|
||||
<span className="sm:hidden">Usuario</span>
|
||||
</button>
|
||||
</div>
|
||||
{/* Modal para crear usuario (agente o importador) eliminado */}
|
||||
</div>
|
||||
|
||||
{/* Filtros avanzados */}
|
||||
@@ -777,6 +752,16 @@ export default function Users() {
|
||||
</td>
|
||||
<td className="px-6 py-4 whitespace-nowrap text-center">
|
||||
<div className="flex justify-center space-x-2">
|
||||
<button
|
||||
onClick={() => navigate(`/users/${user.id}/edit`)}
|
||||
className="inline-flex items-center px-3 py-1.5 border border-blue-300 shadow-sm text-xs font-medium rounded-lg text-blue-700 bg-white hover:bg-blue-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all duration-200 transform hover:scale-105"
|
||||
title="Editar usuario"
|
||||
>
|
||||
<svg className="w-4 h-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
|
||||
</svg>
|
||||
Editar
|
||||
</button>
|
||||
<button
|
||||
onClick={() => { setShowDeleteModal(true); setUserToDelete(user); }}
|
||||
disabled={user.username === localStorage.getItem('username')}
|
||||
@@ -874,16 +859,27 @@ export default function Users() {
|
||||
<div className="text-xs text-gray-500 mt-1">ID: {user.id}</div>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => { setShowDeleteModal(true); setUserToDelete(user); }}
|
||||
disabled={user.username === localStorage.getItem('username')}
|
||||
className={`inline-flex items-center px-3 py-2 border border-red-300 shadow-sm text-xs font-medium rounded-lg text-red-700 bg-white hover:bg-red-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 transition-all duration-200 ${user.username === localStorage.getItem('username') ? 'opacity-50 cursor-not-allowed' : ''}`}
|
||||
title={user.username === localStorage.getItem('username') ? 'No puedes eliminar tu propia cuenta' : 'Eliminar usuario'}
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
|
||||
</svg>
|
||||
</button>
|
||||
<div className="flex items-center gap-2">
|
||||
<button
|
||||
onClick={() => navigate(`/users/${user.id}/edit`)}
|
||||
className="inline-flex items-center px-3 py-2 border border-blue-300 shadow-sm text-xs font-medium rounded-lg text-blue-700 bg-white hover:bg-blue-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all duration-200"
|
||||
title="Editar usuario"
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
onClick={() => { setShowDeleteModal(true); setUserToDelete(user); }}
|
||||
disabled={user.username === localStorage.getItem('username')}
|
||||
className={`inline-flex items-center px-3 py-2 border border-red-300 shadow-sm text-xs font-medium rounded-lg text-red-700 bg-white hover:bg-red-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 transition-all duration-200 ${user.username === localStorage.getItem('username') ? 'opacity-50 cursor-not-allowed' : ''}`}
|
||||
title={user.username === localStorage.getItem('username') ? 'No puedes eliminar tu propia cuenta' : 'Eliminar usuario'}
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-4 text-xs">
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user