-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.html
More file actions
262 lines (231 loc) · 10.2 KB
/
Copy pathprofile.html
File metadata and controls
262 lines (231 loc) · 10.2 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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Profile - Student Portal</title>
<link rel="stylesheet" href="css/base.css">
<link rel="stylesheet" href="css/navigation.css">
<link rel="stylesheet" href="css/components.css">
<link rel="stylesheet" href="css/pages.css">
<link rel="stylesheet" href="css/responsive.css">
<link rel="stylesheet" href="css/animations.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
</head>
<body>
<!-- Navigation -->
<nav class="navbar">
<div class="nav-container">
<div class="nav-logo">
<h2><i class="fas fa-graduation-cap"></i> Belgium Campus iTversity</h2>
</div>
<ul class="nav-menu">
<li class="nav-item">
<a href="index.html" class="nav-link">Home</a>
</li>
<li class="nav-item">
<a href="index.html#hackathons" class="nav-link">Hackathons</a>
</li>
<li class="nav-item">
<a href="dashboard.html" class="nav-link active">Student Portal</a>
</li>
</ul>
<div class="hamburger">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</div>
</div>
</nav>
<!-- Profile Page -->
<section id="profile" class="page active">
<div class="container">
<div class="page-header">
<a href="dashboard.html" class="btn btn-secondary">
<i class="fas fa-arrow-left"></i> Back to Dashboard
</a>
<h1>My Profile</h1>
</div>
<div class="portal-content">
<h2>Account Information</h2>
<div class="hackathon-card">
<h3>Profile Details</h3>
<div class="profile-info">
<div class="info-row">
<label>Email:</label>
<span id="profile-email">-</span>
</div>
<div class="info-row">
<label>Student ID:</label>
<span id="profile-student-id">-</span>
</div>
<div class="info-row">
<label>Member Since:</label>
<span id="profile-join-date">-</span>
</div>
<div class="info-row">
<label>Account Status:</label>
<span class="status active">Active</span>
</div>
</div>
</div>
<div class="hackathon-card">
<h3>Activity Summary</h3>
<div class="activity-stats">
<div class="stat-item">
<i class="fas fa-trophy"></i>
<div class="stat-content">
<h4 id="profile-hackathons">0</h4>
<p>Hackathons Participated</p>
</div>
</div>
<div class="stat-item">
<i class="fas fa-upload"></i>
<div class="stat-content">
<h4 id="profile-submissions">0</h4>
<p>Projects Submitted</p>
</div>
</div>
<div class="stat-item">
<i class="fas fa-award"></i>
<div class="stat-content">
<h4 id="profile-awards">0</h4>
<p>Awards Won</p>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Footer -->
<footer class="site-footer">
<div class="container">
<div class="footer-grid">
<div class="footer-brand">
<h3><i class="fas fa-graduation-cap"></i> Belgium Campus iTversity</h3>
<p>Building innovation and collaboration through hackathons.</p>
</div>
<div class="footer-links">
<h4>Explore</h4>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="index.html#hackathons">Hackathons</a></li>
<li><a href="dashboard.html">Student Portal</a></li>
</ul>
</div>
<div class="footer-contact">
<h4>Contact</h4>
<p>Email: 601681@student.belgiumcampus.ac.za</p>
<p>© <span id="year"></span> Belgium Campus iTversity</p>
</div>
</div>
</div>
</footer>
<script src="js/navigation.js"></script>
<script src="js/auth.js"></script>
<script src="js/utils.js"></script>
<script>
document.getElementById('year').textContent = new Date().getFullYear();
// Global variables
let currentUser = null;
// Initialize the page
document.addEventListener('DOMContentLoaded', function() {
initializeProfile();
});
// Initialize profile page
async function initializeProfile() {
console.log('Initializing profile page...');
// Check authentication
const authResult = await checkAuthStatus();
console.log('Auth check result:', authResult);
if (!authResult.authenticated) {
console.log('User not authenticated, redirecting to login...');
window.location.href = 'login.html';
return;
}
currentUser = authResult.user;
console.log('User authenticated:', currentUser);
// Load profile data
loadProfileData();
}
// Load profile data from server
async function loadProfileData() {
try {
console.log('Loading profile data...');
// Update profile information
updateProfileInfo(currentUser);
// Load user statistics
await loadUserStats();
} catch (error) {
console.error('Error loading profile data:', error);
if (typeof showNotification === 'function') {
showNotification('Error loading profile data. Please try again.', 'error');
}
}
}
// Update profile information display
function updateProfileInfo(user) {
const emailElement = document.getElementById('profile-email');
const studentIdElement = document.getElementById('profile-student-id');
const joinDateElement = document.getElementById('profile-join-date');
if (emailElement) emailElement.textContent = user.email || 'Not available';
if (studentIdElement) studentIdElement.textContent = user.studentId || 'Not available';
if (joinDateElement) joinDateElement.textContent = formatJoinDate(user.createdAt);
}
// Format join date
function formatJoinDate(dateString) {
if (!dateString) return 'Not available';
try {
const date = new Date(dateString);
return date.toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
});
} catch (error) {
console.error('Error formatting date:', error);
return 'Not available';
}
}
// Load user statistics
async function loadUserStats() {
try {
console.log('Loading user statistics...');
// Load submissions count
const submissionsResponse = await fetch('server/submissions.php?action=user_submissions&user_email=' + encodeURIComponent(currentUser.email));
const submissionsData = await submissionsResponse.json();
// Load registrations count
const registrationsResponse = await fetch('server/hackathon-registrations.php?action=get_user_registrations&userEmail=' + encodeURIComponent(currentUser.email));
const registrationsData = await registrationsResponse.json();
console.log('Submissions data:', submissionsData);
console.log('Registrations data:', registrationsData);
// Update statistics
updateProfileStats(
registrationsData.registrations?.length || 0,
submissionsData.submissions?.length || 0,
0 // Awards - to be implemented later
);
} catch (error) {
console.error('Error loading user stats:', error);
// Set defaults to 0
updateProfileStats(0, 0, 0);
}
}
// Update profile statistics display
function updateProfileStats(hackathonsCount, submissionsCount, awardsCount) {
const hackathonsElement = document.getElementById('profile-hackathons');
const submissionsElement = document.getElementById('profile-submissions');
const awardsElement = document.getElementById('profile-awards');
if (hackathonsElement) hackathonsElement.textContent = hackathonsCount;
if (submissionsElement) submissionsElement.textContent = submissionsCount;
if (awardsElement) awardsElement.textContent = awardsCount;
console.log('Updated profile stats:', {
hackathons: hackathonsCount,
submissions: submissionsCount,
awards: awardsCount
});
}
</script>
</body>
</html>