package activity_logs

import (
	"web-qudo-be/app/module/activity_logs/controller"
	"web-qudo-be/app/module/activity_logs/repository"
	"web-qudo-be/app/module/activity_logs/service"

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

// struct of ActivityLogsRouter
type ActivityLogsRouter struct {
	App        fiber.Router
	Controller *controller.Controller
}

// register bulky of ActivityLogs module
var NewActivityLogsModule = fx.Options(
	// register repository of ActivityLogs module
	fx.Provide(repository.NewActivityLogsRepository),

	// register service of ActivityLogs module
	fx.Provide(service.NewActivityLogsService),

	// register controller of ActivityLogs module
	fx.Provide(controller.NewController),

	// register router of ActivityLogs module
	fx.Provide(NewActivityLogsRouter),
)

// init ActivityLogsRouter
func NewActivityLogsRouter(fiber *fiber.App, controller *controller.Controller) *ActivityLogsRouter {
	return &ActivityLogsRouter{
		App:        fiber,
		Controller: controller,
	}
}

// register routes of ActivityLogs module
func (_i *ActivityLogsRouter) RegisterActivityLogsRoutes() {
	// define controllers
	activityLogsController := _i.Controller.ActivityLogs

	// define routes
	_i.App.Route("/activity-logs", func(router fiber.Router) {
		router.Get("/", activityLogsController.All)
		router.Get("/statistics", activityLogsController.GetActivityStats)
		router.Get("/detail/:id", activityLogsController.Show)
		router.Post("/", activityLogsController.Save)
		router.Put("/:id", activityLogsController.Update)
		router.Delete("/:id", activityLogsController.Delete)
	})
}
