diff --git a/internal/cron/job_report.go b/internal/cron/job_report.go index c368ad1..9c579ed 100644 --- a/internal/cron/job_report.go +++ b/internal/cron/job_report.go @@ -1,16 +1,41 @@ package cron import ( - "errors" + "fmt" "log" + "os" "time" + + "github.com/joho/godotenv" + "gorm.io/driver/postgres" + "gorm.io/gorm" + + "github.com/rjNemo/rentease/internal/booking" + "github.com/rjNemo/rentease/internal/pdf" ) func JobMonthlyBookingReport() error { + godotenv.Load() + db, err := gorm.Open(postgres.Open(os.Getenv("DATABASE_URL")), &gorm.Config{}) + if err != nil { + return fmt.Errorf("error connecting to the database %s", err) + } + now := time.Now() log.Println("Start Monthly Booking Report job at:", now) - //err := booking.NewService().BuildReport("monthly", int(now.Month()), now.Year()) - err := errors.New("test") + report := booking.NewService(db).BuildReport("monthly", int(now.Month()), now.Year()) + + ps, err := pdf.NewPdfService( + os.Getenv("HTMLDOCS_PROJECT_ID"), + os.Getenv("HTMLDOCS_REPORT_PROJECT_ID"), + os.Getenv("HTMLDOCS_URL"), + os.Getenv("HTMLDOCS_KEY"), + ) + if err != nil { + return fmt.Errorf("error starting pdf service %s", err) + } + + ps.BuildReport(report, "", int(now.Month()), now.Year()) log.Printf("Executed Monthly Booking Report job at %v with errors: %s:", time.Now().Format(time.DateTime), err) return err } diff --git a/internal/view/booking_by_id.templ b/internal/view/booking_by_id.templ index d21653d..89e1422 100644 --- a/internal/view/booking_by_id.templ +++ b/internal/view/booking_by_id.templ @@ -2,42 +2,10 @@ package view import ( "fmt" + "github.com/rjNemo/rentease/internal/view/layout" ) -type BookingViewModel struct { - Id string - Name string - PhoneNumber string - CustomerNumber string - Email string - Canceled bool - From string - To string - Platform string - ExternalId string - Platforms []string - PlatformFees string - Items []ItemViewModel - ItemList []string - PaymentMethods []string - Url string - PdfUrl templ.SafeURL - CancelUrl string - Total string -} - -type ItemViewModel struct { - Id string - Item string - Quantity string - Price string - SubTotal string - PaymentMethod string - PaymentStatus string - ItemUrl string -} - templ BookingById(booking *BookingViewModel) { @layout.BaseLayout() {
diff --git a/internal/view/booking_by_id_templ.go b/internal/view/booking_by_id_templ.go index e027d1f..5d750c2 100644 --- a/internal/view/booking_by_id_templ.go +++ b/internal/view/booking_by_id_templ.go @@ -12,42 +12,10 @@ import "bytes" import ( "fmt" + "github.com/rjNemo/rentease/internal/view/layout" ) -type BookingViewModel struct { - Id string - Name string - PhoneNumber string - CustomerNumber string - Email string - Canceled bool - From string - To string - Platform string - ExternalId string - Platforms []string - PlatformFees string - Items []ItemViewModel - ItemList []string - PaymentMethods []string - Url string - PdfUrl templ.SafeURL - CancelUrl string - Total string -} - -type ItemViewModel struct { - Id string - Item string - Quantity string - Price string - SubTotal string - PaymentMethod string - PaymentStatus string - ItemUrl string -} - func BookingById(booking *BookingViewModel) templ.Component { return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) @@ -74,7 +42,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 45, Col: 22} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 13, Col: 22} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -87,7 +55,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Id) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 46, Col: 20} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 14, Col: 20} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -119,7 +87,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(booking.CancelUrl) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 55, Col: 66} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 23, Col: 66} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -137,7 +105,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Url) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 60, Col: 29} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 28, Col: 29} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -150,7 +118,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 65, Col: 68} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 33, Col: 68} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -163,7 +131,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(booking.PhoneNumber) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 69, Col: 90} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 37, Col: 90} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -176,7 +144,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(booking.CustomerNumber) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 73, Col: 111} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 41, Col: 111} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -189,7 +157,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Email) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 79, Col: 72} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 47, Col: 72} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { @@ -202,7 +170,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var12 string templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(booking.From) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 83, Col: 68} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 51, Col: 68} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { @@ -215,7 +183,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var13 string templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(booking.To) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 87, Col: 62} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 55, Col: 62} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { @@ -228,7 +196,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var14 string templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Platform) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 94, Col: 40} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 62, Col: 40} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { @@ -241,7 +209,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var15 string templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Platform) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 94, Col: 70} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 62, Col: 70} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) if templ_7745c5c3_Err != nil { @@ -259,7 +227,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var16 string templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(platform) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 96, Col: 33} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 64, Col: 33} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { @@ -272,7 +240,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var17 string templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(platform) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 96, Col: 46} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 64, Col: 46} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) if templ_7745c5c3_Err != nil { @@ -290,7 +258,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var18 string templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(booking.PlatformFees) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 102, Col: 128} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 70, Col: 128} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) if templ_7745c5c3_Err != nil { @@ -303,7 +271,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var19 string templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(booking.ExternalId) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 106, Col: 88} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 74, Col: 88} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) if templ_7745c5c3_Err != nil { @@ -326,7 +294,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var20 string templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Total) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 140, Col: 38} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 108, Col: 38} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) if templ_7745c5c3_Err != nil { @@ -339,7 +307,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var21 string templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s/items", booking.Url)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 149, Col: 55} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 117, Col: 55} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21)) if templ_7745c5c3_Err != nil { @@ -357,7 +325,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var22 string templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(item) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 155, Col: 28} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 123, Col: 28} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22)) if templ_7745c5c3_Err != nil { @@ -370,7 +338,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var23 string templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(item) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 155, Col: 37} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 123, Col: 37} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) if templ_7745c5c3_Err != nil { @@ -393,7 +361,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var24 string templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(paymentMethod) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 171, Col: 37} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 139, Col: 37} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24)) if templ_7745c5c3_Err != nil { @@ -406,7 +374,7 @@ func BookingById(booking *BookingViewModel) templ.Component { var templ_7745c5c3_Var25 string templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(paymentMethod) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 171, Col: 55} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 139, Col: 55} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25)) if templ_7745c5c3_Err != nil { diff --git a/internal/view/booking_list_viewmodel.go b/internal/view/booking_list_viewmodel.go new file mode 100644 index 0000000..5569b3f --- /dev/null +++ b/internal/view/booking_list_viewmodel.go @@ -0,0 +1,14 @@ +package view + +import "github.com/a-h/templ" + +type ListBookingsViewModel struct { + Id string + Url templ.SafeURL + From string + To string + Total string + Name string + Platform string + Canceled bool +} diff --git a/internal/view/booking_viewmodel.go b/internal/view/booking_viewmodel.go new file mode 100644 index 0000000..db49756 --- /dev/null +++ b/internal/view/booking_viewmodel.go @@ -0,0 +1,25 @@ +package view + +import "github.com/a-h/templ" + +type BookingViewModel struct { + Id string + Name string + PhoneNumber string + CustomerNumber string + Email string + Canceled bool + From string + To string + Platform string + ExternalId string + Platforms []string + PlatformFees string + Items []ItemViewModel + ItemList []string + PaymentMethods []string + Url string + PdfUrl templ.SafeURL + CancelUrl string + Total string +} diff --git a/internal/view/bookings_list.templ b/internal/view/bookings_list.templ index 90ff820..b963f95 100644 --- a/internal/view/bookings_list.templ +++ b/internal/view/bookings_list.templ @@ -4,17 +4,6 @@ import ( "github.com/rjNemo/rentease/internal/view/layout" ) -type ListBookingsViewModel struct { - Id string - Url templ.SafeURL - From string - To string - Total string - Name string - Platform string - Canceled bool -} - templ ListBookings(bookings []*ListBookingsViewModel) { @layout.BaseLayout() {
diff --git a/internal/view/bookings_list_templ.go b/internal/view/bookings_list_templ.go index b69dcd1..5b672f6 100644 --- a/internal/view/bookings_list_templ.go +++ b/internal/view/bookings_list_templ.go @@ -14,17 +14,6 @@ import ( "github.com/rjNemo/rentease/internal/view/layout" ) -type ListBookingsViewModel struct { - Id string - Url templ.SafeURL - From string - To string - Total string - Name string - Platform string - Canceled bool -} - func ListBookings(bookings []*ListBookingsViewModel) templ.Component { return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) @@ -65,7 +54,7 @@ func ListBookings(bookings []*ListBookingsViewModel) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(b.Id) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 41, Col: 15} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 30, Col: 15} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -88,7 +77,7 @@ func ListBookings(bookings []*ListBookingsViewModel) templ.Component { 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: 50, Col: 17} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 39, Col: 17} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -101,7 +90,7 @@ func ListBookings(bookings []*ListBookingsViewModel) templ.Component { 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: 53, Col: 20} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 42, Col: 20} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -114,7 +103,7 @@ func ListBookings(bookings []*ListBookingsViewModel) templ.Component { 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: 54, Col: 19} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 43, Col: 19} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -127,7 +116,7 @@ func ListBookings(bookings []*ListBookingsViewModel) templ.Component { 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: 55, Col: 17} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 44, Col: 17} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -140,7 +129,7 @@ func ListBookings(bookings []*ListBookingsViewModel) templ.Component { 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: 56, Col: 23} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/bookings_list.templ`, Line: 45, Col: 23} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { diff --git a/internal/view/index.templ b/internal/view/index.templ index 379c131..7abfdc9 100644 --- a/internal/view/index.templ +++ b/internal/view/index.templ @@ -8,7 +8,7 @@ import ( templ Index() { @layout.PublicLayout() {
-

Reserver votre sejour des maintenant

+

Reserver votre sejour dès maintenant

@component.RequestBookingForm(&component.RequestBookingViewModel{ Item: "T2", diff --git a/internal/view/index_templ.go b/internal/view/index_templ.go index d252da1..dd5baf9 100644 --- a/internal/view/index_templ.go +++ b/internal/view/index_templ.go @@ -34,7 +34,7 @@ func Index() templ.Component { templ_7745c5c3_Buffer = templ.GetBuffer() defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Reserver votre sejour des maintenant

") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Reserver votre sejour dès maintenant

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/internal/view/item_viewmodel.go b/internal/view/item_viewmodel.go new file mode 100644 index 0000000..aadea8a --- /dev/null +++ b/internal/view/item_viewmodel.go @@ -0,0 +1,12 @@ +package view + +type ItemViewModel struct { + Id string + Item string + Quantity string + Price string + SubTotal string + PaymentMethod string + PaymentStatus string + ItemUrl string +} diff --git a/internal/view/login_form.templ b/internal/view/login_form.templ index 9463d4b..9d9ac7d 100644 --- a/internal/view/login_form.templ +++ b/internal/view/login_form.templ @@ -1,11 +1,5 @@ package view -type LoginFormViewModel struct { - Email string - Password string - Errors map[string]string -} - func isFormError(data map[string]string, key string) bool { _, ok := data[key] return ok diff --git a/internal/view/login_form_templ.go b/internal/view/login_form_templ.go index a8cf523..7fe6ccc 100644 --- a/internal/view/login_form_templ.go +++ b/internal/view/login_form_templ.go @@ -10,12 +10,6 @@ import "context" import "io" import "bytes" -type LoginFormViewModel struct { - Email string - Password string - Errors map[string]string -} - func isFormError(data map[string]string, key string) bool { _, ok := data[key] return ok @@ -41,7 +35,7 @@ func LoginForm(lfvm LoginFormViewModel) templ.Component { var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(lfvm.Email) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/login_form.templ`, Line: 19, Col: 21} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/login_form.templ`, Line: 13, Col: 21} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -69,7 +63,7 @@ func LoginForm(lfvm LoginFormViewModel) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(msg) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/login_form.templ`, Line: 30, Col: 37} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/login_form.templ`, Line: 24, Col: 37} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -87,7 +81,7 @@ func LoginForm(lfvm LoginFormViewModel) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(lfvm.Password) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/login_form.templ`, Line: 35, Col: 24} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/login_form.templ`, Line: 29, Col: 24} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { diff --git a/internal/view/login_form_viewmodel.go b/internal/view/login_form_viewmodel.go new file mode 100644 index 0000000..80aff04 --- /dev/null +++ b/internal/view/login_form_viewmodel.go @@ -0,0 +1,7 @@ +package view + +type LoginFormViewModel struct { + Email string + Password string + Errors map[string]string +} diff --git a/internal/view/report_line_viewmodel.go b/internal/view/report_line_viewmodel.go new file mode 100644 index 0000000..aa73788 --- /dev/null +++ b/internal/view/report_line_viewmodel.go @@ -0,0 +1,16 @@ +package view + +import "github.com/a-h/templ" + +type ReportLine struct { + Id string + Url templ.SafeURL + Total string + CustomerName string + From string + To string + Platform string + PlatformFees string + Fee string + Profit string +} diff --git a/internal/view/report_section.templ b/internal/view/report_section.templ index bb3f24c..081b970 100644 --- a/internal/view/report_section.templ +++ b/internal/view/report_section.templ @@ -1,29 +1,5 @@ package view -type ReportViewModel struct { - Total string - CardTotal string - BookingFees string - PlatformFees string - Fee string - Profit string - PdfUrl templ.SafeURL - Lines []*ReportLine -} - -type ReportLine struct { - Id string - Url templ.SafeURL - Total string - CustomerName string - From string - To string - Platform string - PlatformFees string - Fee string - Profit string -} - templ ReportSection(report *ReportViewModel) {

Your report

diff --git a/internal/view/report_section_templ.go b/internal/view/report_section_templ.go index 84cbb7e..daa5403 100644 --- a/internal/view/report_section_templ.go +++ b/internal/view/report_section_templ.go @@ -10,30 +10,6 @@ import "context" import "io" import "bytes" -type ReportViewModel struct { - Total string - CardTotal string - BookingFees string - PlatformFees string - Fee string - Profit string - PdfUrl templ.SafeURL - Lines []*ReportLine -} - -type ReportLine struct { - Id string - Url templ.SafeURL - Total string - CustomerName string - From string - To string - Platform string - PlatformFees string - Fee string - Profit string -} - func ReportSection(report *ReportViewModel) templ.Component { return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) @@ -77,7 +53,7 @@ func ReportSection(report *ReportViewModel) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(row.Id) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 55, Col: 16} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 31, Col: 16} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -90,7 +66,7 @@ func ReportSection(report *ReportViewModel) templ.Component { var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(row.CustomerName) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 58, Col: 28} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 34, Col: 28} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -103,7 +79,7 @@ func ReportSection(report *ReportViewModel) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(row.From) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 59, Col: 20} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 35, Col: 20} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -116,7 +92,7 @@ func ReportSection(report *ReportViewModel) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(row.To) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 60, Col: 18} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 36, Col: 18} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -129,7 +105,7 @@ func ReportSection(report *ReportViewModel) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(row.Total) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 61, Col: 21} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 37, Col: 21} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -142,7 +118,7 @@ func ReportSection(report *ReportViewModel) templ.Component { var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(row.Platform) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 62, Col: 24} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 38, Col: 24} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -155,7 +131,7 @@ func ReportSection(report *ReportViewModel) templ.Component { var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(row.PlatformFees) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 63, Col: 28} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 39, Col: 28} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -168,7 +144,7 @@ func ReportSection(report *ReportViewModel) templ.Component { var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(row.Fee) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 64, Col: 19} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 40, Col: 19} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { @@ -181,7 +157,7 @@ func ReportSection(report *ReportViewModel) templ.Component { var templ_7745c5c3_Var12 string templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(row.Profit) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 65, Col: 22} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 41, Col: 22} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { @@ -199,7 +175,7 @@ func ReportSection(report *ReportViewModel) templ.Component { var templ_7745c5c3_Var13 string templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(report.Total) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 75, Col: 23} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 51, Col: 23} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { @@ -212,7 +188,7 @@ func ReportSection(report *ReportViewModel) templ.Component { var templ_7745c5c3_Var14 string templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(report.PlatformFees) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 77, Col: 30} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 53, Col: 30} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { @@ -225,7 +201,7 @@ func ReportSection(report *ReportViewModel) templ.Component { var templ_7745c5c3_Var15 string templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(report.Fee) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 78, Col: 21} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 54, Col: 21} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) if templ_7745c5c3_Err != nil { @@ -238,7 +214,7 @@ func ReportSection(report *ReportViewModel) templ.Component { var templ_7745c5c3_Var16 string templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(report.Profit) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 79, Col: 24} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 55, Col: 24} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { @@ -251,7 +227,7 @@ func ReportSection(report *ReportViewModel) templ.Component { var templ_7745c5c3_Var17 string templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(report.CardTotal) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 86, Col: 27} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 62, Col: 27} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) if templ_7745c5c3_Err != nil { @@ -264,7 +240,7 @@ func ReportSection(report *ReportViewModel) templ.Component { var templ_7745c5c3_Var18 string templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(report.BookingFees) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 88, Col: 29} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 64, Col: 29} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) if templ_7745c5c3_Err != nil { diff --git a/internal/view/report_viewmodel.go b/internal/view/report_viewmodel.go new file mode 100644 index 0000000..93825a4 --- /dev/null +++ b/internal/view/report_viewmodel.go @@ -0,0 +1,14 @@ +package view + +import "github.com/a-h/templ" + +type ReportViewModel struct { + Total string + CardTotal string + BookingFees string + PlatformFees string + Fee string + Profit string + PdfUrl templ.SafeURL + Lines []*ReportLine +} diff --git a/internal/view/reports.templ b/internal/view/reports.templ index 7885b81..a9389db 100644 --- a/internal/view/reports.templ +++ b/internal/view/reports.templ @@ -2,6 +2,7 @@ package view import ( "strconv" + "github.com/rjNemo/rentease/internal/view/layout" ) diff --git a/internal/view/reports_templ.go b/internal/view/reports_templ.go index dc3a1b7..27c1539 100644 --- a/internal/view/reports_templ.go +++ b/internal/view/reports_templ.go @@ -11,8 +11,9 @@ import "io" import "bytes" import ( - "github.com/rjNemo/rentease/internal/view/layout" "strconv" + + "github.com/rjNemo/rentease/internal/view/layout" ) func Reports(months []string, m int, year string) templ.Component { @@ -41,7 +42,7 @@ func Reports(months []string, m int, year string) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(year) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/reports.templ`, Line: 30, Col: 61} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/reports.templ`, Line: 31, Col: 61} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -59,7 +60,7 @@ func Reports(months []string, m int, year string) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(i + 1)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/reports.templ`, Line: 37, Col: 36} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/reports.templ`, Line: 38, Col: 36} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -82,7 +83,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: 42, Col: 16} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/reports.templ`, Line: 43, Col: 16} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil {