"use client" import * as React from "react" import { Send03Icon } from "../icons-v2-generated" import { cn } from "../../utils/cn" import { Input } from "./input" import { type TicketNote, TicketNoteCard } from "./ticket-note-card" export interface TicketNotesSectionProps { notes: TicketNote[] onAddNote?: (text: string) => void onEditNote?: (id: string, text: string) => void onDeleteNote?: (id: string) => void /** Disables the input and send button while a note is being added */ isAddingNote?: boolean className?: string } export function TicketNotesSection({ notes, onAddNote, onEditNote, onDeleteNote, isAddingNote, className, }: TicketNotesSectionProps) { const [noteText, setNoteText] = React.useState("") const handleSend = () => { const trimmed = noteText.trim() if (!trimmed || !onAddNote || isAddingNote) return onAddNote(trimmed) setNoteText("") } const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault() handleSend() } } return (
{notes.map(note => ( ))} {onAddNote && (
setNoteText(e.target.value)} onKeyDown={handleKeyDown} placeholder="Enter your Note Here" disabled={isAddingNote} />
)}
) }