import { useState } from "react"; export const NOTES_MAX_LENGTH = 1000; interface OrderNotesProps { notes: string; onSave: (notes: string) => Promise; } export function OrderNotesPanel({ notes, onSave }: OrderNotesProps) { const [draft, setDraft] = useState(notes); const [isSaving, setIsSaving] = useState(false); const trimmed = draft.trim(); const isDisabled = isSaving || trimmed.length === 0 || trimmed === notes; async function handleSave() { if (isDisabled) { return; } setIsSaving(true); try { await onSave(trimmed); } finally { setIsSaving(false); } } return (

Internal notes

{draft.length}/{NOTES_MAX_LENGTH}
{notes ? (

{notes}

) : (

No internal notes yet. Add context for teammates following up on this order.

)}