Refactor invoice loading and search functionality for improved performance and user experience
This commit is contained in:
parent
810dbd7781
commit
aa8f049444
|
|
@ -183,16 +183,15 @@ export function renderFacturasPage() {
|
|||
|
||||
const searchInput = container.querySelector('.search-input');
|
||||
searchInput.addEventListener('input', (e) => {
|
||||
const inputValue = e.target.value;
|
||||
const inputValue = e.target.value.trim();
|
||||
// Debounce para no hacer muchas llamadas
|
||||
clearTimeout(searchInput.debounceTimer);
|
||||
searchInput.debounceTimer = setTimeout(() => {
|
||||
// Solo aplicar búsqueda si contiene al menos un número
|
||||
const hasNumber = /\d/.test(inputValue);
|
||||
if (hasNumber && inputValue !== 'I' && inputValue !== 'IN' && inputValue !== 'N') {
|
||||
// Validación mínima: al menos 2 caracteres para activar búsqueda
|
||||
if (inputValue.length >= 2) {
|
||||
searchTerm = inputValue;
|
||||
} else {
|
||||
searchTerm = ''; // Si no tiene número, mostrar todas
|
||||
searchTerm = ''; // Si es muy corto, mostrar todas
|
||||
}
|
||||
applyFilters();
|
||||
}, 500); // Espera 500ms después de que el usuario deja de escribir
|
||||
|
|
|
|||
Loading…
Reference in New Issue