diff --git a/src/app/(app)/delivery-notes/page.tsx b/src/app/(app)/delivery-notes/page.tsx index fb43279..06fca07 100644 --- a/src/app/(app)/delivery-notes/page.tsx +++ b/src/app/(app)/delivery-notes/page.tsx @@ -952,7 +952,8 @@ export default function DeliveryNotesPage() { // Slot 1 — "Create quote", or the quote itself once it // exists. The popup means she never leaves this list to // read a quote. - "delivery-note": () => openNoteEditor(note), + "delivery-note": () => setPreviewDnNumber(note.delivery_note_number), + "edit-delivery-note": () => openNoteEditor(note), "create-quote": () => openQuoteReview(note), "preview-quote": () => quote && setPreviewQuote(quote), // Slot 2 — send, in a modal on this screen. @@ -1786,11 +1787,15 @@ export default function DeliveryNotesPage() { onOpenChange={(v) => setNoteEditor((prev) => ({ ...prev, open: v }))} deliveryNoteId={noteEditor.noteId} deliveryNoteNumber={noteEditor.number} - onSaved={() => { + onSaved={(dnNumber) => { setNoteEditor((prev) => ({ ...prev, open: false })); // Refresh so the next quote review starts from what was - // just saved rather than the values fetched at page load. - void fetchNotes(); + // just saved rather than the values fetched at page load, + // then bring the document back — "save, and show me what + // I just saved". + void fetchNotes().then(() => { + if (dnNumber) setPreviewDnNumber(dnNumber); + }); }} /> )} diff --git a/src/components/delivery-notes/action-buttons.tsx b/src/components/delivery-notes/action-buttons.tsx index 44a0661..cb6e4d4 100644 --- a/src/components/delivery-notes/action-buttons.tsx +++ b/src/components/delivery-notes/action-buttons.tsx @@ -50,6 +50,7 @@ import type { DeliveryNote, DeliveryNoteStatus } from "@/lib/types"; */ export type DnActionId = | "delivery-note" + | "edit-delivery-note" | "create-quote" | "open-quote" | "preview-dn" @@ -259,22 +260,37 @@ function FlowControl({ return (
- {/* Slot 0 — edit the delivery note itself: quantities, costs, - margins. Sits FIRST on purpose: the quote is priced from the - DN's lines, so anything wrong here becomes a wrong number on - a customer-facing document. Fix it at the source. */} + {/* Slot 0 — the delivery note DOCUMENT: click to open the PDF + and print it, exactly like the quote link. Editing is one + click further, via "Edit items" — so the common case (print + the note, or look at what it says) doesn't open an editor. */} + {/* The editor. Adjacent rather than nested so the order is + visible without opening anything: document, edit it, quote + it. */} + + {/* Slot 1 — the thing to do next. Quote link once it exists. */} {hasQuote ? ( + {/* Close without saving, but still show the document — + most times someone opens this to LOOK, not change. */} +