User weight updates after session

This commit is contained in:
AG
2025-11-20 23:37:13 +02:00
parent 12a79ae642
commit 20ec84bd97
3 changed files with 21 additions and 0 deletions

View File

@@ -101,8 +101,28 @@ router.post('/', async (req: any, res) => {
},
include: { sets: true }
});
// Update user profile weight if session has weight and is finished
if (weight && end) {
await prisma.userProfile.upsert({
where: { userId },
create: { userId, weight },
update: { weight }
});
}
return res.json(created);
}
// Update user profile weight if session has weight and is finished (for update case too)
if (weight && end) {
await prisma.userProfile.upsert({
where: { userId },
create: { userId, weight },
update: { weight }
});
}
} catch (error) {
console.error(error);
res.status(500).json({ error: 'Server error' });