'use client' import { usePresence } from '@/hooks/usePresence' interface OnlineIndicatorProps { userId: string size?: 'sm' | 'md' } const SIZE_CLASSES: Record, string> = { sm: 'w-2.5 h-2.5', md: 'w-3.5 h-3.5', } export function OnlineIndicator({ userId, size = 'sm' }: OnlineIndicatorProps) { const { onlineUsers } = usePresence() const isOnline = onlineUsers.some((u) => u.id === userId) if (!isOnline) return null return ( ) } // Avatar wrapper with online badge — preserved for existing usages interface AvatarWithOnlineStatusProps { userId: string avatar?: string username: string size?: number showOnlineStatus?: boolean } export function AvatarWithOnlineStatus({ userId, avatar, username, size = 40, showOnlineStatus = true, }: AvatarWithOnlineStatusProps) { const { onlineUsers } = usePresence() const isOnline = showOnlineStatus && onlineUsers.some((u) => u.id === userId) return (
{avatar ? ( {username} ) : (
{username?.[0]?.toUpperCase() ?? '?'}
)} {showOnlineStatus && ( )}
) } export default OnlineIndicator