-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.html
More file actions
47 lines (45 loc) · 1.61 KB
/
Copy pathdashboard.html
File metadata and controls
47 lines (45 loc) · 1.61 KB
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
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>داشبورد دانشجو</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<h1>داشبورد دانشجو</h1>
<button onclick="toggleDarkMode()">تغییر تم</button>
<button id="logoutBtn">خروج</button>
<div id="loading" style="display: none;">در حال بارگذاری...</div>
<div id="userInfo"></div>
<div class="quick-links">
<a href="books.html" class="btn btn-primary">مشاهده کتابها</a>
<a href="my-loans.html" class="btn btn-primary">امانتهای من</a>
</div>
</div>
<script src="js/utils.js"></script>
<script src="js/auth.js"></script>
<script>
if (!checkAuth()) return;
document.getElementById('logoutBtn').addEventListener('click', logout);
async function fetchUserInfo() {
showLoading('loading');
try {
const user = await apiRequest('/auth/me');
const stats = await apiRequest('/stats');
document.getElementById('userInfo').innerHTML = `
<p>نام: ${user.name || 'دانشجو'}</p>
<p>امانتهای فعال: ${stats.activeLoans || 0}</p>
<p>کتابهای موجود: ${stats.availableBooks || 0}</p>
`;
} catch (e) {
showToast('خطا در بارگذاری اطلاعات', 'error');
} finally {
document.getElementById('loading').style.display = 'none';
}
}
fetchUserInfo();
</script>
</body>
</html>