From c7ac82d6eab9bd1984791e70c4922a438e99972b Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Mon, 27 Feb 2023 12:45:32 +0100 Subject: [PATCH] Redirect to the newly created invoice on add It makes more sense to see the invoice once created than to return to the list of invoices and having to look for it. --- pkg/invoices.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/invoices.go b/pkg/invoices.go index a40a9be..759df22 100644 --- a/pkg/invoices.go +++ b/pkg/invoices.go @@ -270,8 +270,8 @@ func HandleAddInvoice(w http.ResponseWriter, r *http.Request, _ httprouter.Param mustRenderNewInvoiceForm(w, r, form) return } - conn.MustExec(r.Context(), "select add_invoice($1, $2, $3, $4, $5, $6)", company.Id, form.Number, form.Date, form.Customer, form.Notes, NewInvoiceProductArray(form.Products)) - http.Redirect(w, r, companyURI(company, "/invoices"), http.StatusSeeOther) + slug := conn.MustGetText(r.Context(), "", "select add_invoice($1, $2, $3, $4, $5, $6)", company.Id, form.Number, form.Date, form.Customer, form.Notes, NewInvoiceProductArray(form.Products)) + http.Redirect(w, r, companyURI(company, "/invoices/"+slug), http.StatusSeeOther) default: http.Error(w, gettext("Invalid action", locale), http.StatusBadRequest) }