"use client"; import { MessageSquarePlus } from "lucide-react"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { CommentComposer } from "../comment-composer/comment-composer"; import { CommentThread } from "../comment-thread/comment-thread"; import type { CommentPanelProps } from "./types"; export function CommentPanel({ threads, members, membersLoading = false, isLoading = false, onCreateComment, onCreateReply, onEditComment, onDeleteComment, isSubmitting = false, maxHeight, variant = "desktop", }: CommentPanelProps) { const [isComposerOpen, setIsComposerOpen] = useState(false); const handleCommentSubmit = (content: string) => { onCreateComment(content); setIsComposerOpen(false); }; const handleComposerCancel = () => { setIsComposerOpen(false); }; const isMobile = variant === "mobile"; if (isLoading) { return (
Loading comments...
); } const hasThreads = threads.length > 0; const showEmptyState = !hasThreads && !isComposerOpen; // Ensure minimum usable height for empty state + composer button const minHeight = 180; const effectiveMaxHeight = maxHeight ? Math.max(maxHeight, minHeight) : undefined; return (
{hasThreads && (
{threads.map((thread) => ( ))}
)} {showEmptyState && (

No comments yet

Start a conversation about this response

)}
{isComposerOpen ? ( ) : ( )}
); }