package api

import (
	"github.com/gofiber/fiber/v2"

	"wucher/internal/service"
	"wucher/internal/transport/http/handlers"
	"wucher/internal/transport/http/middleware"
)

func registerUserRoutes(
	v1 fiber.Router,
	userHandler *handlers.UserHandler,
	eventsHandler *handlers.FileManagerEventsHandler,
	authMiddleware fiber.Handler,
	authSvc *service.AuthService,
) {
	users := v1.Group("/users", authMiddleware)
	users.Get("/events", middleware.PermissionRequired(authSvc, "user.read"), eventsHandler.Stream)
	users.Post("/create", middleware.PermissionRequired(authSvc, "user.create"), userHandler.Create)
	users.Get("/get-all", middleware.PermissionRequired(authSvc, "user.read"), userHandler.List)
	users.Get("/get-all/dt", middleware.PermissionRequired(authSvc, "user.read"), userHandler.ListDatatable)
	users.Get("/get/:uuid", middleware.PermissionRequired(authSvc, "user.read"), userHandler.Get)
	users.Patch("/update/:uuid", middleware.PermissionRequired(authSvc, "user.update"), userHandler.Update)
	users.Delete("/delete/:uuid", middleware.PermissionRequired(authSvc, "user.delete"), userHandler.Delete)
}
