User weight updates after session
This commit is contained in:
@@ -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' });
|
||||
|
||||
Reference in New Issue
Block a user