diff --git a/constants/platforms.go b/constants/platforms.go new file mode 100644 index 0000000..3a5e1f3 --- /dev/null +++ b/constants/platforms.go @@ -0,0 +1,3 @@ +package constants + +var Platforms = []string{"Booking", "AirBnb", "TripAdvisor", "Other"} diff --git a/constants/routes.go b/constants/routes.go new file mode 100644 index 0000000..7480fdb --- /dev/null +++ b/constants/routes.go @@ -0,0 +1,6 @@ +package constants + +const ( + RouteBooking = "/bookings" + RouteNewBooking = "bookings/new" +) diff --git a/internal/server/handlers.go b/internal/server/handlers.go index 7de8555..76a1add 100644 --- a/internal/server/handlers.go +++ b/internal/server/handlers.go @@ -5,6 +5,7 @@ import ( "github.com/labstack/echo/v4" + "github.com/rjNemo/rentease/constants" "github.com/rjNemo/rentease/internal/views" ) @@ -15,6 +16,13 @@ func (s Server) handleHomePage() echo.HandlerFunc { } } +func (s Server) handleNewBookingPage() echo.HandlerFunc { + return func(c echo.Context) error { + component := views.NewBooking(constants.Platforms) + return s.renderTempl(c, http.StatusOK, component) + } +} + //func (s Server) handleLoginPage() echo.HandlerFunc { // return func(c echo.Context) error { // qs := c.QueryParams() diff --git a/internal/server/server.go b/internal/server/server.go index 7d03f70..919cd8c 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -14,6 +14,8 @@ import ( "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "gorm.io/gorm" + + "github.com/rjNemo/rentease/constants" ) type Server struct { @@ -47,6 +49,7 @@ func (s Server) MountHandlers() { s.Router.Static("/static", "assets") // landing page s.Router.GET("/", s.handleHomePage()) + s.Router.GET(constants.RouteNewBooking, s.handleNewBookingPage()) } func (s Server) Start() { diff --git a/internal/views/bookings_new.templ b/internal/views/bookings_new.templ new file mode 100644 index 0000000..6fcad65 --- /dev/null +++ b/internal/views/bookings_new.templ @@ -0,0 +1,58 @@ +package views + + +templ NewBooking(platforms []string) { + @BaseLayout() { +
+

New Booking

+

Create a new booking

+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ } +} diff --git a/internal/views/bookings_new_templ.go b/internal/views/bookings_new_templ.go new file mode 100644 index 0000000..93aeb93 --- /dev/null +++ b/internal/views/bookings_new_templ.go @@ -0,0 +1,176 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: 0.2.476 +package views + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import "context" +import "io" +import "bytes" + +func NewBooking(platforms []string) 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) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var2 := 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) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Var3 := `New Booking ` + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var3) + 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 + } + templ_7745c5c3_Var4 := `Create a new booking ` + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var4) + 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 + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = io.Copy(templ_7745c5c3_W, templ_7745c5c3_Buffer) + } + return templ_7745c5c3_Err + }) + templ_7745c5c3_Err = BaseLayout().Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +}