From 721b40cf6380751d124fd3d94a5ccb8d5f5544cb Mon Sep 17 00:00:00 2001 From: Sonu7430 Date: Tue, 9 Jun 2026 21:56:47 +0530 Subject: [PATCH 1/2] feat: implement full desktop profile page view with stats and subject breakdown --- index.html | 58 +++++++++++++++++++++++- js/app.js | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 188 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 543be76..015c8dc 100644 --- a/index.html +++ b/index.html @@ -62,7 +62,7 @@

StudyPlan

- +
@@ -207,6 +207,62 @@

StudyPlan

+ + + diff --git a/js/app.js b/js/app.js index f69f7f6..0d155eb 100644 --- a/js/app.js +++ b/js/app.js @@ -1097,6 +1097,100 @@ store.subscribe(renderCalendar); store.subscribe(renderFocusTasks); store.subscribe(renderSidebarSubjects); +function updateDesktopProfilePage() { + const userStr = localStorage.getItem('studyplan_user'); + let email = 'guest@example.com'; + if (userStr) { + try { + const user = JSON.parse(userStr); + email = user.email || email; + } catch (e) { + console.error(e); + } + } + + const avatarEl = document.getElementById('desktop-profile-avatar'); + const emailEl = document.getElementById('desktop-profile-email'); + if (emailEl) emailEl.textContent = email; + if (avatarEl && email) { + avatarEl.textContent = email.charAt(0).toUpperCase(); + } + + // Theme + const themeEl = document.getElementById('desktop-profile-theme'); + if (themeEl) { + const isDarkMode = localStorage.getItem('studyplan_dark_mode') === 'true'; + themeEl.textContent = isDarkMode ? 'Dark Mode' : 'Light Mode'; + } + + // Stats + const completedCount = store.tasks.filter(t => t.status === 'Done').length; + const pendingCount = store.tasks.filter(t => t.status !== 'Done' && !t.archived).length; + const totalMins = store.tasks.reduce((acc, t) => acc + (Number(t.estimated_duration) || 0), 0); + + const completedEl = document.getElementById('desktop-profile-completed'); + const pendingEl = document.getElementById('desktop-profile-pending'); + const durationEl = document.getElementById('desktop-profile-duration'); + + if (completedEl) completedEl.textContent = completedCount; + if (pendingEl) pendingEl.textContent = pendingCount; + if (durationEl) durationEl.textContent = formatDuration(totalMins); + + // Subject-wise breakdown + const subjectsListEl = document.getElementById('desktop-profile-subjects-list'); + if (subjectsListEl) { + const subjects = store.subjects; + const tasks = store.tasks; + + if (subjects.length === 0) { + subjectsListEl.innerHTML = '
No subjects defined yet.
'; + return; + } + + const html = subjects.map(sub => { + const subTasks = tasks.filter(t => t.subject_id === sub.id && !t.archived); + const subCompleted = subTasks.filter(t => t.status === 'Done').length; + const subTotal = subTasks.length; + const percent = subTotal > 0 ? Math.round((subCompleted / subTotal) * 100) : 0; + + return ` +
+
+
+ + ${sub.name} +
+ + ${subCompleted}/${subTotal} completed (${percent}%) + +
+
+
+
+
+ `; + }).join(''); + + subjectsListEl.innerHTML = html; + } +} + +store.subscribe(updateDesktopProfilePage); + +function hideProfileSection() { + const profileSection = document.getElementById('profile-section'); + if (profileSection) profileSection.classList.add('hidden'); + + const topbar = document.querySelector('.topbar'); + if (topbar) topbar.style.display = ''; + + const greeting = document.querySelector('.dashboard-greeting'); + if (greeting) greeting.style.display = ''; + + const studyTime = document.getElementById('daily-study-time'); + if (studyTime) studyTime.style.display = ''; +} + document.addEventListener('DOMContentLoaded', () => { if (newSubjectColorsEl) { SUBJECT_COLORS.forEach(c => { @@ -1166,6 +1260,7 @@ document.addEventListener('DOMContentLoaded', () => { calendarBtn.addEventListener('click', () => { currentView = 'calendar'; + hideProfileSection(); document.querySelector('.cal-section').classList.remove('hidden'); document.getElementById('tasks-section').classList.remove('hidden'); document.getElementById('focus-section').classList.add('hidden'); @@ -1175,6 +1270,7 @@ document.addEventListener('DOMContentLoaded', () => { allTasksBtn.addEventListener('click', () => { currentView = 'all-tasks'; + hideProfileSection(); document.querySelector('.cal-section').classList.add('hidden'); document.getElementById('tasks-section').classList.remove('hidden'); document.getElementById('focus-section').classList.add('hidden'); @@ -1184,6 +1280,7 @@ document.addEventListener('DOMContentLoaded', () => { archivedTasksBtn.addEventListener('click', () => { currentView = 'archived'; + hideProfileSection(); document.querySelector('.cal-section').classList.add('hidden'); document.getElementById('tasks-section').classList.remove('hidden'); document.getElementById('focus-section').classList.add('hidden'); @@ -1194,6 +1291,7 @@ document.addEventListener('DOMContentLoaded', () => { if(focusModeBtn) { focusModeBtn.addEventListener('click', () => { currentView = 'focus'; + hideProfileSection(); document.querySelector('.cal-section').classList.add('hidden'); document.getElementById('tasks-section').classList.add('hidden'); document.getElementById('focus-section').classList.remove('hidden'); @@ -1317,6 +1415,39 @@ addItemsBtn.addEventListener('click', () => { pasteInput.value = ''; } }); + + // Profile Section Logic + const profileSection = document.getElementById('profile-section'); + const profileBtn = document.getElementById('profile-btn'); + + if (profileBtn && profileSection) { + profileBtn.addEventListener('click', (e) => { + e.preventDefault(); + currentView = 'profile'; + + // Hide other views + document.querySelector('.cal-section')?.classList.add('hidden'); + document.getElementById('tasks-section')?.classList.add('hidden'); + document.getElementById('focus-section')?.classList.add('hidden'); + + const topbar = document.querySelector('.topbar'); + if (topbar) topbar.style.setProperty('display', 'none', 'important'); + + const greeting = document.querySelector('.dashboard-greeting'); + if (greeting) greeting.style.setProperty('display', 'none', 'important'); + + const studyTime = document.getElementById('daily-study-time'); + if (studyTime) studyTime.style.setProperty('display', 'none', 'important'); + + // Show profile section + profileSection.classList.remove('hidden'); + + // Update sidebar active status to none + document.querySelectorAll('.sidebar .nav-item').forEach(el => el.classList.remove('active')); + + updateDesktopProfilePage(); + }); + } }); // Ensures the button is hidden on initial page load if the textarea is empty From 8e7c084d5af557f6b6fc5a4b5e8f1d66da406ff9 Mon Sep 17 00:00:00 2001 From: Sonu7430 Date: Tue, 9 Jun 2026 22:30:23 +0530 Subject: [PATCH 2/2] fix: profile displays correct logged-in user email after signup --- README.md | 1 + index.html | 17 ++++++++++++++--- server.js | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 73991c1..db242eb 100644 --- a/README.md +++ b/README.md @@ -259,3 +259,4 @@ GitHub: https://github.com/Charushi06 Built with AI, code, and a mission to simplify student life. --- +sonu diff --git a/index.html b/index.html index 015c8dc..b6bcb13 100644 --- a/index.html +++ b/index.html @@ -438,8 +438,9 @@

{ return res.status(400).json({ error: 'User already exists' }); } users[email] = { email, password }; - res.json({ success: true, message: 'Account created successfully' }); + res.json({ success: true, message: 'Account created successfully', email }); }); app.post('/api/auth/login', (req, res) => {