Repository navigation
feat: allow draft invoice downloads #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,6 +83,12 @@ export default async function InvoicePage({ params }: InvoicePageProps) { | |
| </Button> | ||
| </form> | ||
| <DeleteDraftDialog action={deleteDraftInvoiceAction} invoiceId={invoice.id} /> | ||
| <Button asChild className="text-[13px]" variant="outline"> | ||
| <a href={`/api/invoices/${invoice.id}/pdf`}> | ||
| <Download aria-hidden="true" className="size-[14px]" /> | ||
| Download PDF | ||
| </a> | ||
| </Button> | ||
| <IssueInvoiceDialog action={issueInvoiceAction} invoiceId={invoice.id} /> | ||
| </> | ||
| ) : ( | ||
|
|
@@ -156,7 +162,7 @@ export default async function InvoicePage({ params }: InvoicePageProps) { | |
| <h2 className="text-[14px] font-medium text-foreground">Invoice preview</h2> | ||
| <p className="mt-0.5 text-[12px] text-subtle-foreground">The downloaded PDF uses this same document.</p> | ||
| </div> | ||
| {invoice.lifecycle === "issued" ? ( | ||
| {invoice.lifecycle !== "void" ? ( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a draft has no Useful? React with 👍 / 👎. |
||
| <Button asChild className="rounded-full" size="icon-sm" variant="ghost"> | ||
| <a aria-label="Download invoice PDF" href={`/api/invoices/${invoice.id}/pdf`}> | ||
| <Download aria-hidden="true" className="size-[14px]" /> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every draft maps its missing invoice number to
DRAFT, and the PDF endpoint derivesContent-Dispositionsolely from that value, so all links enabled here download asDRAFT.pdf. When a user exports multiple drafts, clients may overwrite the earlier file or create indistinguishable names such asDRAFT (1).pdf, increasing the chance of sending the wrong invoice; include a stable draft-specific identifier in the filename while retaining theDRAFTlabel inside the document.Useful? React with 👍 / 👎.