fix search bug introduce isHxRequest helper

This commit is contained in:
Ruidy 2024-09-09 17:42:57 +02:00
parent e02de4daa5
commit 701a32671a
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
2 changed files with 12 additions and 1 deletions

View file

@ -45,7 +45,7 @@ func handleBookingListPage(bs *booking.Service, hc *config.Host) echo.HandlerFun
}
})
if search != "" {
if isHxRequest(c) {
return renderTempl(c, http.StatusOK, view.BookingLines(bvm))
} else {
return renderTempl(c, http.StatusOK, view.ListBookings(bvm))

View file

@ -24,3 +24,14 @@ func hxRedirect(c echo.Context, statusCode int, url string) error {
c.Response().Header().Add("HX-Redirect", url)
return c.NoContent(statusCode)
}
func isHxRequest(c echo.Context) bool {
header, ok := c.Request().Header["Hx-Request"]
if !ok {
return false
}
if header[0] != "true" {
return false
}
return true
}