File size: 6,827 Bytes
0658440
 
 
 
 
 
 
e0cbd77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0658440
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e0cbd77
 
0658440
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e0cbd77
 
0658440
 
 
 
 
 
 
 
 
 
 
 
 
e0cbd77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0658440
 
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Data View | DataVault Pro</title>
    <link rel="stylesheet" href="style.css">
    <script src="https://cdn.tailwindcss.com">
        // Fetch report details data
        async function loadReportDetails() {
            try {
                const response = await fetch('https://jsonplaceholder.typicode.com/comments');
                const comments = await response.json();
                
                const detailsTable = document.querySelectorAll('.data-table')[1];
                const tableBody = detailsTable.querySelector('tbody');
                tableBody.innerHTML = '';
                
                // Format and display the data
                comments.slice(0, 5).forEach(comment => {
                    const status = ['In Stock', 'Low Stock', 'Out of Stock'][Math.floor(Math.random() * 3)];
                    const statusClass = {
                        'In Stock': 'bg-green-100 text-green-800',
                        'Low Stock': 'bg-yellow-100 text-yellow-800',
                        'Out of Stock': 'bg-red-100 text-red-800'
                    }[status];
                    
                    const row = document.createElement('tr');
                    row.innerHTML = `
                        <td>${comment.id}</td>
                        <td>${comment.name.split(' ')[0]} Product</td>
                        <td>${comment.email.split('@')[0]}</td>
                        <td>${Math.floor(Math.random() * 500)}</td>
                        <td>${(Math.random() * 100).toFixed(2)}</td>
                        <td><span class="px-2 py-1 ${statusClass} text-xs rounded-full">${status}</span></td>
                    `;
                    tableBody.appendChild(row);
                });
            } catch (error) {
                console.error('Error loading report details:', error);
            }
        }
        
        loadReportDetails();
    </script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    <script src="https://unpkg.com/feather-icons"></script>
</head>
<body class="bg-gray-50 min-h-screen">
    <custom-navbar></custom-navbar>
    
    <main class="container mx-auto px-4 py-8">
        <div class="max-w-6xl mx-auto">
            <div class="bg-white rounded-lg shadow-sm p-6 mb-8">
                <div class="flex justify-between items-center mb-6">
                    <div class="flex items-center">
                        <i data-feather="database" class="text-blue-600 mr-3"></i>
                        <h1 class="text-2xl font-semibold text-gray-800">Data Reports</h1>
                    </div>
                    <div class="text-sm text-gray-500">
                        Last updated: <span id="last-updated">Loading...</span>
                    </div>
                </div>
                
                <div class="overflow-x-auto">
                    <table class="data-table w-full">
                        <thead>
                            <tr>
                                <th>Report ID</th>
                                <th>Report Name</th>
                                <th>Category</th>
                                <th>Date</th>
                                <th>Records</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <!-- Reports will be loaded dynamically -->
</tbody>
                    </table>
                </div>
            </div>
            
            <div class="bg-white rounded-lg shadow-sm p-6">
                <h2 class="text-lg font-medium text-gray-800 mb-4 flex items-center">
                    <i data-feather="file-text" class="text-gray-600 mr-2"></i> Report Details
                </h2>
                
                <div class="overflow-x-auto">
                    <table class="data-table w-full">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>Product</th>
                                <th>Category</th>
                                <th>Qty</th>
                                <th>Price</th>
                                <th>Status</th>
                            </tr>
                        </thead>
                        <tbody>
                            <!-- Report details will be loaded dynamically -->
</tbody>
                    </table>
                </div>
            </div>
        </div>
    </main>
    
    <custom-footer></custom-footer>
    
    <script src="components/navbar.js"></script>
    <script src="components/footer.js"></script>
    <script src="script.js"></script>
    <script>
        feather.replace();
        
        // Fetch reports data from API
        async function loadReports() {
            try {
                const response = await fetch('https://jsonplaceholder.typicode.com/posts');
                const reports = await response.json();
                
                const tableBody = document.querySelector('.data-table tbody');
                tableBody.innerHTML = '';
                
                // Format and display the data
                reports.slice(0, 5).forEach(report => {
                    const row = document.createElement('tr');
                    row.innerHTML = `
                        <td>RPT-${report.id}</td>
                        <td>${report.title}</td>
                        <td>${report.userId === 1 ? 'Finance' : report.userId === 2 ? 'Marketing' : 'Operations'}</td>
                        <td>2023-${Math.floor(Math.random() * 12) + 1}-${Math.floor(Math.random() * 28) + 1}</td>
                        <td>${Math.floor(Math.random() * 5000) + 100}</td>
                        <td>
                            <a href="/report-detail.html?id=RPT-${report.id}" class="text-blue-600 hover:text-blue-800 flex items-center">
                                <i data-feather="eye" class="w-4 h-4 mr-1"></i> View
                            </a>
                        </td>
                    `;
                    tableBody.appendChild(row);
                });
                
                // Update last updated time
                document.getElementById('last-updated').textContent = new Date().toLocaleString();
                feather.replace();
            } catch (error) {
                console.error('Error loading reports:', error);
                document.getElementById('last-updated').textContent = 'Error loading data';
            }
        }
        
        loadReports();
</script>
</body>
</html>