File size: 2,036 Bytes
bc2f68f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Initialize tooltips
document.addEventListener('DOMContentLoaded', function() {
    // Initialize any tooltip libraries if needed
    feather.replace();
    
    // Sample data fetching - would be replaced with real API calls
    async function fetchDashboardData() {
        try {
            // This would be replaced with actual API endpoint
            // const response = await fetch('/api/dashboard');
            // const data = await response.json();
            // return data;
            
            // Mock data for demonstration
            return {
                totalFiles: 1248,
                activeFirms: 87,
                medianTimeToValue: 4.2,
                probateMetrics: {
                    withContacts: 78,
                    withDisbursements: 65,
                    withDocuments: 52,
                    withDownloads: 43
                },
                accountingMetrics: {
                    withInventory: 82,
                    withTransactions: 76,
                    withParser: 58,
                    withReports: 39
                }
            };
        } catch (error) {
            console.error('Error fetching dashboard data:', error);
            return null;
        }
    }
    
    // Load data when page loads
    fetchDashboardData().then(data => {
        if (data) {
            console.log('Dashboard data loaded:', data);
            // Here you would update the DOM with the actual data
        }
    });
    
    // Responsive menu toggle for mobile (handled by components)
});

// Event delegation for dynamic elements
document.addEventListener('click', function(e) {
    // Handle clicks on dynamically added elements
    if (e.target.classList.contains('toggle-details')) {
        const details = e.target.nextElementSibling;
        details.classList.toggle('hidden');
        e.target.querySelector('i').setAttribute('data-feather', 
            details.classList.contains('hidden') ? 'chevron-down' : 'chevron-up');
        feather.replace();
    }
});