more frontend formatting and logic for locations and rooms

This commit is contained in:
2022-03-28 22:47:37 -04:00
parent 02a9c6c99c
commit 36fe4ca701
10 changed files with 273 additions and 57 deletions

View File

@@ -231,6 +231,18 @@ func (s *Server) AddNewRoomHandler(c *fiber.Ctx) error {
if err != nil {
return err
}
// Update our location in the db to add the new room as attached to the ID
loc, err = s.GetLocation(newRoom.LocationID)
if err != nil {
return err
}
roomList := loc.Rooms
roomList = append(roomList, newRoom)
err = s.Database.UpdateField(&Location{ID: newRoom.LocationID}, "Rooms", roomList)
if err != nil {
return err
}
s.Log.Debug().Msgf("Adding new Room: %v", newRoom)
return c.Status(fiber.StatusOK).SendString(fmt.Sprintf("New Room Created! %s", newRoom.Name))
}