fix linter errors

This commit is contained in:
Ruidy 2024-07-14 23:43:14 +02:00
parent cd61bdf2f1
commit 22175a9b39
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
5 changed files with 102 additions and 115 deletions

View file

@ -1,62 +1,49 @@
package server package server
import ( //func handleHomePage() echo.HandlerFunc {
"fmt" // return func(ctx echo.Context) error {
"net/http" // return renderTempl(ctx, http.StatusOK, view.Index())
"time" // }
//}
"github.com/labstack/echo/v4" //func handleRequestBooking(bs *booking.Service) echo.HandlerFunc {
// return func(c echo.Context) error {
"github.com/rjNemo/rentease/internal/booking" // itemStr := c.FormValue("item")
"github.com/rjNemo/rentease/internal/view" // fromStr := c.FormValue("from")
"github.com/rjNemo/rentease/internal/view/component" // toStr := c.FormValue("to")
myTime "github.com/rjNemo/rentease/pkg/time" // name := c.FormValue("item")
) // phoneNumber := c.FormValue("phone")
// email := c.FormValue("email")
func handleHomePage() echo.HandlerFunc { //
return func(ctx echo.Context) error { // from, fErr := myTime.ParseFromForm(fromStr)
return renderTempl(ctx, http.StatusOK, view.Index()) // to, tErr := myTime.ParseFromForm(toStr)
} // if fErr != nil || tErr != nil {
} // return fmt.Errorf("error parsing booking request time: %q %q", fErr, tErr)
// }
func handleRequestBooking(bs *booking.Service) echo.HandlerFunc { //
return func(c echo.Context) error { // errs := make([]string, 0)
itemStr := c.FormValue("item") // if to.Sub(from) < time.Duration(0) {
fromStr := c.FormValue("from") // errs = append(errs, "invalid_time_range")
toStr := c.FormValue("to") // }
name := c.FormValue("item") //
phoneNumber := c.FormValue("phone") // if phoneNumber == "" && email == "" {
email := c.FormValue("email") // errs = append(errs, "missing_communication_method")
// }
from, fErr := myTime.ParseFromForm(fromStr) //
to, tErr := myTime.ParseFromForm(toStr) // if len(errs) > 0 {
if fErr != nil || tErr != nil { // return renderTempl(c, http.StatusOK, component.RequestBookingForm(&component.RequestBookingViewModel{
return fmt.Errorf("error parsing booking request time: %q %q", fErr, tErr) // Item: itemStr,
} // From: fromStr,
// To: toStr,
errs := make([]string, 0) // Name: name,
if to.Sub(from) < time.Duration(0) { // PhoneNumber: phoneNumber,
errs = append(errs, "invalid_time_range") // Email: email,
} // Errors: errs,
// }))
if phoneNumber == "" && email == "" { // }
errs = append(errs, "missing_communication_method") //
} // bs.CreateRequest(from, to, name, phoneNumber, email, itemStr, 1)
//
if len(errs) > 0 { // return renderTempl(c, http.StatusSeeOther, view.Success())
return renderTempl(c, http.StatusOK, component.RequestBookingForm(&component.RequestBookingViewModel{ // }
Item: itemStr, //}
From: fromStr,
To: toStr,
Name: name,
PhoneNumber: phoneNumber,
Email: email,
Errors: errs,
}))
}
bs.CreateRequest(from, to, name, phoneNumber, email, itemStr, 1)
return renderTempl(c, http.StatusSeeOther, view.Success())
}
}

View file

@ -114,7 +114,7 @@ func New(bs *booking.Service, as *auth.Service, ps *pdf.PdfService, hc *config.H
return s, nil return s, nil
} }
func (s Server) Start() { func (s Server) Start(c context.Context) {
go func() { go func() {
if err := s.Router.Start(s.addr); err != nil && !errors.Is(err, http.ErrServerClosed) { if err := s.Router.Start(s.addr); err != nil && !errors.Is(err, http.ErrServerClosed) {
s.Router.Logger.Fatalf("shutting down the server: %s", err) s.Router.Logger.Fatalf("shutting down the server: %s", err)
@ -124,7 +124,7 @@ func (s Server) Start() {
quit := make(chan os.Signal, 1) quit := make(chan os.Signal, 1)
signal.Notify(quit, os.Interrupt) signal.Notify(quit, os.Interrupt)
<-quit <-quit
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(c, 10*time.Second)
defer cancel() defer cancel()
if err := s.Router.Shutdown(ctx); err != nil { if err := s.Router.Shutdown(ctx); err != nil {
s.Router.Logger.Fatal(err) s.Router.Logger.Fatal(err)

View file

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.663 // templ: version: v0.2.707
package view package view
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.
@ -67,7 +67,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
templ_7745c5c3_Buffer = templ.GetBuffer() templ_7745c5c3_Buffer = templ.GetBuffer()
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<section class=\"grid\"><hgroup><h1>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -80,7 +80,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h1><h2>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -93,7 +93,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h2></hgroup><div><a class=\"contrast\" role=\"button\" href=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -102,17 +102,17 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 4) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" target=\"_blank\">Create PDF</a> <a href=\"https://web.whatsapp.com/\" target=\"_blank\" rel=\"noreferrer noopener\"><img src=\"/static/icons/whatsapp.png\" width=\"20px\" style=\"width: 2rem; margin: 0 1rem\"></a> <a href=\"https://dashboard.stripe.com/payments/new\" target=\"_blank\" rel=\"noreferrer noopener\"><img src=\"/static/icons/stripe.png\" width=\"20px\" style=\"width: 2rem;\"></a> ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
if booking.Canceled { if booking.Canceled {
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 5) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<span>Canceled</span>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} else { } else {
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 6) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<a class=\"outline\" role=\"button\" hx-patch=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -125,12 +125,12 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 7) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-swap=\"outerHTML\">Cancel</a>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 8) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></section><section><form hx-put=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -143,7 +143,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 9) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><fieldset><div class=\"grid\"><label for=\"name\">Customer name <input type=\"text\" id=\"name\" name=\"name\" value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -156,7 +156,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 10) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" required autofocus></label> <label for=\"phone_number\">Phone number <input type=\"tel\" id=\"phone_number\" name=\"phone_number\" value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -169,7 +169,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 11) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></label> <label for=\"customer_number\">Customer number <input type=\"number\" id=\"customer_number\" name=\"customer_number\" required value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -182,7 +182,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 12) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></label></div><div class=\"grid\"><label for=\"email\">Email <input type=\"email\" id=\"email\" name=\"email\" value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -195,7 +195,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 13) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></label> <label for=\"from\">From <input type=\"date\" id=\"from\" name=\"from\" value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -208,7 +208,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 14) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></label> <label for=\"to\">To <input type=\"date\" id=\"to\" name=\"to\" value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -221,7 +221,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 15) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></label></div><div class=\"grid\"><label for=\"platform\">Platform <select id=\"platform\" name=\"platform\"><option value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -234,7 +234,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 16) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" selected>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -247,12 +247,12 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 17) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</option> ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
for _, platform := range booking.Platforms { for _, platform := range booking.Platforms {
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 18) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<option value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -265,7 +265,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 19) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -278,12 +278,12 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 20) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</option>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 21) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</select></label> <label for=\"platform_fees\">Fees <input type=\"number\" id=\"platform_fees\" inputmode=\"decimal\" step=\"0.01\" name=\"platform_fees\" value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -296,7 +296,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 22) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></label> <label for=\"external_id\">Platform ID <input type=\"text\" id=\"external_id\" name=\"external_id\" value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -309,7 +309,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 23) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></label></div></fieldset><button type=\"submit\">Update</button></form></section><section><h3>Line Items </h3><div class=\"overflow-auto\"><table class=\"striped\"><thead><tr><th scope=\"col\">Item</th><th scope=\"col\">Quantity</th><th scope=\"col\">Price (€)</th><th scope=\"col\">Payment Method</th><th scope=\"col\">Payment Status</th><th scope=\"col\">Sub-total (€)</th><th scope=\"col\"></th></tr></thead> <tbody id=\"line-items\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -319,7 +319,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 24) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</tbody><tfoot><tr><th scope=\"col\"></th><th scope=\"col\"></th><th scope=\"col\"></th><th scope=\"col\"></th><th scope=\"col\"></th><th scope=\"col\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -332,7 +332,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 25) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</th><th scope=\"col\"></th></tr></tfoot></table></div></section><details><summary role=\"button\" class=\"secondary\">Add line </summary><form hx-post=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -345,12 +345,12 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 26) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-target=\"#line-items\" hx-swap=\"afterend\" hx-on::after-request=\" if(event.detail.successful) this.reset()\"><article><label for=\"new-line-item\">Item <select name=\"item\" id=\"new-line-item\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
for _, item := range booking.ItemList { for _, item := range booking.ItemList {
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 27) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<option value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -363,7 +363,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 28) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -376,17 +376,17 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 29) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</option>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 30) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</select></label> <label for=\"new-line-quantity\">Quantity <input type=\"number\" name=\"quantity\" id=\"new-line-quantity\" required></label> <label for=\"new-line-price\">Price <input type=\"number\" name=\"price\" inputmode=\"decimal\" step=\"0.01\" id=\"new-line-price\" required></label> <label for=\"new-line-method\">Payment Method <select name=\"method\" id=\"new-line-method\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
for _, paymentMethod := range booking.PaymentMethods { for _, paymentMethod := range booking.PaymentMethods {
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 31) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<option value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -399,7 +399,7 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 32) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -412,12 +412,12 @@ func BookingById(booking *BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 33) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</option>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 34) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</select></label> <button type=\"submit\">Add</button></article></form></details>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }

View file

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.663 // templ: version: v0.2.707
package view package view
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.
@ -23,7 +23,7 @@ func BookingForm(booking BookingViewModel) templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent templ_7745c5c3_Var1 = templ.NopComponent
} }
ctx = templ.ClearChildren(ctx) ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<form hx-put=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -36,7 +36,7 @@ func BookingForm(booking BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><fieldset><div class=\"grid\"><label for=\"name\">Customer name <input type=\"text\" id=\"name\" name=\"name\" value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -49,7 +49,7 @@ func BookingForm(booking BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" required autofocus></label> <label for=\"phone_number\">Phone number <input type=\"tel\" id=\"phone_number\" name=\"phone_number\" value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -62,7 +62,7 @@ func BookingForm(booking BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 4) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></label> <label for=\"customer_number\">Customer number <input type=\"number\" id=\"customer_number\" name=\"customer_number\" required value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -75,7 +75,7 @@ func BookingForm(booking BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 5) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></label></div><div class=\"grid\"><label for=\"email\">Email <input type=\"email\" id=\"email\" name=\"email\" value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -88,7 +88,7 @@ func BookingForm(booking BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 6) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></label> <label for=\"from\">From <input type=\"date\" id=\"from\" name=\"from\" value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -101,7 +101,7 @@ func BookingForm(booking BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 7) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></label> <label for=\"to\">To <input type=\"date\" id=\"to\" name=\"to\" value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -114,7 +114,7 @@ func BookingForm(booking BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 8) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></label></div><div class=\"grid\"><label for=\"platform\">Platform <select id=\"platform\" name=\"platform\"><option value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -127,7 +127,7 @@ func BookingForm(booking BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 9) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" selected>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -140,12 +140,12 @@ func BookingForm(booking BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 10) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</option> ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
for _, platform := range booking.Platforms { for _, platform := range booking.Platforms {
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 11) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<option value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -158,7 +158,7 @@ func BookingForm(booking BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 12) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -171,12 +171,12 @@ func BookingForm(booking BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 13) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</option>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 14) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</select></label> <label for=\"platform_fees\">Fees <input type=\"number\" id=\"platform_fees\" inputmode=\"decimal\" step=\"0.01\" name=\"platform_fees\" value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -189,7 +189,7 @@ func BookingForm(booking BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 15) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></label> <label for=\"external_id\">Platform ID <input type=\"text\" id=\"external_id\" name=\"external_id\" value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -202,7 +202,7 @@ func BookingForm(booking BookingViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 16) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></label></div></fieldset><button type=\"submit\">Update</button></form>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }

View file

@ -26,7 +26,7 @@ var static embed.FS
func main() { func main() {
ctx := context.Background() ctx := context.Background()
godotenv.Load() _ = godotenv.Load()
if err := run(ctx, os.Getenv); err != nil { if err := run(ctx, os.Getenv); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err) fmt.Fprintf(os.Stderr, "%s\n", err)
@ -97,6 +97,6 @@ func run(c context.Context, getEnv func(string) string) error {
return fmt.Errorf("error starting server %s", err) return fmt.Errorf("error starting server %s", err)
} }
srv.Start() srv.Start(ctx)
return nil return nil
} }