package routes

import (
	"fotbal-club/internal/controllers"
	"fotbal-club/internal/middleware"
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
)

func RegisterEventRoutes(router *gin.RouterGroup, db *gorm.DB) {
	eventController := controllers.EventController{DB: db}
	
	events := router.Group("/events")
	{
		events.GET("", eventController.GetEvents)
		events.GET("/upcoming", eventController.GetUpcomingEvents)
		// Public single event endpoint
		events.GET(":id", eventController.GetEventByID)
		
		// Protected routes
		authorized := events.Group("")
		authorized.Use(middleware.JWTAuth(db))
		{
			authorized.POST("", eventController.CreateEvent)
			authorized.PUT(":id", eventController.UpdateEvent)
			authorized.DELETE(":id", eventController.DeleteEvent)
		}
	}
}
