'use client';

import type { PlazaComment } from '@/types/plaza';
import { CommentThread } from '@/components/comment/CommentThread';

type CommentListProps = {
  postId: string;
  comments: PlazaComment[];
  onReply: (comment: PlazaComment) => void;
  onToggleLike: (comment: PlazaComment) => void;
};

export function CommentList({ postId, comments, onReply, onToggleLike }: CommentListProps) {
  if (comments.length === 0) {
    return <p className="py-6 text-center text-sm text-[#8a928c]">暂无评论，来抢沙发吧</p>;
  }

  return (
    <ul className="divide-y divide-[#ebe4d6]">
      {comments.map((comment) => (
        <li key={comment.id} className="py-4">
          <CommentThread
            postId={postId}
            comment={comment}
            onReply={onReply}
            onToggleLike={onToggleLike}
          />
        </li>
      ))}
    </ul>
  );
}
