diff --git a/internal/handlers/booking.go b/internal/handlers/booking.go index b43259a..9648cff 100644 --- a/internal/handlers/booking.go +++ b/internal/handlers/booking.go @@ -14,6 +14,19 @@ import ( "decor-by-hannahs/internal/db" ) +func getServiceIDFromOption(option string) int64 { + serviceMap := map[string]int64{ + "Small Bundle": 1, + "Medium Bundle": 2, + "Large Bundle": 3, + "Balloons Only": 4, + } + if id, ok := serviceMap[option]; ok { + return id + } + return 1 +} + func validateAustralianAddress(address string) (bool, string) { if len(strings.TrimSpace(address)) < 10 { return false, "Address is too short. Please provide a complete address." @@ -125,10 +138,11 @@ func BookingAPIHandler(q *db.Queries, tmpl *template.Template, oryClient *ory.AP } userID := sql.NullInt64{Int64: user.ID, Valid: true} + serviceID := getServiceIDFromOption(in.ServiceOption) booking, err := q.CreateBooking(r.Context(), db.CreateBookingParams{ UserID: userID, - ServiceID: sql.NullInt64{}, + ServiceID: sql.NullInt64{Int64: serviceID, Valid: true}, EventDate: eventTime, Address: sqlNullString(in.Address), Notes: sqlNullString(in.Notes),