-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.html
More file actions
320 lines (289 loc) · 18.7 KB
/
Copy pathprofile.html
File metadata and controls
320 lines (289 loc) · 18.7 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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
<!DOCTYPE html>
<html lang="en" class="scroll-smooth">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>StudySync | Profile</title>
<link rel="icon" type="image/png" href="Image_Folder/Logo.png">
<script src="https://cdn.tailwindcss.com"></script>
<script src="js/api.js"></script>
<script src="js/reminder.js"></script>
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: { colors: { study: '#2F2E80', sync: '#00B4BE' } }
}
}
// Apply theme immediately to prevent flicker
function applyTheme() {
if (localStorage.getItem('theme') === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
}
applyTheme();
(async () => {
const user = await requireLogin();
if (user) {
// Function to start the dashboard
const startApp = () => {
initProfile(user);
};
// If DOM is already loaded, run immediately. Otherwise, wait for it.
if (document.readyState === "loading") {
window.addEventListener('DOMContentLoaded', startApp);
} else {
startApp();
}
} else {
console.error("Auth failed or no user found.");
}
})();
</script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap" rel="stylesheet">
<style>
body { font-family: 'Inter', sans-serif; }
.main-scrollbar::-webkit-scrollbar { width: 4px; }
.main-scrollbar::-webkit-scrollbar-thumb { background: #00B4BE; border-radius: 10px; }
#sidebar { transition: width 0.3s ease; }
input:focus, select:focus {
outline: none;
box-shadow: 0 0 0 2px #00B4BE;
border-color: transparent;
}
</style>
</head>
<body class="bg-slate-50 dark:bg-[#020617] text-slate-800 dark:text-slate-200 overflow-hidden transition-colors duration-300">
<!-- TOP NAVBAR -->
<header class="h-16 w-full bg-white dark:bg-[#0b1120] border-b border-slate-200 dark:border-white/5 flex items-center justify-between px-6 fixed top-0 z-[60]">
<div class="flex items-center gap-4">
<button onclick="toggleSidebar()" class="p-2 rounded-lg text-slate-500 hover:text-sync transition">
<i class="fas fa-bars"></i>
</button>
<div class="flex items-center gap-2">
<img src="Image_Folder/Logo.png" class="h-8 w-auto">
<span class="font-black text-xl tracking-tighter">
<span class="text-[#2F2E80] dark:text-indigo-400">Study</span><span class="text-[#00B4BE]">Sync</span>
</span>
</div>
</div>
<div class="flex items-center gap-4">
<!-- NOTIFICATION BELL -->
<div class="relative">
<button onclick="toggleReminderDropdown()" class="p-2 w-10 h-10 rounded-full bg-slate-100 dark:bg-white/5 transition flex items-center justify-center relative hover:text-sync">
<i class="fas fa-bell text-sm text-slate-400"></i>
<!-- Fixed ID: matching the script -->
<span id="active-reminder-dot" class="hidden absolute top-2 right-2.5 w-2 h-2 bg-rose-500 rounded-full border-2 border-white dark:border-[#0b1120]"></span>
</button>
<!-- DROPDOWN -->
<div id="reminder-dropdown" class="hidden absolute right-0 mt-3 w-72 bg-white dark:bg-[#0b1120] rounded-[1.5rem] shadow-2xl border border-slate-100 dark:border-white/5 z-[100] overflow-hidden" onclick="event.stopPropagation()">
<div class="p-4 border-b dark:border-white/5 bg-slate-50/50 dark:bg-white/5 flex justify-between items-center">
<h4 class="text-[10px] font-black uppercase tracking-widest text-slate-400">Upcoming Alerts</h4>
<button onclick="toggleReminderSound()" id="sound-toggle-btn" class="text-slate-400 hover:text-sync transition">
<i class="fas fa-volume-up text-xs"></i>
</button>
</div>
<div id="reminder-list" class="max-h-80 overflow-y-auto main-scrollbar p-2 space-y-2">
<p class="text-center py-8 text-[10px] text-slate-400 italic">No tasks with reminders for today.</p>
</div>
</div>
</div>
<button onclick="toggleDarkMode()" class="p-2 w-10 h-10 rounded-full bg-slate-100 dark:bg-white/5 transition flex items-center justify-center">
<i class="fas fa-moon dark:hidden"></i>
<i class="fas fa-sun hidden dark:block text-amber-400"></i>
</button>
<div class="flex items-center gap-3 border-l pl-4 dark:border-white/10">
<div class="text-right hidden sm:block">
<p class="sidebar-username text-xs font-bold leading-none">User</p>
<p class="text-[9px] text-sync font-bold uppercase mt-1">Active Profile</p>
</div>
<div class="sidebar-avatar w-10 h-10 rounded-xl bg-sync text-white flex items-center justify-center font-black shadow-lg">U</div>
</div>
</div>
</header>
<div class="flex pt-16 h-screen">
<!-- SIDEBAR -->
<aside id="sidebar" class="w-64 bg-white dark:bg-[#0b1120] border-r border-slate-200 dark:border-white/5 flex flex-col shrink-0">
<nav class="flex-1 px-4 overflow-y-auto main-scrollbar py-6 space-y-1">
<p class="px-4 text-[10px] font-black text-slate-400 uppercase tracking-widest mb-2">Workspace</p>
<button onclick="window.location.href='dashboard.html'" class="w-full flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium text-slate-500 hover:text-sync hover:bg-slate-50 dark:hover:bg-white/5 transition-all">
<i class="fas fa-home"></i> <span>Home</span>
</button>
<p class="px-4 text-[10px] font-black text-slate-400 uppercase tracking-widest mb-2 pt-4">Schedule View</p>
<div class="p-1 bg-slate-100 dark:bg-white/5 rounded-2xl flex flex-col gap-1">
<button onclick="window.location.href='dashboard.html'" class="flex items-center gap-3 px-4 py-2 rounded-xl text-xs font-bold transition-all text-slate-500 hover:text-sync">
<i class="fas fa-list"></i> Day Timeline
</button>
<button onclick="window.location.href='dashboard.html'" class="flex items-center gap-3 px-4 py-2 rounded-xl text-xs font-bold transition-all text-slate-500 hover:text-sync">
<i class="fas fa-calendar-week"></i> Week View
</button>
<button onclick="window.location.href='dashboard.html'" class="flex items-center gap-3 px-4 py-2 rounded-xl text-xs font-bold transition-all text-slate-500 hover:text-sync">
<i class="fas fa-th-large"></i> Month Grid
</button>
</div>
<p class="px-4 text-[10px] font-black text-slate-400 uppercase tracking-widest mb-2 pt-4">Actions</p>
<button onclick="window.location.href='taskscheduler.html'" class="w-full flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium text-slate-500 hover:text-sync hover:bg-slate-50 dark:hover:bg-white/5 transition-all">
<i class="fas fa-plus-circle"></i> <span>Add New Task</span>
</button>
<button onclick="window.location.href='taskscheduler.html'" class="w-full flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium text-slate-500 hover:text-sync hover:bg-slate-50 dark:hover:bg-white/5 transition-all">
<i class="fas fa-tasks"></i> <span>Task Scheduler</span>
</button>
<p class="px-4 text-[10px] font-black text-slate-400 uppercase tracking-widest mb-2 pt-4">Insights</p>
<button onclick="window.location.href='progress.html'" class="w-full flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium text-slate-500 hover:text-sync hover:bg-slate-50 dark:hover:bg-white/5 transition-all">
<i class="fas fa-chart-pie"></i> <span>Progress Report</span>
</button>
<button onclick="window.location.href='notes.html'" class="w-full flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium text-slate-500 hover:text-sync hover:bg-slate-50 dark:hover:bg-white/5 transition-all">
<i class="fas fa-sticky-note"></i> <span>My Notes</span>
</button>
</button>
<button class="w-full flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-bold bg-sync/10 text-sync">
<i class="fas fa-user"></i> <span>Profile</span>
</button>
<div class="pt-6">
<button onclick="handleLogout()" class="w-full flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-bold text-rose-500 hover:bg-rose-500/10 transition-all">
<i class="fas fa-power-off"></i> <span>Sign Out</span>
</button>
</div>
</nav>
</aside>
<!-- MAIN CONTENT -->
<main class="flex-1 overflow-y-auto main-scrollbar p-6 lg:p-8 bg-slate-50 dark:bg-[#020617]">
<div class="max-w-4xl mx-auto space-y-8 pb-20">
<h2 class="text-3xl font-black px-2 tracking-tight">Account Settings</h2>
<!-- PERSONAL INFO FORM -->
<section class="bg-white dark:bg-[#0b1120] rounded-[2rem] border border-slate-200 dark:border-white/5 shadow-sm overflow-hidden">
<div class="p-6 border-b border-slate-100 dark:border-white/5 bg-slate-50/50 dark:bg-white/5 flex items-center justify-between">
<h3 class="font-bold text-xs uppercase tracking-[0.2em] text-slate-400">Identity & Capacity</h3>
</div>
<form id="profileForm" class="p-8 space-y-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Full Name</label>
<input id="edit-name" type="text" class="w-full p-4 bg-slate-50 dark:bg-white/5 border border-slate-100 dark:border-white/5 rounded-2xl font-bold text-sm">
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Email Address</label>
<input id="edit-email" type="email" class="w-full p-4 bg-slate-50 dark:bg-white/5 border border-slate-100 dark:border-white/5 rounded-2xl font-bold text-sm">
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Daily Study Hours</label>
<input id="edit-capacity" type="number" min="1" max="24" class="w-full p-4 bg-slate-50 dark:bg-white/5 border border-slate-100 dark:border-white/5 rounded-2xl font-bold text-sm">
</div>
</div>
<div class="flex justify-end pt-4">
<button type="submit" class="bg-sync text-white px-8 py-2 rounded-2xl font-black shadow-lg shadow-sync/20 hover:scale-105 transition-all">Save Profile</button>
</div>
</form>
</section>
<!-- PASSWORD SECTION -->
<section class="bg-white dark:bg-[#0b1120] rounded-[2rem] border border-slate-200 dark:border-white/5 shadow-sm overflow-hidden">
<div class="p-6 border-b border-slate-100 dark:border-white/5 bg-slate-50/50 dark:bg-white/5">
<h3 class="font-bold text-xs uppercase tracking-[0.2em] text-slate-400">Security & Credentials</h3>
</div>
<form id="passwordForm" class="p-8 space-y-6">
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Current Password</label>
<input id="pass-current" type="password" class="w-full p-4 bg-slate-50 dark:bg-white/5 border border-slate-100 dark:border-white/5 rounded-2xl text-sm">
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">New Password</label>
<input id="pass-new" type="password" class="w-full p-4 bg-slate-50 dark:bg-white/5 border border-slate-100 dark:border-white/5 rounded-2xl text-sm">
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Confirm New</label>
<input id="pass-confirm" type="password" class="w-full p-4 bg-slate-50 dark:bg-white/5 border border-slate-100 dark:border-white/5 rounded-2xl text-sm">
</div>
</div>
<div class="flex justify-end pt-4">
<button type="submit" class="bg-study text-white px-8 py-2 rounded-2xl font-black shadow-lg hover:scale-105 transition-all">Update Password</button>
</div>
</form>
</section>
<!-- DANGER ZONE -->
<section class="rounded-[2rem] border border-rose-100 dark:border-rose-900/20 bg-rose-50/30 dark:bg-rose-900/5 p-8 flex flex-col md:flex-row items-center justify-between gap-6">
<div class="text-center md:text-left">
<h4 class="text-rose-600 font-bold text-lg">Permanently Delete Account</h4>
<p class="text-slate-500 dark:text-slate-400 text-sm mt-1">This will remove all your tasks, streaks, and data forever.</p>
</div>
<button onclick="deleteAccount()" class="bg-rose-500 text-white px-8 py-2 rounded-2xl font-black hover:bg-rose-600 transition shadow-lg shadow-rose-500/50">Delete Forever</button>
</section>
</div>
</main>
</div>
<script>
function toggleSidebar() {
const sb = document.getElementById('sidebar');
sb.classList.toggle('hidden');
}
function toggleDarkMode() {
if (document.documentElement.classList.contains('dark')) {
document.documentElement.classList.remove('dark');
localStorage.setItem('theme', 'light');
} else {
document.documentElement.classList.add('dark');
localStorage.setItem('theme', 'dark');
}
}
async function initProfile(user) {
populateSidebar(user);
// Pre-fill existing data
document.getElementById('edit-name').value = user.full_name || '';
document.getElementById('edit-email').value = user.email || '';
document.getElementById('edit-capacity').value = user.daily_capacity || 4;
}
// --- Update Profile AJAX ---
document.getElementById('profileForm').onsubmit = async (e) => {
e.preventDefault();
const data = {
full_name: document.getElementById('edit-name').value,
email: document.getElementById('edit-email').value,
daily_capacity: document.getElementById('edit-capacity').value
};
const res = await API.updateProfile(data);
if(res.success) {
showToast("Identity Updated!");
// Refresh sidebar name
const userRes = await API.getMe();
if(userRes.success) populateSidebar(userRes.data);
} else {
showToast(res.message, "error");
}
};
// --- Change Password AJAX ---
document.getElementById('passwordForm').onsubmit = async (e) => {
e.preventDefault();
const current = document.getElementById('pass-current').value;
const newPass = document.getElementById('pass-new').value;
const confirm = document.getElementById('pass-confirm').value;
if(!current || !newPass) return showToast("Fields required", "error");
if(newPass !== confirm) return showToast("Passwords don't match", "error");
const res = await API.changePassword({ current_password: current, new_password: newPass });
if(res.success) {
showToast("Security updated!");
e.target.reset();
} else {
showToast(res.message, "error");
}
};
async function deleteAccount() {
if (confirm("WARNING: Are you sure? This will delete all your study data forever.")) {
const res = await API.deleteAccount();
if (res.success) {
alert("Account deleted.");
window.location.href = "index.html";
} else {
alert(res.message);
}
}
}
async function handleLogout() {
await API.logout();
window.location.href = "index.html";
}
</script>
</body>
</html>