package api

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

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

func registerBaseRoutes(
	v1 fiber.Router,
	baseHandler *handlers.BaseHandler,
	eventsHandler *handlers.FileManagerEventsHandler,
	authMiddleware fiber.Handler,
	authSvc *service.AuthService,
) {
	bases := v1.Group("/bases", authMiddleware)
	bases.Get("/events", middleware.PermissionRequired(authSvc, "base.read"), eventsHandler.Stream)
	bases.Post("/create",
		middleware.PermissionRequired(authSvc, "base.create"),
		baseHandler.CreateBase,
	)
	bases.Get("/get-all", middleware.PermissionRequired(authSvc, "base.read"), baseHandler.ListBases)
	bases.Get("/get-all/dt", middleware.PermissionRequired(authSvc, "base.read"), baseHandler.ListBasesDatatable)
	bases.Get("/get/:uuid", middleware.PermissionRequired(authSvc, "base.read"), baseHandler.GetBase)
	bases.Patch("/update/:uuid",
		middleware.PermissionRequired(authSvc, "base.update"),
		baseHandler.UpdateBase,
	)
	bases.Delete("/delete/:uuid",
		middleware.PermissionRequired(authSvc, "base.delete"),
		baseHandler.DeleteBase,
	)
}
