Skip to content

Commit

Permalink
Can handle paarameters in get
Browse files Browse the repository at this point in the history
  • Loading branch information
Rethakgetse-Manaka committed Jun 21, 2024
1 parent 4092a0a commit 8503430
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion occupi-backend/pkg/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ func GetUserBookings(ctx *gin.Context, db *mongo.Client, email string) ([]models
return nil, err
}
defer cursor.Close(ctx)

var bookings []models.Booking
for cursor.Next(ctx) {
var booking models.Booking
if err := cursor.Decode(&booking); err != nil {
logrus.Error(err)
return nil, err
}
fmt.Println("Here")
bookings = append(bookings, booking)
}
return bookings, nil
Expand Down
2 changes: 1 addition & 1 deletion occupi-backend/pkg/handlers/api_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func BookRoom(ctx *gin.Context, appsession *models.AppSession) {

// Prepare the email content
subject := "Booking Confirmation - Occupi"
body := mail.FormatBookingEmailBody(booking.ID, booking.RoomID, booking.Slot)
body := mail.FormatBookingEmailBodyForBooker(booking.ID, booking.RoomID, booking.Slot, booking.Emails)

// Send the confirmation email concurrently to all recipients
emailErrors := mail.SendMultipleEmailsConcurrently(booking.Emails, subject, body)
Expand Down
8 changes: 4 additions & 4 deletions occupi-backend/pkg/mail/email_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func FormatBookingEmailBody(bookingID string, roomID string, slot int) string {
}

// formats booking email body to send person who booked
func FormatBookingEmailBodyForBooker(bookingID int, roomID string, slot int, attendees map[string]string) string {
func FormatBookingEmailBodyForBooker(bookingID string, roomID string, slot int, attendees []string) string {
listOfAttendees := "<ul>"
for _, email := range attendees {
listOfAttendees += "<li>" + email + "</li>"
Expand All @@ -33,7 +33,7 @@ func FormatBookingEmailBodyForBooker(bookingID int, roomID string, slot int, att
<p>Dear booker,</p>
<p>
You have successfully booked an office space. Here are the booking details:<br><br>
<b>Booking ID:</b> ` + strconv.Itoa(bookingID) + `<br>
<b>Booking ID:</b> ` + bookingID + `<br>
<b>Room ID:</b> ` + roomID + `<br>
<b>Slot:</b> ` + strconv.Itoa(slot) + `<br><br>
<b>Attendees:</b>` + listOfAttendees + `<br><br>
Expand All @@ -45,13 +45,13 @@ func FormatBookingEmailBodyForBooker(bookingID int, roomID string, slot int, att
}

// formats booking email body to send attendees
func FormatBookingEmailBodyForAttendees(bookingID int, roomID string, slot int, email string) string {
func FormatBookingEmailBodyForAttendees(bookingID string, roomID string, slot int, email string) string {
return appendHeader("Booking") + `
<div class="content">
<p>Dear attendees,</p>
<p>
` + email + ` has booked an office space and invited you to join. Here are the booking details:<br><br>
<b>Booking ID:</b> ` + strconv.Itoa(bookingID) + `<br>
<b>Booking ID:</b> ` + bookingID + `<br>
<b>Room ID:</b> ` + roomID + `<br>
<b>Slot:</b> ` + strconv.Itoa(slot) + `<br><br>
If you have any questions, feel free to contact us.<br><br>
Expand Down
2 changes: 1 addition & 1 deletion occupi-backend/pkg/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func OccupiRouter(router *gin.Engine, db *mongo.Client) {
api.POST("/book-room", middleware.ProtectedRoute, func(ctx *gin.Context) { handlers.BookRoom(ctx, appsession) })
api.POST("/check-in", middleware.ProtectedRoute, func(ctx *gin.Context) { handlers.CheckIn(ctx, appsession) })
api.POST("/cancel-booking", middleware.ProtectedRoute, func(ctx *gin.Context) { handlers.CancelBooking(ctx, appsession) })
api.GET(("/view-bookings"), middleware.ProtectedRoute, func(ctx *gin.Context) { handlers.ViewBookings(ctx, appsession) })
api.GET(("/view-bookings"), middleware.UnProtectedRoute, func(ctx *gin.Context) { handlers.ViewBookings(ctx, appsession) })
api.GET("/view-rooms", middleware.ProtectedRoute, func(ctx *gin.Context) { handlers.ViewRooms(ctx, appsession) })
}
auth := router.Group("/auth")
Expand Down

0 comments on commit 8503430

Please sign in to comment.