Finishing up our response to user, and adding alerts
This commit is contained in:
parent
3ad57c754f
commit
d8d2abcde3
@ -119,12 +119,17 @@ func (m *Repository) PostMakeReservation(w http.ResponseWriter, r *http.Request)
|
||||
http.Redirect(w, r, "/reservation-summary", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
// ReservationSummary is the reservation summary page handler
|
||||
func (m *Repository) ReservationSummary(w http.ResponseWriter, r *http.Request) {
|
||||
reservation, ok := m.App.Session.Get(r.Context(), "reservation").(models.Reservation)
|
||||
if !ok {
|
||||
log.Println("connot get item from reservation")
|
||||
m.App.Session.Put(r.Context(), "error", "Can't get reservation from session")
|
||||
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
|
||||
}
|
||||
|
||||
m.App.Session.Remove(r.Context(), "reservation")
|
||||
|
||||
data := make(map[string]interface{})
|
||||
data["reservation"] = reservation
|
||||
|
||||
|
@ -21,6 +21,9 @@ func NewTemplates(a *config.AppConfig) {
|
||||
|
||||
// AddDefaultData adds default template data
|
||||
func AddDefaultData(td *models.TemplateData, r *http.Request) *models.TemplateData {
|
||||
td.Flash = app.Session.PopString(r.Context(), "flash")
|
||||
td.Warning = app.Session.PopString(r.Context(), "warning")
|
||||
td.Error = app.Session.PopString(r.Context(), "error")
|
||||
td.CSRFToken = nosurf.Token(r)
|
||||
return td
|
||||
}
|
||||
|
@ -116,6 +116,16 @@
|
||||
})
|
||||
}
|
||||
|
||||
{{with .Error}}
|
||||
notify("{{.}}", "error")
|
||||
{{end}}
|
||||
{{with .Warning}}
|
||||
notify("{{.}}", "warning")
|
||||
{{end}}
|
||||
{{with .Flash}}
|
||||
notify("{{.}}", "flash")
|
||||
{{end}}
|
||||
|
||||
// Prompt is out Javascript module for all alerts, notifications, and custom popup dialogs
|
||||
function Prompt() {
|
||||
let toast = function (c) {
|
||||
|
Loading…
Reference in New Issue
Block a user