diff --git a/dashboard/siro-admin/js/app.js b/dashboard/siro-admin/js/app.js
index be970141..128b5231 100644
--- a/dashboard/siro-admin/js/app.js
+++ b/dashboard/siro-admin/js/app.js
@@ -280,12 +280,96 @@ document.addEventListener('DOMContentLoaded', () => {
}
showNotification('Live Database Stats Synchronized!', 'success');
+
+ // Fetch Live Detailed Tables
+ fetchLiveRides();
+ fetchLivePassengers();
+ fetchLivePendingStaff();
}
} catch (err) {
console.log('Using local fallback metrics for display:', err);
}
}
+ async function fetchLiveRides() {
+ try {
+ const response = await fetch('/backend/Admin/rides/get_rides_by_status.php?status=All', {
+ headers: { 'Authorization': `Bearer ${currentUser?.jwt || ''}` }
+ });
+ const data = await response.json();
+ const rides = Array.isArray(data) ? data : (data.data || []);
+ if (rides.length > 0) {
+ const tbody = document.getElementById('ridesTableBody');
+ if (tbody) {
+ tbody.innerHTML = rides.slice(0, 15).map(r => `
+
+ | SR-${r.id} |
+ ${r.p_fname || 'Passenger'} ${r.p_lname || ''} |
+ ${r.d_fname || 'Driver'} ${r.d_lname || ''} |
+ ${r.address_start || 'Pickup'} → ${r.address_end || 'Dropoff'} |
+ $${r.price || r.price_for_passenger || '0.00'} |
+ ${r.status || 'Active'} |
+ ${r.created_at ? r.created_at.substring(11, 16) : 'Just now'} |
+
+
+ |
+
+ `).join('');
+ }
+ }
+ } catch (err) {
+ console.log('Error fetching live rides:', err);
+ }
+ }
+
+ async function fetchLivePassengers() {
+ try {
+ const response = await fetch('/backend/Admin/getPassengerDetails.php', {
+ headers: { 'Authorization': `Bearer ${currentUser?.jwt || ''}` }
+ });
+ const data = await response.json();
+ const passengers = Array.isArray(data) ? data : (data.data || []);
+ if (passengers.length > 0) {
+ const tbody = document.getElementById('passengersTableBody');
+ if (tbody) {
+ tbody.innerHTML = passengers.slice(0, 15).map(p => `
+
+ | PSG-${p.id} |
+ ${p.first_name || 'Passenger'} ${p.last_name || ''} |
+ ${p.email || p.phone || 'N/A'} |
+ ${p.countPassengerRide || 0} trips |
+ ${p.passengerAverageRating || '5.0'} |
+ ${p.created_at ? p.created_at.substring(0, 10) : 'Jan 2025'} |
+ ${p.status || 'Active'} |
+
+
+ |
+
+ `).join('');
+ }
+ }
+ } catch (err) {
+ console.log('Error fetching live passengers:', err);
+ }
+ }
+
+ async function fetchLivePendingStaff() {
+ try {
+ const response = await fetch('/backend/Admin/Staff/pending.php', {
+ headers: { 'Authorization': `Bearer ${currentUser?.jwt || ''}` }
+ });
+ const data = await response.json();
+ const pending = data?.data || [];
+ if (pending.length > 0) {
+ showNotification(`Notice: You have ${pending.length} pending staff approval requests!`, 'info');
+ }
+ } catch (err) {
+ console.log('Pending staff lookup:', err);
+ }
+ }
+
const fingerprintLoginBtn = document.getElementById('fingerprintLoginBtn');
fingerprintLoginBtn?.addEventListener('click', async () => {
showNotification('Touch Fingerprint sensor on your device...', 'info');