Complete UI/UX overhaul: Polished login, fixed mood tracking, enhanced animations, and verified full-stack flows
This commit is contained in:
@@ -98,6 +98,17 @@ db.serialize(() => {
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users (id)
|
||||
)`);
|
||||
|
||||
// Exercise Logs table
|
||||
db.run(`CREATE TABLE IF NOT EXISTS exercise_logs (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
exercise_type TEXT NOT NULL,
|
||||
duration INTEGER NOT NULL,
|
||||
completed BOOLEAN DEFAULT 1,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users (id)
|
||||
)`);
|
||||
});
|
||||
|
||||
// JWT authentication middleware
|
||||
@@ -376,6 +387,27 @@ app.post('/api/gratitude', authenticateToken, (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Log Exercise Session
|
||||
app.post('/api/exercises', authenticateToken, (req, res) => {
|
||||
try {
|
||||
const { exerciseType, duration } = req.body;
|
||||
|
||||
if (!exerciseType || !duration) {
|
||||
return res.status(400).json({ error: 'Type and duration required' });
|
||||
}
|
||||
|
||||
db.run('INSERT INTO exercise_logs (user_id, exercise_type, duration) VALUES (?, ?, ?)',
|
||||
[req.user.id, exerciseType, duration], function(err) {
|
||||
if (err) {
|
||||
return res.status(500).json({ error: 'Database error' });
|
||||
}
|
||||
res.status(201).json({ success: true, id: this.lastID });
|
||||
});
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: 'Server error' });
|
||||
}
|
||||
});
|
||||
|
||||
// Get gratitude entries
|
||||
app.get('/api/gratitude', authenticateToken, (req, res) => {
|
||||
const limit = parseInt(req.query.limit) || 30;
|
||||
@@ -427,8 +459,9 @@ app.get('/api/dashboard/stats', authenticateToken, (req, res) => {
|
||||
db.get(`SELECT
|
||||
(SELECT COUNT(*) FROM mood_entries WHERE user_id = ?) as totalMoods,
|
||||
(SELECT COUNT(*) FROM thoughts WHERE user_id = ?) as totalThoughts,
|
||||
(SELECT COUNT(*) FROM gratitude_entries WHERE user_id = ?) as totalGratitude`,
|
||||
[req.user.id, req.user.id, req.user.id], (err, totals) => {
|
||||
(SELECT COUNT(*) FROM gratitude_entries WHERE user_id = ?) as totalGratitude,
|
||||
(SELECT COUNT(*) FROM exercise_logs WHERE user_id = ?) as totalSessions`,
|
||||
[req.user.id, req.user.id, req.user.id, req.user.id], (err, totals) => {
|
||||
if (err) {
|
||||
return res.status(500).json({ error: 'Database error' });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user