File size: 852 Bytes
58c1398
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
 * Admin Panel - Dashboard Logic
 */

async function loadDashboardStats() {
    try {
        const res = await fetch('/api/admin/stats');
        const stats = await res.json();
        
        document.getElementById('stat-pending-payments').innerText = stats.pending_payments;
        document.getElementById('stat-total-wallet').innerText = `₹${stats.total_wallet_balance}`;
        document.getElementById('stat-open-tickets').innerText = stats.open_tickets;
        document.getElementById('stat-active-users').innerText = stats.active_users;
        
    } catch (e) {
        console.error("Error loading dashboard stats:", e);
    }
}

function refreshDashboard() {
    loadDashboardStats();
    if(typeof showToast === 'function') {
        showToast('success', 'Dashboard Refreshed', 'All data has been updated successfully');
    }
}