2024-07-05 22:35:42 -06:00
|
|
|
package pages
|
|
|
|
|
|
|
|
import (
|
|
|
|
"pollo/lib"
|
|
|
|
|
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
)
|
|
|
|
|
|
|
|
type RoomProps struct {
|
2024-07-09 11:10:32 -06:00
|
|
|
Room lib.Room
|
2024-07-05 22:35:42 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func Room(c echo.Context) error {
|
|
|
|
// Get the room ID from the URL
|
|
|
|
roomID := c.Param("id")
|
2024-07-09 11:59:06 -06:00
|
|
|
|
|
|
|
// Initialize the page error
|
|
|
|
pageError := lib.Error{}
|
2024-07-05 22:35:42 -06:00
|
|
|
|
|
|
|
// Get the room from the database
|
2024-11-21 00:48:45 -06:00
|
|
|
room, err := lib.GetRoomById(lib.GetDB(), roomID)
|
2024-07-05 22:35:42 -06:00
|
|
|
if err != nil {
|
2024-07-09 11:59:06 -06:00
|
|
|
pageError = lib.Error{
|
|
|
|
Code: 404,
|
|
|
|
Message: "Room not found",
|
|
|
|
}
|
|
|
|
|
|
|
|
props := RoomProps{}
|
|
|
|
|
|
|
|
// Specify the partials used by this page
|
|
|
|
partials := []string{"header"}
|
|
|
|
|
|
|
|
// Render the template
|
|
|
|
return lib.RenderTemplate(c, "base", partials, props, pageError)
|
2024-07-05 22:35:42 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
props := RoomProps{
|
2024-07-09 11:10:32 -06:00
|
|
|
Room: *room,
|
2024-07-05 22:35:42 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Specify the partials used by this page
|
|
|
|
partials := []string{"header"}
|
|
|
|
|
|
|
|
// Render the template
|
2024-07-09 11:59:06 -06:00
|
|
|
return lib.RenderTemplate(c, "base", partials, props, pageError)
|
2024-07-05 22:35:42 -06:00
|
|
|
}
|