rename reservation to availability

This commit is contained in:
Muyao CHEN 2024-06-30 10:51:29 +02:00
parent a8b56b50db
commit 97b9898dfc
4 changed files with 12 additions and 12 deletions

View File

@ -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/"))

View File

@ -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!",

View File

@ -7,7 +7,7 @@
<div class="col-md-6">
<h1 class="text-center mt-5">Search for Availability</h1>
<form action="/reservation" method="post" novalidate class="needs-validation">
<form action="/availability" method="post" novalidate class="needs-validation">
<input type="hidden" name="csrf_token" value="{{.CSRFToken}}">
<div id="reservation-dates" class="row">
<div class="col mb-3">

View File

@ -45,7 +45,7 @@
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="/reservation">Book Now</a>
<a class="nav-link" href="/availability">Book Now</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/contact">Contact</a>