diff --git a/cmd/web/routes.go b/cmd/web/routes.go index e6d44c0..cbfe377 100644 --- a/cmd/web/routes.go +++ b/cmd/web/routes.go @@ -44,6 +44,7 @@ func routes(app *config.AppConfig) http.Handler { mux.Get("/reservations-new", handlers.Repo.AdminNewReservations) mux.Get("/reservations-all", handlers.Repo.AdminAllReservations) mux.Get("/reservations-calendar", handlers.Repo.AdminReservationsCalendar) + mux.Get("/process-reservation/{src}/{id}", handlers.Repo.AdminProcessReservation) mux.Get("/reservations/{src}/{id}", handlers.Repo.AdminShowReservation) mux.Post("/reservations/{src}/{id}", handlers.Repo.AdminPostShowReservation) diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 383f781..0a1c5ec 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -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) +} diff --git a/static/js/app.js b/static/js/app.js index ccdedda..c884468 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -97,12 +97,6 @@ function Prompt() { c.didOpen(); } }, - preConfirm: () => { - return [ - document.getElementById('start').value, - document.getElementById('end').value, - ] - }, }) if (c.callback !== undefined) { diff --git a/templates/admin-reservations-show.page.tmpl b/templates/admin-reservations-show.page.tmpl index 387c272..21cea01 100644 --- a/templates/admin-reservations-show.page.tmpl +++ b/templates/admin-reservations-show.page.tmpl @@ -50,7 +50,25 @@ Reservation Cancel + Mark as Processed {{end}} +{{define "js"}} +{{$src := index .StringMap "src"}} + +{{end}} + diff --git a/templates/admin.layout.tmpl b/templates/admin.layout.tmpl index e58791d..615f0bc 100644 --- a/templates/admin.layout.tmpl +++ b/templates/admin.layout.tmpl @@ -14,6 +14,7 @@ + @@ -25,6 +26,9 @@ label { font-weight: bold; } + .notie-container { + z-index: 50000; + } {{block "css" .}} @@ -132,8 +136,25 @@ + + + + {{block "js" .}} {{end}}