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 543be76..b6bcb13 100644 --- a/index.html +++ b/index.html @@ -62,7 +62,7 @@

StudyPlan

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

StudyPlan

+ + + @@ -382,8 +438,9 @@

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 diff --git a/server.js b/server.js index c09dbc7..97a86e6 100644 --- a/server.js +++ b/server.js @@ -527,7 +527,7 @@ app.post('/api/auth/signup', (req, res) => { 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) => {