import { useComments } from '@/hooks/useComments'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Skeleton } from '@/components/ui/skeleton'; import { MessageSquare } from 'lucide-react'; import { cn } from '@/lib/utils'; import type { NostrEvent } from '@nostrify/nostrify'; import { CommentForm } from './CommentForm'; import { Comment } from './Comment'; interface CommentsSectionProps { root: NostrEvent | URL; title?: string; emptyStateMessage?: string; emptyStateSubtitle?: string; className?: string; limit?: number; } export function CommentsSection({ root, title = "Comments", emptyStateMessage = "No comments yet", emptyStateSubtitle = "Be the first to share your thoughts!", className, limit = 500, }: CommentsSectionProps) { const { data: commentsData, isLoading, error } = useComments(root, limit); const comments = commentsData?.topLevelComments || []; if (error) { return ( Failed to load comments ); } return ( {title} {!isLoading && ( ({comments.length}) )} {/* Comment Form */} {/* Comments List */} {isLoading ? ( {[...Array(3)].map((_, i) => ( ))} ) : comments.length === 0 ? ( {emptyStateMessage} {emptyStateSubtitle} ) : ( {comments.map((comment) => ( ))} )} ); }
Failed to load comments
{emptyStateMessage}
{emptyStateSubtitle}