package article_approval_flows

import (
	"github.com/gofiber/fiber/v2"
	"go.uber.org/fx"
	"web-qudo-be/app/module/article_approval_flows/controller"
	"web-qudo-be/app/module/article_approval_flows/repository"
	"web-qudo-be/app/module/article_approval_flows/service"
)

// ArticleApprovalFlowsRouter struct of ArticleApprovalFlowsRouter
type ArticleApprovalFlowsRouter struct {
	App        fiber.Router
	Controller controller.ArticleApprovalFlowsController
}

// NewArticleApprovalFlowsModule register bulky of ArticleApprovalFlows module
var NewArticleApprovalFlowsModule = fx.Options(
	// register repository of ArticleApprovalFlows module
	fx.Provide(repository.NewArticleApprovalFlowsRepository),

	// register service of ArticleApprovalFlows module
	fx.Provide(service.NewArticleApprovalFlowsService),

	// register controller of ArticleApprovalFlows module
	fx.Provide(controller.NewArticleApprovalFlowsController),

	// register router of ArticleApprovalFlows module
	fx.Provide(NewArticleApprovalFlowsRouter),
)

// NewArticleApprovalFlowsRouter init ArticleApprovalFlowsRouter
func NewArticleApprovalFlowsRouter(fiber *fiber.App, controller controller.ArticleApprovalFlowsController) *ArticleApprovalFlowsRouter {
	return &ArticleApprovalFlowsRouter{
		App:        fiber,
		Controller: controller,
	}
}

// RegisterArticleApprovalFlowsRoutes register routes of ArticleApprovalFlows module
func (_i *ArticleApprovalFlowsRouter) RegisterArticleApprovalFlowsRoutes() {
	// define controllers
	articleApprovalFlowsController := _i.Controller

	// define routes
	_i.App.Route("/article-approval-flows", func(router fiber.Router) {
		router.Get("/", articleApprovalFlowsController.All)
		router.Get("/my-queue", articleApprovalFlowsController.GetMyApprovalQueue)
		router.Get("/pending", articleApprovalFlowsController.GetPendingApprovals)
		router.Get("/history", articleApprovalFlowsController.GetApprovalHistory)
		router.Get("/dashboard-stats", articleApprovalFlowsController.GetDashboardStats)
		router.Get("/workload-stats", articleApprovalFlowsController.GetWorkloadStats)
		router.Get("/analytics", articleApprovalFlowsController.GetApprovalAnalytics)
		router.Get("/:id", articleApprovalFlowsController.Show)
		router.Post("/submit", articleApprovalFlowsController.SubmitForApproval)
		router.Put("/:id/approve", articleApprovalFlowsController.Approve)
		router.Put("/:id/reject", articleApprovalFlowsController.Reject)
		router.Put("/:id/request-revision", articleApprovalFlowsController.RequestRevision)
		router.Put("/:id/resubmit", articleApprovalFlowsController.Resubmit)
	})
}