import React from 'react' function timeAgo(dateStr) { if (!dateStr) return '' const date = new Date(dateStr) const seconds = Math.floor((Date.now() - date.getTime()) / 1000) if (seconds < 60) return 'just now' const minutes = Math.floor(seconds / 60) if (minutes < 60) return `${minutes}m ago` const hours = Math.floor(minutes / 60) if (hours < 24) return `${hours}h ago` const days = Math.floor(hours / 24) if (days < 365) return `${days}d ago` return date.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' }) } function Avatar({ user, size = 36 }) { if (user?.avatar_url) { return ( ) } const initials = (user?.name || user?.username || '?').slice(0, 1).toUpperCase() return ( {initials} ) } export default function ArtworkComments({ comments = [] }) { if (!comments || comments.length === 0) return null return ( Comments{' '} ({comments.length}) {comments.map((comment) => ( {comment.user?.profile_url ? ( ) : ( )} {comment.user?.profile_url ? ( {comment.user.name || comment.user.username || 'Member'} ) : ( {comment.user?.name || comment.user?.username || 'Member'} )} {timeAgo(comment.created_at)} {comment.content} ))} ) }
{comment.content}