diff --git a/src/components/ui/mark-ready-dialog.tsx b/src/components/ui/mark-ready-dialog.tsx new file mode 100644 index 0000000..394d8fe --- /dev/null +++ b/src/components/ui/mark-ready-dialog.tsx @@ -0,0 +1,128 @@ +"use client"; + +import { useState } from "react"; +import { Loader2 } from "lucide-react"; + +import { Button } from "@/components/ui/button"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog"; +import { Textarea } from "@/components/ui/textarea"; + +/** + * Modal that asks the operator for a free-text note before marking a + * collection-pool row ready. The note is required (non-empty after + * trim) and is saved into `OrderItem.notes` by the server route. We + * also surface a small "Notes" chip on the row whenever the row has + * any notes, so the operator can see at a glance whether they've + * already written something. + * + * The submit button is disabled until the textarea is non-empty. + * Whitespace-only content is treated as empty for the disabled + * state and the server validation. + */ +export interface MarkReadyDialogProps { + open: boolean; + /** PO number + item description, formatted for the title. */ + poLabel: string; + /** Item description, formatted for the title. */ + itemLabel: string; + /** Any pre-existing note (not currently used; reserved for edit flows). */ + initialNote?: string; + busy?: boolean; + serverError?: string | null; + onOpenChange: (open: boolean) => void; + onSubmit: (note: string) => void; +} + +export function MarkReadyDialog({ + open, + poLabel, + itemLabel, + initialNote = "", + busy = false, + serverError = null, + onOpenChange, + onSubmit, +}: MarkReadyDialogProps) { + const [note, setNote] = useState(initialNote); + const trimmed = note.trim(); + const canSubmit = trimmed.length > 0 && !busy; + + return ( + { + if (!busy) { + if (!o) setNote(""); + onOpenChange(o); + } + }} + > + + + + Mark ready: {poLabel} · {itemLabel} + + + Add a note for the audit log. Required. + + +
+