package routes

import (
	"GoMembership/internal/controllers"
	"GoMembership/internal/middlewares"

	"github.com/gin-gonic/gin"
)

func RegisterRoutes(router *gin.Engine, userController *controllers.UserController, membershipcontroller *controllers.MembershipController, contactController *controllers.ContactController, licenceController *controllers.LicenceController) {
	router.GET("/users/verify", userController.VerifyMailHandler)
	router.POST("/users/register", userController.RegisterUser)
	router.POST("/users/contact", contactController.RelayContactRequest)

	router.POST("/users/login", userController.LoginHandler)
	router.POST("/csp-report", middlewares.CSPReportHandling)

	// apiRouter := router.Group("/api")
	// apiRouter.Use(middlewares.APIKeyMiddleware())
	// {
	// 	apiRouter.POST("/v1/subscription", membershipcontroller.RegisterSubscription)
	// }

	userRouter := router.Group("/backend")
	userRouter.Use(middlewares.AuthMiddleware())
	{
		userRouter.GET("/users/current", userController.CurrentUserHandler)
		userRouter.POST("/logout", userController.LogoutHandler)
		userRouter.PATCH("/users", userController.UpdateHandler)
		userRouter.POST("/users", userController.RegisterUser)
		userRouter.GET("/users/all", userController.GetAllUsers)
		userRouter.DELETE("/users", userController.DeleteUser)
	}

	membershipRouter := router.Group("/backend/membership")
	membershipRouter.Use(middlewares.AuthMiddleware())
	{
		membershipRouter.GET("/subscriptions", membershipcontroller.GetSubscriptions)
		membershipRouter.PATCH("/subscriptions", membershipcontroller.UpdateHandler)
		membershipRouter.POST("/subscriptions", membershipcontroller.RegisterSubscription)
		membershipRouter.DELETE("/subscriptions", membershipcontroller.DeleteSubscription)
	}

	licenceRouter := router.Group("/backend/licence")
	licenceRouter.Use(middlewares.AuthMiddleware())
	{
		licenceRouter.GET("/categories", licenceController.GetAllCategories)
	}
}
