feat: Add checkbox selection and bulk operations

- Add checkbox functionality to Expedientes.jsx with bulk document deletion
- Add checkbox functionality to PedimentoDetail.jsx documents table
- Implement custom modal for deletion confirmation with modern UI
- Fix pagination reset on filter changes in Procesos.jsx
- Add bulk selection with 'select all' functionality
- Integrate with /record/documents/bulk-delete/ endpoint
- Improve UX with loading states and success/error messages
This commit is contained in:
2025-10-09 13:01:49 -05:00
parent d09c99f1a9
commit b35c87bd28
3 changed files with 541 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import React, { useEffect, useState, useRef } from 'react';
import { Link } from 'react-router-dom';
import { fetchProcesamientoPedimentos } from '../api/procesos.ts';
import { postWithAuth, putWithAuth } from '../fetchWithAuth';
@@ -40,6 +40,15 @@ export default function Procesos() {
const [selectedProcesos, setSelectedProcesos] = useState([]);
const [isSelectAll, setIsSelectAll] = useState(false);
// Ref para rastrear valores previos de filtros y detectar cambios
const prevFiltersRef = useRef({
pedimentoPedimentoFilter: '',
estadoFilter: '',
servicioFilter: '',
sortField: '',
sortOrder: 'asc'
});
// Función para mostrar toast
const showToast = (type, title, message, details = '', persistent = false, progress = null) => {
const id = Date.now();
@@ -691,6 +700,30 @@ export default function Procesos() {
useEffect(() => {
async function fetchProcesos() {
// Detectar si algún filtro cambió
const currentFilters = {
pedimentoPedimentoFilter,
estadoFilter,
servicioFilter,
sortField,
sortOrder
};
const filtersChanged = Object.keys(currentFilters).some(
key => currentFilters[key] !== prevFiltersRef.current[key]
);
// Si los filtros cambiaron y no estamos en la página 1, resetear página
if (filtersChanged && page !== 1) {
setPage(1);
// Actualizar ref con valores actuales
prevFiltersRef.current = { ...currentFilters };
return; // Salir temprano, el efecto se ejecutará de nuevo con page = 1
}
// Actualizar ref con valores actuales
prevFiltersRef.current = { ...currentFilters };
setLoading(true);
setError('');
try {