package approval_workflows

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

	// articleCategoriesRepo "netidhub-saas-be/app/module/article_categories/repository"
	// clientApprovalSettingsRepo "netidhub-saas-be/app/module/client_approval_settings/repository"
	// userLevelsRepo "netidhub-saas-be/app/module/user_levels/repository"
	// userRolesRepo "netidhub-saas-be/app/module/user_roles/repository"
	// usersRepo "netidhub-saas-be/app/module/users/repository"

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

// ApprovalWorkflowsRouter struct of ApprovalWorkflowsRouter
type ApprovalWorkflowsRouter struct {
	App        fiber.Router
	Controller controller.ApprovalWorkflowsController
}

// NewApprovalWorkflowsModule register bulky of ApprovalWorkflows module
var NewApprovalWorkflowsModule = fx.Options(
	// register repository of ApprovalWorkflows module
	fx.Provide(repository.NewApprovalWorkflowsRepository),

	// fx.Provide(clientApprovalSettingsRepo.NewClientApprovalSettingsRepository),
	// fx.Provide(usersRepo.NewUsersRepository),
	// fx.Provide(userLevelsRepo.NewUserLevelsRepository),
	// fx.Provide(userRolesRepo.NewUserRolesRepository),
	// fx.Provide(articleCategoriesRepo.NewArticleCategoriesRepository),

	// register service of ApprovalWorkflows module
	fx.Provide(service.NewApprovalWorkflowsService),

	// register controller of ApprovalWorkflows module
	fx.Provide(controller.NewApprovalWorkflowsController),

	// register router of ApprovalWorkflows module
	fx.Provide(NewApprovalWorkflowsRouter),
)

// NewApprovalWorkflowsRouter init ApprovalWorkflowsRouter
func NewApprovalWorkflowsRouter(fiber *fiber.App, controller controller.ApprovalWorkflowsController) *ApprovalWorkflowsRouter {
	return &ApprovalWorkflowsRouter{
		App:        fiber,
		Controller: controller,
	}
}

// RegisterApprovalWorkflowsRoutes register routes of ApprovalWorkflows module
func (_i *ApprovalWorkflowsRouter) RegisterApprovalWorkflowsRoutes() {
	// define controllers
	approvalWorkflowsController := _i.Controller

	// define routes
	_i.App.Route("/approval-workflows", func(router fiber.Router) {
		router.Get("/", approvalWorkflowsController.All)
		router.Get("/default", approvalWorkflowsController.GetDefault)
		router.Get("/detail/:id", approvalWorkflowsController.Show)
		router.Get("/:id/with-steps", approvalWorkflowsController.GetWithSteps)
		router.Post("/", approvalWorkflowsController.Save)
		router.Post("/with-steps", approvalWorkflowsController.SaveWithSteps)
		router.Post("/with-client-settings", approvalWorkflowsController.SaveWithClientSettings)
		router.Put("/with-client-settings", approvalWorkflowsController.UpdateWithClientSettings)
		router.Get("/comprehensive-details", approvalWorkflowsController.GetComprehensiveDetails)
		router.Put("/:id", approvalWorkflowsController.Update)
		router.Put("/:id/with-steps", approvalWorkflowsController.UpdateWithSteps)
		router.Put("/:id/set-default", approvalWorkflowsController.SetDefault)
		router.Put("/:id/activate", approvalWorkflowsController.Activate)
		router.Put("/:id/deactivate", approvalWorkflowsController.Deactivate)
		router.Delete("/:id", approvalWorkflowsController.Delete)
	})
}
