diff --git a/internal/booking/models.go b/internal/booking/models.go index 6ea0f7a..415447c 100644 --- a/internal/booking/models.go +++ b/internal/booking/models.go @@ -23,6 +23,24 @@ type Booking struct { PlatformFees float64 `gorm:"type:decimal(10,2)"` } +func (b Booking) InvoiceNumber(hc *config.Host) string { + return fmt.Sprintf("%s%04s", hc.InvoicePrefix, strconv.Itoa(b.Id+hc.CustomerSeed)) +} + +type BookingRequest struct { + From time.Time + To time.Time + gorm.Model + CustomerName string + PhoneNumber *string // ensure at least one out of these is not null + Email *string + ItemType string + Message string + Status string + CustomerNumber int + BookingId int +} + type Item struct { gorm.Model Item string @@ -33,7 +51,3 @@ type Item struct { Quantity int Price float64 `gorm:"type:decimal(10,2)"` } - -func (b Booking) InvoiceNumber(hc *config.Host) string { - return fmt.Sprintf("%s%04s", hc.InvoicePrefix, strconv.Itoa(b.Id+hc.CustomerSeed)) -} diff --git a/internal/booking/service.go b/internal/booking/service.go index 911f471..886ecdb 100644 --- a/internal/booking/service.go +++ b/internal/booking/service.go @@ -6,7 +6,6 @@ import ( "time" u "github.com/rjNemo/underscore" - "gorm.io/gorm" "github.com/rjNemo/rentease/config" diff --git a/internal/server/handle_public.go b/internal/server/handle_public.go index 7751509..af3b32b 100644 --- a/internal/server/handle_public.go +++ b/internal/server/handle_public.go @@ -11,13 +11,14 @@ import ( func handleHomePage(hc *config.Host) echo.HandlerFunc { return func(ctx echo.Context) error { - return renderTempl(ctx, http.StatusOK, view.Index(&view.HostViewModel{ + return renderTempl(ctx, http.StatusOK, view.Index(&view.HomePageViewModel{ Name: hc.Name, Address: hc.Address, ZipCode: hc.ZipCode, City: hc.City, PhoneNumber: hc.PhoneNumber, Email: hc.Email, + Items: hc.Items, })) } } diff --git a/internal/view/index.templ b/internal/view/index.templ index cb02c8c..7dd35b3 100644 --- a/internal/view/index.templ +++ b/internal/view/index.templ @@ -1,16 +1,21 @@ package view -type HostViewModel struct { +import ( + "github.com/rjNemo/rentease/config" +) + +type HomePageViewModel struct { Name string Address string ZipCode string City string PhoneNumber string Email string + Items []config.HostItem } -templ Index(host *HostViewModel) { - @BaseLayout() { +templ Index(host *HomePageViewModel) { + @PublicLayout() {
{ host.Name }
@@ -23,5 +28,48 @@ templ Index(host *HostViewModel) {
+
+
+
+
+ + + +
+
+ + + +
+ + +
+
+
} } diff --git a/internal/view/public.templ b/internal/view/public.templ new file mode 100644 index 0000000..6cf45dc --- /dev/null +++ b/internal/view/public.templ @@ -0,0 +1,32 @@ +package view + +templ PublicLayout() { + + + + RentEase | Your Property Management System + + + + + + + + + +
+ { children... } +
+ + + +} diff --git a/main.go b/main.go index 8858352..dff5e05 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,7 @@ func main() { log.Fatalf("error connecting to the database %s\n", err) } - err = db.AutoMigrate(&booking.Booking{}, &booking.Item{}) + err = db.AutoMigrate(&booking.Booking{}, &booking.BookingRequest{}, &booking.Item{}) if err != nil { log.Fatalf("error migrating the database %s\n", err) }