get booking by id

This commit is contained in:
Ruidy 2024-02-16 18:11:25 +01:00
parent f3bf9b3caf
commit 92f8085537
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
2 changed files with 9 additions and 3 deletions

View file

@ -37,6 +37,12 @@ func (bs Service) Create(From time.Time, To time.Time, Name string, PhoneNumber
return b
}
func (bs Service) One(id int) *Booking {
b := &Booking{Id: id}
bs.db.Preload("Items").First(b)
return b
}
type Line struct {
From time.Time
To time.Time

View file

@ -79,8 +79,8 @@ func handleBookingPage(bs *booking.Service) echo.HandlerFunc {
if err != nil {
return err
}
b := &booking.Booking{Id: id}
bs.db.Preload("Items").First(b)
b := bs.One(id)
bvm := &views.BookingViewModel{
Id: fmt.Sprintf("%04s", strconv.Itoa(b.Id)),
@ -111,7 +111,7 @@ func handleBookingPage(bs *booking.Service) echo.HandlerFunc {
PaymentMethods: constants.PaymentMethods,
}
component := views.BookingById(bvm)
return s.renderTempl(c, http.StatusOK, component)
return renderTempl(c, http.StatusOK, component)
}
}