Workout Management tests done

This commit is contained in:
AG
2025-12-09 18:11:55 +02:00
parent f32661d892
commit 2352ac04d6
14 changed files with 557 additions and 67 deletions

Binary file not shown.

View File

@@ -139,30 +139,28 @@ router.patch('/profile', validate(updateProfileSchema), async (req, res) => {
const token = req.headers.authorization?.split(' ')[1];
if (!token) return res.status(401).json({ error: 'Unauthorized' });
const { userId, profile } = req.body;
// const { userId, profile } = req.body;
// Convert birthDate from timestamp to Date object if needed
if (profile.birthDate) {
if (req.body.birthDate) {
// Handle both number (timestamp) and string (ISO)
profile.birthDate = new Date(profile.birthDate);
req.body.birthDate = new Date(req.body.birthDate);
}
// Verify token
const decoded = jwt.verify(token, JWT_SECRET) as any;
if (decoded.userId !== userId) {
return res.status(403).json({ error: 'Forbidden' });
}
const userId = decoded.userId;
// Update or create profile
await prisma.userProfile.upsert({
where: { userId: userId },
update: {
...profile
...req.body
},
create: {
userId: userId,
...profile
...req.body
}
});