/** * @file components/friends/AllFriendsTab.tsx * @description Component rendering the list of all accepted friends along with status indicators, messaging options, and remove actions. */ "use client"; import { MessageSquare, X } from "lucide-react"; import { UserAvatar } from "../ui/UserAvatar"; import { Friendship, FriendUser } from "./FriendsView"; /** * Properties for the AllFriendsTab component. * * @interface AllFriendsTabProps * @property {Friendship[]} acceptedFriends - Array of accepted friendship objects. * @property {(f: Friendship) => FriendUser} getFriendUser - Helper function to retrieve user details from a friendship relationship. * @property {(id: string) => void} onRemove - Callback function to remove a friend by their friendship ID. */ interface AllFriendsTabProps { acceptedFriends: Friendship[]; getFriendUser: (f: Friendship) => FriendUser; onRemove: (id: string) => void; } /** * Renders the list of all accepted friends along with status, message, and remove actions. * * @param {AllFriendsTabProps} props - The component props. * @param {Friendship[]} props.acceptedFriends - Array of accepted friendship objects. * @param {(f: Friendship) => FriendUser} props.getFriendUser - Helper function to extract user details. * @param {(id: string) => void} props.onRemove - Callback function to remove a friend. * @returns {JSX.Element} The rendered list of all accepted friends. */ export function AllFriendsTab({ acceptedFriends, getFriendUser, onRemove, }: AllFriendsTabProps) { return (

All Friends — {acceptedFriends.length}

{acceptedFriends.length === 0 ? (

You have no friends yet.

) : (
{acceptedFriends.map((f) => { const friend = getFriendUser(f); const isOnline = friend.status && friend.status !== "OFFLINE"; return (
{friend.username}
{isOnline ? "Online" : "Offline"}
); })}
)}
); }