package article_approval_step_logs

import (
	"netidhub-saas-be/app/module/article_approval_step_logs/controller"
	"netidhub-saas-be/app/module/article_approval_step_logs/repository"
	"netidhub-saas-be/app/module/article_approval_step_logs/service"

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

// ArticleApprovalStepLogsRouter struct of ArticleApprovalStepLogsRouter
type ArticleApprovalStepLogsRouter struct {
	App        fiber.Router
	Controller controller.ArticleApprovalStepLogsController
}

// NewArticleApprovalStepLogsModule register bulky of ArticleApprovalStepLogs module
var NewArticleApprovalStepLogsModule = fx.Options(
	// register repository of ArticleApprovalStepLogs module
	fx.Provide(repository.NewArticleApprovalStepLogsRepository),

	// register service of ArticleApprovalStepLogs module
	fx.Provide(service.NewArticleApprovalStepLogsService),

	// register controller of ArticleApprovalStepLogs module
	fx.Provide(controller.NewArticleApprovalStepLogsController),

	// register router of ArticleApprovalStepLogs module
	fx.Provide(NewArticleApprovalStepLogsRouter),
)

// NewArticleApprovalStepLogsRouter init ArticleApprovalStepLogsRouter
func NewArticleApprovalStepLogsRouter(fiber *fiber.App, controller controller.ArticleApprovalStepLogsController) *ArticleApprovalStepLogsRouter {
	return &ArticleApprovalStepLogsRouter{
		App:        fiber,
		Controller: controller,
	}
}

// RegisterArticleApprovalStepLogsRoutes register routes of ArticleApprovalStepLogs module
func (_i *ArticleApprovalStepLogsRouter) RegisterArticleApprovalStepLogsRoutes() {
	// define controllers
	articleApprovalStepLogsController := _i.Controller

	// define routes
	_i.App.Route("/article-approval-step-logs", func(router fiber.Router) {
		router.Get("/", articleApprovalStepLogsController.All)
		router.Get("/:id", articleApprovalStepLogsController.Show)
		router.Post("/", articleApprovalStepLogsController.Save)
		router.Put("/:id", articleApprovalStepLogsController.Update)
		router.Delete("/:id", articleApprovalStepLogsController.Delete)

		// Approval process management routes
		router.Get("/flow/:flow_id", articleApprovalStepLogsController.GetByApprovalFlow)
		router.Get("/step/:step_id", articleApprovalStepLogsController.GetByWorkflowStep)
		router.Get("/approver/:user_id", articleApprovalStepLogsController.GetByApprover)
		router.Get("/pending", articleApprovalStepLogsController.GetPendingApprovals)
		router.Get("/overdue", articleApprovalStepLogsController.GetOverdueApprovals)

		// Approval action routes
		router.Post("/:id/process", articleApprovalStepLogsController.ProcessApproval)
		router.Post("/bulk-process", articleApprovalStepLogsController.BulkProcessApproval)
		router.Post("/:id/auto-approve", articleApprovalStepLogsController.AutoApprove)

		// History and analytics routes
		router.Get("/history", articleApprovalStepLogsController.GetApprovalHistory)
		router.Get("/stats", articleApprovalStepLogsController.GetApprovalStats)
		router.Get("/user/:user_id/workload", articleApprovalStepLogsController.GetUserWorkload)
	})
}
