import React, { useRef, useState } from 'react' const DEFAULT_AVATAR = 'https://files.skinbase.org/default/avatar_default.webp' function CommentItem({ comment }) { return (
{comment.author_name} { e.target.src = DEFAULT_AVATAR }} loading="lazy" />
{comment.author_name} {(() => { try { const d = new Date(comment.created_at) const diff = Date.now() - d.getTime() const mins = Math.floor(diff / 60000) if (mins < 1) return 'just now' if (mins < 60) return `${mins}m ago` const hrs = Math.floor(mins / 60) if (hrs < 24) return `${hrs}h ago` const days = Math.floor(hrs / 24) if (days < 30) return `${days}d ago` return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }) } catch { return '' } })()}

{comment.body}

{comment.author_signature && (

{comment.author_signature}

)}
) } /** * TabActivity * Profile comments list + comment form for authenticated visitors. * Also acts as "Activity" tab. */ export default function TabActivity({ profileComments, user, isOwner, isLoggedIn }) { const uname = user.username || user.name const formRef = useRef(null) const [submitted, setSubmitted] = useState(false) return (

Comments {profileComments?.length > 0 && ( {profileComments.length} )}

{/* Comments list */}
{!profileComments?.length ? (

No comments yet. Be the first to leave one!

) : (
{profileComments.map((comment) => ( ))}
)}
{/* Comment form */} {!isOwner && (

Write a Comment

{isLoggedIn ? ( submitted ? (
Your comment has been posted!
) : (
setSubmitted(false)} > document.querySelector('meta[name="csrf-token"]')?.content ?? '')() } />