diff --git a/frontend/src/pages/Friends.jsx b/frontend/src/pages/Friends.jsx index 3dc3a3d..fdd7c5e 100644 --- a/frontend/src/pages/Friends.jsx +++ b/frontend/src/pages/Friends.jsx @@ -14,6 +14,7 @@ export default function Friends() { const [searchTimeout, setSearchTimeout] = useState(null); const [responding, setResponding] = useState(null); const [sending, setSending] = useState(null); + const [removing, setRemoving] = useState(null); const { socket } = useSocket(); const searchRef = useRef(null); @@ -119,6 +120,23 @@ export default function Friends() { } }; + const handleRemoveFriend = async (friendId, friendName) => { + if (!confirm(`Are you sure you want to remove ${friendName} from your friends?`)) { + return; + } + + setRemoving(friendId); + try { + await api.removeFriend(friendId); + toast.success('Friend removed'); + await loadData(); + } catch (err) { + toast.error('Failed to remove friend: ' + err.message); + } finally { + setRemoving(null); + } + }; + if (loading) { return
Loading...
; } @@ -221,12 +239,21 @@ export default function Friends() { ) : (
{friends.map(friend => ( -
+
{friend.username}
{friend.email}
-
{friend.total_points} points
+
+
{friend.total_points} points
+ +
))} {challengeFriends.length > 0 && ( @@ -237,12 +264,21 @@ export default function Friends() {
{challengeFriends.map(friend => ( -
+
{friend.username}
{friend.email}
-
{friend.total_points} points
+
+
{friend.total_points} points
+ +
))}