diff --git a/internal/server/handle_public.go b/internal/server/handle_public.go deleted file mode 100644 index 047ad36..0000000 --- a/internal/server/handle_public.go +++ /dev/null @@ -1,49 +0,0 @@ -package server - -//func handleHomePage() echo.HandlerFunc { -// return func(ctx echo.Context) error { -// return renderTempl(ctx, http.StatusOK, view.Index()) -// } -//} - -//func handleRequestBooking(bs *booking.Service) echo.HandlerFunc { -// return func(c echo.Context) error { -// itemStr := c.FormValue("item") -// fromStr := c.FormValue("from") -// toStr := c.FormValue("to") -// name := c.FormValue("item") -// phoneNumber := c.FormValue("phone") -// email := c.FormValue("email") -// -// from, fErr := myTime.ParseFromForm(fromStr) -// to, tErr := myTime.ParseFromForm(toStr) -// if fErr != nil || tErr != nil { -// return fmt.Errorf("error parsing booking request time: %q %q", fErr, tErr) -// } -// -// errs := make([]string, 0) -// if to.Sub(from) < time.Duration(0) { -// errs = append(errs, "invalid_time_range") -// } -// -// if phoneNumber == "" && email == "" { -// errs = append(errs, "missing_communication_method") -// } -// -// if len(errs) > 0 { -// 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()) -// } -//} diff --git a/internal/view/booking_by_id.templ b/internal/view/booking_by_id.templ index c66fd84..225a55a 100644 --- a/internal/view/booking_by_id.templ +++ b/internal/view/booking_by_id.templ @@ -7,89 +7,42 @@ import ( templ BookingById(booking *BookingViewModel) { @layout.BaseLayout() { -
-
-

{ booking.Name }

-

{ booking.Id }

+
+
+

{ booking.Name }

+

{ booking.Id }

-
- Create PDF - - +
+ Create PDF + + + + + + if booking.Canceled { - Canceled + Canceled } else { - Cancel + }
-
-
-
- - - -
-
- - - -
-
- - - -
-
- -
+ @BookingForm(*booking)
-
-

Line Items

-
- +
+

Line Items

+
+
- - - - - - - + + + + + + + @@ -98,50 +51,83 @@ templ BookingById(booking *BookingViewModel) { } - - - - - - - - + + + +
ItemQuantityPrice (€)Payment MethodPayment StatusSub-total (€)ItemQuantityPrice (€)Payment MethodPayment StatusSub-total (€)
{ booking.Total }
Total:{ booking.Total }
-
- Add line -
-
- - - -
-
+ +
+ +
+ +
} } diff --git a/internal/view/booking_by_id_templ.go b/internal/view/booking_by_id_templ.go index 4749295..8970c4f 100644 --- a/internal/view/booking_by_id_templ.go +++ b/internal/view/booking_by_id_templ.go @@ -46,33 +46,33 @@ func BookingById(booking *BookingViewModel) templ.Component { }() } ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } 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: 12, Col: 22} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 12, Col: 62} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } 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: 13, Col: 20} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 13, Col: 47} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Create PDF ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" target=\"_blank\">Create PDF ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if booking.Canceled { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("Canceled") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("Canceled") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("Cancel") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-swap=\"outerHTML\">Cancel") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - 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: 27, Col: 29} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) + templ_7745c5c3_Err = BookingForm(*booking).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">

Line Items

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

Line Items

ItemQuantityPrice (€)Payment MethodPayment StatusSub-total (€)
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -298,33 +127,33 @@ func BookingById(booking *BookingViewModel) templ.Component { return templ_7745c5c3_Err } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
ItemQuantityPrice (€)Payment MethodPayment StatusSub-total (€)
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Total:") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var20 string - templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Total) + var templ_7745c5c3_Var7 string + templ_7745c5c3_Var7, 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: 107, Col: 38} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/booking_by_id.templ`, Line: 56, Col: 26} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) + _, 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("
Add line
Add New Line Item
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/internal/view/booking_form.templ b/internal/view/booking_form.templ index 150a68b..c93096f 100644 --- a/internal/view/booking_form.templ +++ b/internal/view/booking_form.templ @@ -1,56 +1,129 @@ package view templ BookingForm(booking BookingViewModel) { -
-
-
-