Marking a resercation as processed

This commit is contained in:
2024-07-25 13:51:31 +02:00
parent ca1e72c676
commit fcd29cc082
5 changed files with 54 additions and 6 deletions

View File

@ -16,6 +16,8 @@ import (
"strconv"
"strings"
"time"
"github.com/go-chi/chi/v5"
)
// Repo the repository used by the handlers
@ -616,3 +618,15 @@ func (m *Repository) AdminPostShowReservation(w http.ResponseWriter, r *http.Req
func (m *Repository) AdminReservationsCalendar(w http.ResponseWriter, r *http.Request) {
render.Template(w, r, "admin-reservations-calendar.page.tmpl", &models.TemplateData{})
}
// AdminProcessReservation marks a reservation as processed
func (m *Repository) AdminProcessReservation(w http.ResponseWriter, r *http.Request) {
id, _ := strconv.Atoi(chi.URLParam(r, "id"))
src := chi.URLParam(r, "src")
_ = m.DB.UpdateProcessedForReservation(id, 1)
m.App.Session.Put(r.Context(), "flash", "Reservation marked as processed")
http.Redirect(w, r, fmt.Sprintf("/admin/reservations-%s", src), http.StatusSeeOther)
}