"use client" import * as React from "react" import { CheckIcon, PenEditIcon, TrashIcon, XmarkIcon } from "../icons-v2-generated" import { cn } from "../../utils/cn" import { Input } from "./input" import { SquareAvatar } from "./square-avatar" export interface TicketNote { id: string text: string authorName: string authorAvatar?: string createdAt: string isOwn: boolean } export interface TicketNoteCardProps { note: TicketNote onEdit?: (id: string, text: string) => void onDelete?: (id: string) => void className?: string } export function TicketNoteCard({ note, onEdit, onDelete, className }: TicketNoteCardProps) { const [isEditing, setIsEditing] = React.useState(false) const [editText, setEditText] = React.useState(note.text) const handleSave = () => { const trimmed = editText.trim() if (!trimmed || !onEdit) return onEdit(note.id, trimmed) setIsEditing(false) } const handleCancel = () => { setEditText(note.text) setIsEditing(false) } const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault() handleSave() } if (e.key === "Escape") { handleCancel() } } return (
{isEditing ? (
setEditText(e.target.value)} onKeyDown={handleKeyDown} autoFocus />
) : ( <>

{note.text}

{note.authorName} • {note.createdAt}

)}
{note.isOwn && !isEditing && (
{onDelete && ( )} {onEdit && ( )}
)}
) }