'use client'; import {useState} from 'react'; import Image from 'next/image'; import {UserProfile} from '@/lib/atproto'; import {ChevronDownIcon, ChevronUpIcon} from '@heroicons/react/24/solid'; interface UserListProps { users: UserProfile[]; } export function UserList({users}: UserListProps) { const [isExpanded, setIsExpanded] = useState(false); const INITIAL_COUNT = 8; const displayedUsers = isExpanded ? users : users.slice(0, INITIAL_COUNT); const hasMore = users.length > INITIAL_COUNT; const colors = [ 'bg-red-400', 'bg-blue-400', 'bg-yellow-400', 'bg-green-400', 'bg-purple-400', 'bg-pink-400', 'bg-orange-400', 'bg-cyan-400', ]; return (
{displayedUsers.map((user, index) => { const isInvalidHandle = user.handle.endsWith('.invalid') || user.handle === user.did; const bskyAppUrlRaw = process.env.NEXT_PUBLIC_BSKY_APP_URL || 'https://bsky.app'; const bskyAppUrl = bskyAppUrlRaw.startsWith('http') ? bskyAppUrlRaw : `https://${bskyAppUrlRaw}`; const profileUrl = isInvalidHandle ? `${bskyAppUrl}/profile/${user.did}` : `${bskyAppUrl}/profile/${user.handle}`; const avatarInitial = isInvalidHandle ? '⚠️' : user.handle[0]?.toUpperCase() || '?'; return (
{user.avatar ? ( {isInvalidHandle ) : (
{avatarInitial}
)}

{user.displayName || user.handle} {!isInvalidHandle && user.verified && (user.trustedVerifier ? ( ) : ( ))}

{isInvalidHandle ? '⚠️ Invalid Handle' : `@${user.handle}`}

); })}
{hasMore && (
)}
); }