"use client"; import { useRef, useState, useCallback } from "react"; import { IconEdit, IconTrash, IconGripHorizontal } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import { cn } from "@/lib/utils"; import type { DiffComment } from "@/lib/diff/types"; import { CommentForm } from "@/components/diff/comment-form"; import { useDraggablePopover, usePopoverDismiss } from "@/components/task/use-draggable-popover"; type CommentViewPopoverProps = { comments: DiffComment[]; position: { x: number; y: number }; onDelete: (commentId: string) => void; onUpdate?: (commentId: string, text: string) => void; onClose: () => void; }; function formatLineRange(start: number, end: number) { return start === end ? `L${start}` : `L${start}-${end}`; } function CommentItem({ comment, onDelete, onUpdate, isEditing, onStartEdit, onCancelEdit, }: { comment: DiffComment; onDelete: (id: string) => void; onUpdate?: (id: string, text: string) => void; isEditing: boolean; onStartEdit: (id: string) => void; onCancelEdit: () => void; }) { const handleUpdate = useCallback( (text: string) => { onUpdate?.(comment.id, text); onCancelEdit(); }, [comment.id, onCancelEdit, onUpdate], ); return (
{comment.codeContent}
)}
{comment.text}
> )}