import { Link } from 'react-router-dom'; import Avatar from '../common/Avatar'; import HeatBadges from '../heats/HeatBadges'; /** * Reusable User List Item component * Displays user avatar, username, and optional heats with action button * * @param {object} user - User object with { userId, username, avatar, isOnline, firstName, lastName } * @param {Array} heats - Array of heat objects for this user * @param {boolean} showHeats - Whether to display heat badges (default: true) * @param {React.ReactNode} actionButton - Optional action button/element to display on right * @param {function} onClick - Optional click handler for the entire item * @param {string} className - Additional CSS classes * @param {boolean} linkToProfile - Whether username should link to profile (default: false) * * @example * handleMatch(userId)}> * * * } * /> */ const UserListItem = ({ user, heats = [], showHeats = true, actionButton, onClick, className = '', linkToProfile = false }) => { const hasHeats = heats && heats.length > 0; const isOnline = user?.isOnline ?? false; const usernameClasses = `text-sm font-medium truncate ${ isOnline ? 'text-gray-900' : 'text-gray-500' }`; const usernameContent = linkToProfile ? ( {user.username} ) : (

{user.username}

); return (
{usernameContent} {/* Full name (optional) */} {(user.firstName || user.lastName) && (

{user.firstName} {user.lastName}

)} {/* Heat Badges */} {showHeats && hasHeats && (
)}
{actionButton && (
{actionButton}
)}
); }; export default UserListItem;