import React, { useState } from 'react' import LevelBadge from '../xp/LevelBadge' import CommentForm from './CommentForm' function CommentItem({ comment, canReply, onReply, onDelete, onReport }) { const [replying, setReplying] = useState(false) return (
{comment.user?.display
{comment.user?.profile_url ? ( {comment.user.display} ) : ( {comment.user?.display || 'User'} )} {comment.time_ago}
{canReply ? ( ) : null} {comment.can_delete ? ( ) : null} {comment.can_report ? ( ) : null}
{replying ? (
setReplying(false)} onSubmit={async (content) => { await onReply?.(comment.id, content) setReplying(false) }} />
) : null} {Array.isArray(comment.replies) && comment.replies.length > 0 ? (
{comment.replies.map((reply) => ( ))}
) : null}
) } export default function CommentList({ comments = [], canReply = false, onReply, onDelete, onReport, emptyMessage = 'No comments yet.' }) { if (!comments.length) { return

{emptyMessage}

} return (
{comments.map((comment) => ( ))}
) }