feat: add list booking api route

This commit is contained in:
Ruidy 2025-01-18 20:58:18 +01:00
parent cb6677ca60
commit 84d341b616
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
2 changed files with 16 additions and 0 deletions

View file

@ -52,6 +52,21 @@ func handleBookingListPage(bs *booking.Service, hc *config.Host) echo.HandlerFun
}
}
func handleBookingList(bs *booking.Service, hc *config.Host) echo.HandlerFunc {
return func(c echo.Context) error {
search := c.FormValue("search")
var bookings []*booking.Line
if search != "" {
bookings = bs.Search(search)
} else {
bookings = bs.All()
}
return c.JSON(http.StatusOK, bookings)
}
}
func handleBookingCreatePage(hc *config.Host) echo.HandlerFunc {
return func(c echo.Context) error {
return renderTempl(c, http.StatusOK, view.NewBooking(hc.Platforms))

View file

@ -18,6 +18,7 @@ func (s Server) MountHandlers() {
},
}))
api.POST("/sync", handleSync(s.bs))
api.GET("/bookings", handleBookingList(s.bs, s.hc))
private := s.Router.Group("")
private.Use(MakeAuthMiddleware(s.as))