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.
This commit is contained in:
jordi fita mas 2023-02-27 12:45:32 +01:00
parent c1a64dd51d
commit c7ac82d6ea
1 changed files with 2 additions and 2 deletions

View File

@ -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)
}