From 97b9898dfc19d85cf16f6d242a05856bc7247637 Mon Sep 17 00:00:00 2001 From: Muyao CHEN Date: Sun, 30 Jun 2024 10:51:29 +0200 Subject: [PATCH] rename reservation to availability --- cmd/web/routes.go | 6 +++--- pkg/handlers/handlers.go | 14 +++++++------- ...eservation.page.tmpl => availability.page.tmpl} | 2 +- templates/base.layout.tmpl | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) rename templates/{reservation.page.tmpl => availability.page.tmpl} (92%) diff --git a/cmd/web/routes.go b/cmd/web/routes.go index c30d62d..0b062fa 100644 --- a/cmd/web/routes.go +++ b/cmd/web/routes.go @@ -22,9 +22,9 @@ func routes(app *config.AppConfig) http.Handler { mux.Get("/contact", handlers.Repo.Contact) mux.Get("/generals-quarters", handlers.Repo.Generals) mux.Get("/majors-suite", handlers.Repo.Majors) - mux.Get("/reservation", handlers.Repo.Reservation) - mux.Post("/reservation", handlers.Repo.PostReservation) - mux.Get("/reservation-json", handlers.Repo.ReservationJSON) + mux.Get("/availability", handlers.Repo.Availability) + mux.Post("/availability", handlers.Repo.PostAvailability) + mux.Get("/availability-json", handlers.Repo.AvailabilityJSON) mux.Get("/make-reservation", handlers.Repo.MakeReservation) fileServer := http.FileServer(http.Dir("./static/")) diff --git a/pkg/handlers/handlers.go b/pkg/handlers/handlers.go index f3430d9..1e69227 100644 --- a/pkg/handlers/handlers.go +++ b/pkg/handlers/handlers.go @@ -71,13 +71,13 @@ func (m *Repository) MakeReservation(w http.ResponseWriter, r *http.Request) { render.RenderTemplate(w, r, "make-reservation.page.tmpl", &models.TemplateData{}) } -// MakeReservation is the make reservation page handler -func (m *Repository) Reservation(w http.ResponseWriter, r *http.Request) { - render.RenderTemplate(w, r, "reservation.page.tmpl", &models.TemplateData{}) +// Availability is the search for availability page handler +func (m *Repository) Availability(w http.ResponseWriter, r *http.Request) { + render.RenderTemplate(w, r, "availability.page.tmpl", &models.TemplateData{}) } -// MakeReservation is the make reservation page handler -func (m *Repository) PostReservation(w http.ResponseWriter, r *http.Request) { +// PostAvailability is the search for availability page handler +func (m *Repository) PostAvailability(w http.ResponseWriter, r *http.Request) { start := r.Form.Get("start") end := r.Form.Get("end") fmt.Fprintf(w, "Posted to search availability from %s to %s", start, end) @@ -88,8 +88,8 @@ type responseJSON struct { Message string `json:"message"` } -// MakeReservation is the make reservation page handler -func (m *Repository) ReservationJSON(w http.ResponseWriter, r *http.Request) { +// AvailabilityJSON is the search for availability page handler +func (m *Repository) AvailabilityJSON(w http.ResponseWriter, r *http.Request) { resp := responseJSON{ OK: "true", Message: "Available!", diff --git a/templates/reservation.page.tmpl b/templates/availability.page.tmpl similarity index 92% rename from templates/reservation.page.tmpl rename to templates/availability.page.tmpl index 431ebea..2c0503a 100644 --- a/templates/reservation.page.tmpl +++ b/templates/availability.page.tmpl @@ -7,7 +7,7 @@

Search for Availability

-
+
diff --git a/templates/base.layout.tmpl b/templates/base.layout.tmpl index fec36f1..ed5138b 100644 --- a/templates/base.layout.tmpl +++ b/templates/base.layout.tmpl @@ -45,7 +45,7 @@