package routes

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

func RegisterContactInfoRoutes(router *gin.RouterGroup, db *gorm.DB) {
	contactInfoController := controllers.NewContactInfoController(db)

	// Public endpoints (no auth required)
	router.GET("/contacts", contactInfoController.GetPublicContacts)
	router.GET("/contacts/categories", contactInfoController.GetPublicContactCategories)

	// Admin endpoints (require auth + admin role)
	admin := router.Group("/admin/contacts")
	admin.Use(middleware.JWTAuth(db))
	admin.Use(middleware.RoleAuth("admin"))
	{
		// Contact Categories CRUD
		admin.GET("/categories", contactInfoController.GetContactCategories)
		admin.POST("/categories", contactInfoController.CreateContactCategory)
		admin.PUT("/categories/:id", contactInfoController.UpdateContactCategory)
		admin.DELETE("/categories/:id", contactInfoController.DeleteContactCategory)

		// Contacts CRUD
		admin.GET("", contactInfoController.GetContacts)
		admin.POST("", contactInfoController.CreateContact)
		admin.PUT("/:id", contactInfoController.UpdateContact)
		admin.DELETE("/:id", contactInfoController.DeleteContact)
	}
}
