package user_agent

import (
	"narasi-ahli-be/app/module/user_agent/controller"
	"narasi-ahli-be/app/module/user_agent/repository"
	"narasi-ahli-be/app/module/user_agent/service"

	"github.com/gofiber/fiber/v2"
	"go.uber.org/fx"
)

type UserAgentRouter struct {
	App        fiber.Router
	Controller *controller.Controller
}

var NewUserAgentModule = fx.Options(

	// repository
	fx.Provide(repository.NewUserAgentRepository),

	// service
	fx.Provide(service.NewUserAgentService),

	// controller
	fx.Provide(controller.NewController),

	// router
	fx.Provide(NewUserAgentRouter),
)

func NewUserAgentRouter(app *fiber.App, controller *controller.Controller) *UserAgentRouter {
	return &UserAgentRouter{
		App:        app,
		Controller: controller,
	}
}

func (r *UserAgentRouter) RegisterUserAgentRoutes() {
	userAgentController := r.Controller.UserAgent

	r.App.Route("/user-agent", func(router fiber.Router) {

		// GET mapping agents by user
		router.Get("/", userAgentController.GetAgentsByUser)

		// UPDATE mapping (replace)
		router.Put("/", userAgentController.UpdateUserAgents)
	})
}
