diff --git a/internal/server/handle_bookings.go b/internal/server/handle_bookings.go index 7478993..f0f9f7c 100644 --- a/internal/server/handle_bookings.go +++ b/internal/server/handle_bookings.go @@ -20,7 +20,7 @@ import ( myTime "github.com/rjNemo/rentease/pkg/time" ) -func handleListBookingPage(bs *booking.Service, hc *config.Host) echo.HandlerFunc { +func handleBookingListPage(bs *booking.Service, hc *config.Host) echo.HandlerFunc { return func(c echo.Context) error { bookings := bs.All() @@ -42,22 +42,22 @@ func handleListBookingPage(bs *booking.Service, hc *config.Host) echo.HandlerFun } } -func handleNewBookingPage(hc *config.Host) echo.HandlerFunc { +func handleBookingCreatePage(hc *config.Host) echo.HandlerFunc { return func(c echo.Context) error { return renderTempl(c, http.StatusOK, view.NewBooking(hc.Platforms)) } } -func handleCreateBooking(bs *booking.Service) echo.HandlerFunc { +func handleBookingCreate(bs *booking.Service) echo.HandlerFunc { return func(c echo.Context) error { type NewBooking struct { From time.Time `json:"from"` To time.Time `json:"to"` + ExternalId *string `form:"external_id"` Name string `form:"name"` PhoneNumber string `form:"phone_number"` Email string `form:"email"` Platform string `form:"platform"` - ExternalId *string `form:"external_id"` CustomerNumber int `form:"customer_number"` PlatformFees float64 `form:"platform_fees"` } @@ -77,6 +77,7 @@ func handleCreateBooking(bs *booking.Service) echo.HandlerFunc { nb.ExternalId = nil } b := bs.Create(nb.From, nb.To, nb.Name, nb.PhoneNumber, nb.Email, nb.Platform, nb.CustomerNumber, nb.PlatformFees, nb.ExternalId) + // sync the calendar return c.Redirect(http.StatusSeeOther, fmt.Sprintf("%s/%d", constant.RouteBooking, b.Id)) } } @@ -135,7 +136,7 @@ func handleBookingPage(bs *booking.Service, hc *config.Host) echo.HandlerFunc { } } -func handleUpdateBooking(bs *booking.Service, hc *config.Host) echo.HandlerFunc { +func handleBookingUpdate(bs *booking.Service, hc *config.Host) echo.HandlerFunc { return func(c echo.Context) error { type UpdateBooking struct { From time.Time `json:"from"` @@ -244,7 +245,7 @@ func handleCreateItem(bs *booking.Service) echo.HandlerFunc { } } -func handlePayItem(bs *booking.Service) echo.HandlerFunc { +func handleItemPay(bs *booking.Service) echo.HandlerFunc { return func(c echo.Context) error { itemIdStr := c.Param("id") itemId, err := strconv.Atoi(itemIdStr) @@ -266,7 +267,7 @@ func handlePayItem(bs *booking.Service) echo.HandlerFunc { } } -func handleUpdateItem(bs *booking.Service) echo.HandlerFunc { +func handleItemUpdate(bs *booking.Service) echo.HandlerFunc { return func(c echo.Context) error { type updateItem struct { Item string `form:"item"` @@ -298,7 +299,7 @@ func handleUpdateItem(bs *booking.Service) echo.HandlerFunc { } } -func handleCancelBooking(bs *booking.Service) echo.HandlerFunc { +func handleBookingCancel(bs *booking.Service) echo.HandlerFunc { return func(c echo.Context) error { idStr := c.Param("id") id, err := strconv.Atoi(idStr)