feat(UserManagement): añadido buscador y funcionalidad para buscar usuarios

parent 2ef4e016
Showing with 30 additions and 2 deletions
......@@ -23,6 +23,9 @@
entradas
</label>
</div>
<div class="d-flex" style="width: 330px;">
<input class="form-control me-2" type="search" placeholder="Buscar por nombre o email..." aria-label="Search" v-model="searchQuery" @input="handleSearch"/>
</div>
</div>
<div v-if="errorMsg" class="alert alert-danger" role="alert">
......@@ -134,10 +137,12 @@ const errorMsg = ref(null);
const userToChangeId = ref(null);
const modalMessage = ref('');
let modalInstance = null;
const actionType = ref('');
const roleToChangeTo = ref('');
// Variable para la búsqueda
const searchQuery = ref('');
onMounted(async () => {
errorMsg.value = null;
try {
......@@ -150,7 +155,11 @@ onMounted(async () => {
// Cambip de página
const goToPage = (page) => {
userStore.readAll(page, userStore.pageSize, userStore.sortBy, userStore.sortDirection);
if (searchQuery.value) {
userStore.search(searchQuery.value, page, userStore.pageSize);
} else {
userStore.readAll(page, userStore.pageSize, userStore.sortBy, userStore.sortDirection);
}
};
// Cambio de ordenación
......@@ -247,6 +256,19 @@ const handleConfirmation = async () => {
}
}
};
// Función para la búsqueda
let searchTimeout = null;
const handleSearch = () => {
clearTimeout(searchTimeout);
searchTimeout = setTimeout(() => {
if (searchQuery.value === '') {
userStore.readAll(0, userStore.pageSize, userStore.sortBy, userStore.sortDirection);
} else {
userStore.search(searchQuery.value, 0, userStore.pageSize);
}
}, 500); // Pequeño retraso para evitar peticiones constantes
};
</script>
<style scoped>
......@@ -301,4 +323,9 @@ const handleConfirmation = async () => {
.pagination-custom .page-item.disabled .page-link {
color: #bbb;
}
.form-control:focus {
border-color: #793E6C;
box-shadow: 0 0 0 0.25rem rgba(121, 62, 108, 0.25);
}
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment