mirror of
https://github.com/Alvin-Zilverstand/Challenge_15_Magazijn_App_Maken.git
synced 2026-03-06 13:22:35 +01:00
Add search functionality to admin and student pages
This commit is contained in:
@@ -62,11 +62,15 @@ async function loadReservations() {
|
||||
function filterAndDisplayReservations() {
|
||||
const locationFilter = document.getElementById('locationFilter').value;
|
||||
const statusFilter = document.getElementById('statusFilter').value;
|
||||
const searchTerm = document.getElementById('searchInput').value.toLowerCase();
|
||||
|
||||
const filteredReservations = reservations.filter(reservation => {
|
||||
const locationMatch = locationFilter === 'all' || reservation.location === locationFilter;
|
||||
const statusMatch = statusFilter === 'all' || reservation.status === statusFilter;
|
||||
return locationMatch && statusMatch;
|
||||
const searchMatch = searchTerm === '' ||
|
||||
reservation.itemName.toLowerCase().includes(searchTerm) ||
|
||||
reservation.location.toLowerCase().includes(searchTerm);
|
||||
return locationMatch && statusMatch && searchMatch;
|
||||
});
|
||||
|
||||
const reservationsList = document.getElementById('reservationsList');
|
||||
@@ -171,6 +175,23 @@ function setupEventListeners() {
|
||||
localStorage.clear();
|
||||
window.location.href = '/index.html';
|
||||
});
|
||||
|
||||
// Search functionality
|
||||
const searchInput = document.getElementById('searchInput');
|
||||
const clearSearch = document.getElementById('clearSearch');
|
||||
|
||||
searchInput.addEventListener('input', filterAndDisplayReservations);
|
||||
searchInput.addEventListener('keypress', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
filterAndDisplayReservations();
|
||||
}
|
||||
});
|
||||
|
||||
clearSearch.addEventListener('click', () => {
|
||||
searchInput.value = '';
|
||||
filterAndDisplayReservations();
|
||||
searchInput.focus();
|
||||
});
|
||||
}
|
||||
|
||||
// Auto refresh functionality
|
||||
|
||||
Reference in New Issue
Block a user