package organization

import (
	"github.com/gofiber/fiber/v2"
	"lms.de/backend/modules/database"
	"lms.de/backend/modules/structs"
)

func GetTeamMembers(c *fiber.Ctx) error {
	// swagger:operation GET /organization/team/members organization getTeamMembers
	// ---
	// summary: Get team members
	// consumes:
	// - application/json
	// produces:
	// - application/json
	// responses:
	//   '200':
	//     description: Team members fetched successfully
	//     schema:
	//       type: array
	//       items:
	//         "$ref": "#/definitions/TeamMember"
	//   '400':
	//     description: Invalid request body
	//   '500':
	//     description: Failed to fetch team members

	var users []structs.TeamMember

	database.DB.Model(&structs.User{}).Where("organization_id = ?", c.Locals("organizationId")).Find(&users)

	return c.JSON(users)
}
