mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-09 20:26:51 +00:00
replace unused constants with config values
This commit is contained in:
parent
ff58b79630
commit
f3e266e502
5 changed files with 6 additions and 15 deletions
|
|
@ -1,3 +0,0 @@
|
|||
package constant
|
||||
|
||||
var Items = []string{"T2", "T3", "Airport", "Port", "Taxes"}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
package constant
|
||||
|
||||
var PaymentMethods = []string{"Card", "Cash", "Cheque", "Transfer"}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
package constant
|
||||
|
||||
var Platforms = []string{"Booking", "AirBnb", "TripAdvisor", "Other"}
|
||||
|
|
@ -39,9 +39,9 @@ func handleListBookingPage(bs *booking.Service, hc *config.Host) echo.HandlerFun
|
|||
}
|
||||
}
|
||||
|
||||
func handleNewBookingPage() echo.HandlerFunc {
|
||||
func handleNewBookingPage(hc *config.Host) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
return renderTempl(c, http.StatusOK, view.NewBooking(constant.Platforms))
|
||||
return renderTempl(c, http.StatusOK, view.NewBooking(hc.Platforms))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -109,9 +109,9 @@ func handleBookingPage(bs *booking.Service, hc *config.Host) echo.HandlerFunc {
|
|||
Total: strconv.FormatFloat(u.Reduce(b.Items, func(i booking.Item, sum float64) float64 {
|
||||
return sum + i.Price*float64(i.Quantity)
|
||||
}, 0.0), 'f', 2, 64),
|
||||
Platforms: constant.Platforms,
|
||||
ItemList: constant.Items,
|
||||
PaymentMethods: constant.PaymentMethods,
|
||||
Platforms: hc.Platforms,
|
||||
ItemList: u.Map(hc.Items, func(i config.HostItem) string { return i.Name }),
|
||||
PaymentMethods: hc.PaymentMethods,
|
||||
}
|
||||
component := view.BookingById(bvm)
|
||||
return renderTempl(c, http.StatusOK, component)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ func (s Server) MountHandlers() {
|
|||
s.Router.POST("/request-booking", handleRequestBooking(s.bs))
|
||||
// admin
|
||||
s.Router.GET("/bookings", handleListBookingPage(s.bs, s.hc))
|
||||
s.Router.GET("/bookings/new", handleNewBookingPage())
|
||||
s.Router.GET("/bookings/new", handleNewBookingPage(s.hc))
|
||||
s.Router.POST("/bookings/new", handleCreateBooking(s.bs))
|
||||
s.Router.GET("/bookings/:id", handleBookingPage(s.bs, s.hc))
|
||||
s.Router.POST("/bookings/:id/items", handleCreateItem(s.bs))
|
||||
|
|
|
|||
Loading…
Reference in a new issue