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("/api/users/verify", userController.VerifyMailHandler)
	router.POST("/api/users/register", userController.RegisterUser)
	router.POST("/api/users/contact", contactController.RelayContactRequest)
	router.POST("/api/users/password/request-change", userController.RequestPasswordChangeHandler)
	router.PATCH("/api/users/password/change/:id", userController.ChangePassword)
	router.POST("/api/users/login", userController.LoginHandler)
	router.POST("/api/csp-report", middlewares.CSPReportHandling)

	userRouter := router.Group("/api/auth")
	userRouter.Use(middlewares.AuthMiddleware())
	{
		userRouter.GET("/users/current", userController.CurrentUserHandler)
		userRouter.POST("/logout", userController.LogoutHandler)
		userRouter.PUT("/users", userController.UpdateHandler)
		userRouter.POST("/users", userController.RegisterUser)
		userRouter.GET("/users", userController.GetAllUsers)
		userRouter.DELETE("/users", userController.DeleteUser)
		userRouter.PATCH("/users/activate", userController.CreatePasswordHandler)
		userRouter.GET("/subscriptions", membershipcontroller.GetSubscriptions)
		userRouter.PUT("/subscriptions", membershipcontroller.UpdateHandler)
		userRouter.POST("/subscriptions", membershipcontroller.RegisterSubscription)
		userRouter.DELETE("/subscriptions", membershipcontroller.DeleteSubscription)
		userRouter.GET("/licence/categories", licenceController.GetAllCategories)
	}
}
