more qol
All checks were successful
Build Images and Deploy / Update-PROD-Stack (push) Successful in 32s

This commit is contained in:
2026-01-30 17:53:55 -05:00
parent 7c674b07c6
commit 480ad66376
2 changed files with 6 additions and 5 deletions

View File

@@ -59,7 +59,8 @@ router.get('/', authMiddleware, asyncHandler(async (req, res) => {
const challengeFriends = await query( const challengeFriends = await query(
`SELECT DISTINCT `SELECT DISTINCT
u.id, u.username, u.email, 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 FROM users u
WHERE u.id IN ( WHERE u.id IN (
SELECT DISTINCT cp.user_id SELECT DISTINCT cp.user_id
@@ -79,7 +80,7 @@ router.get('/', authMiddleware, asyncHandler(async (req, res) => {
) )
${notInClause} ${notInClause}
ORDER BY u.username`, 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({ res.json({

View File

@@ -281,12 +281,12 @@ export default function Friends() {
</div> </div>
<div style={{ display: 'flex', gap: '0.5rem', alignItems: 'center', flexShrink: 0, flexWrap: 'nowrap' }}> <div style={{ display: 'flex', gap: '0.5rem', alignItems: 'center', flexShrink: 0, flexWrap: 'nowrap' }}>
<button <button
className="btn btn-primary btn-sm" className={`btn btn-sm ${friend.friendship_status === 'pending' ? 'btn-secondary' : 'btn-primary'}`}
onClick={() => handleSendRequest(friend.id)} onClick={() => handleSendRequest(friend.id)}
disabled={sending === friend.id} disabled={sending === friend.id || friend.friendship_status === 'pending'}
style={{ flexShrink: 0 }} style={{ flexShrink: 0 }}
> >
{sending === friend.id ? 'Sending...' : 'Add Friend'} {sending === friend.id ? 'Sending...' : friend.friendship_status === 'pending' ? 'Pending' : 'Add Friend'}
</button> </button>
<div style={{ color: 'var(--primary)', whiteSpace: 'nowrap' }}>{friend.total_points} points</div> <div style={{ color: 'var(--primary)', whiteSpace: 'nowrap' }}>{friend.total_points} points</div>
</div> </div>