diff --git a/backend/src/routes/friends.js b/backend/src/routes/friends.js index 9842778..4c7aea8 100644 --- a/backend/src/routes/friends.js +++ b/backend/src/routes/friends.js @@ -59,7 +59,8 @@ router.get('/', authMiddleware, asyncHandler(async (req, res) => { const challengeFriends = await query( `SELECT DISTINCT u.id, u.username, u.email, - (SELECT COUNT(*) FROM predictions WHERE user_id = u.id AND status = 'validated') as total_points + (SELECT COUNT(*) FROM predictions WHERE user_id = u.id AND status = 'validated') as total_points, + (SELECT status FROM friendships WHERE (user_id = ? AND friend_id = u.id) OR (user_id = u.id AND friend_id = ?) LIMIT 1) as friendship_status FROM users u WHERE u.id IN ( SELECT DISTINCT cp.user_id @@ -79,7 +80,7 @@ router.get('/', authMiddleware, asyncHandler(async (req, res) => { ) ${notInClause} ORDER BY u.username`, - [req.user.userId, req.user.userId, req.user.userId, req.user.userId, req.user.userId, req.user.userId, ...friends.map(f => f.id)] + [req.user.userId, req.user.userId, req.user.userId, req.user.userId, req.user.userId, req.user.userId, req.user.userId, req.user.userId, ...friends.map(f => f.id)] ); res.json({ diff --git a/frontend/src/pages/Friends.jsx b/frontend/src/pages/Friends.jsx index 793a084..b927e80 100644 --- a/frontend/src/pages/Friends.jsx +++ b/frontend/src/pages/Friends.jsx @@ -281,12 +281,12 @@ export default function Friends() {
{friend.total_points} points