From ab52e6ec95bc2a3b1aac43fb089169bdd27c094c Mon Sep 17 00:00:00 2001 From: Ruidy Date: Sun, 2 Jun 2024 11:07:42 +0200 Subject: [PATCH] show cancel state on booking list --- internal/booking/service.go | 2 +- internal/view/bookings_list.templ | 8 +++++- internal/view/bookings_list_templ.go | 40 +++++++++++++++++----------- internal/view/reports.templ | 4 ++- internal/view/reports_templ.go | 2 +- 5 files changed, 37 insertions(+), 19 deletions(-) diff --git a/internal/booking/service.go b/internal/booking/service.go index ebc7ffd..89522ac 100644 --- a/internal/booking/service.go +++ b/internal/booking/service.go @@ -23,7 +23,7 @@ func NewService(db *gorm.DB) *Service { func (bs Service) All() []*Line { bookings := make([]*Line, 0) bs.db.Raw(` - select bookings.id, customer_name, "from", "to", platform, sum(price * quantity) as total + select bookings.id, customer_name, "from", "to", platform, sum(price * quantity) as total, canceled from bookings join items on bookings.id = items.booking_id group by bookings.id diff --git a/internal/view/bookings_list.templ b/internal/view/bookings_list.templ index 79cee06..66f6842 100644 --- a/internal/view/bookings_list.templ +++ b/internal/view/bookings_list.templ @@ -41,7 +41,13 @@ templ ListBookings(bookings []*ListBookingsViewModel) { { b.Id } - { b.Name } + + + { b.Name } + + { b.Total } { b.From } { b.To } diff --git a/internal/view/bookings_list_templ.go b/internal/view/bookings_list_templ.go index 4697480..0aa07e2 100644 --- a/internal/view/bookings_list_templ.go +++ b/internal/view/bookings_list_templ.go @@ -44,12 +44,12 @@ func ListBookings(bookings []*ListBookingsViewModel) templ.Component { templ_7745c5c3_Buffer = templ.GetBuffer() defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Bookings

Overview of the activity

") + templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } for _, b := range bookings { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 11) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
IDNameTotal (€)FromToPlatform
") + templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -71,77 +71,87 @@ func ListBookings(bookings []*ListBookingsViewModel) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 4) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if b.Canceled { + templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 5) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 6) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(b.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 44, Col: 19} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 48, Col: 17} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 7) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(b.Total) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 45, Col: 20} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 51, Col: 20} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 8) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(b.From) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 46, Col: 19} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 52, Col: 19} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 9) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(b.To) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 47, Col: 17} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 53, Col: 17} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 10) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(b.Platform) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 48, Col: 23} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 54, Col: 23} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 12) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/internal/view/reports.templ b/internal/view/reports.templ index 0fb72e5..7885b81 100644 --- a/internal/view/reports.templ +++ b/internal/view/reports.templ @@ -38,7 +38,9 @@ templ Reports(months []string, m int, year string) { if i+1 == m { selected } - >{ month } + > + { month } + } diff --git a/internal/view/reports_templ.go b/internal/view/reports_templ.go index adee44a..1d356d9 100644 --- a/internal/view/reports_templ.go +++ b/internal/view/reports_templ.go @@ -82,7 +82,7 @@ func Reports(months []string, m int, year string) templ.Component { var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(month) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/reports.templ`, Line: 41, Col: 16} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/reports.templ`, Line: 42, Col: 16} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil {