package approval_workflow_steps

import (
	"github.com/gofiber/fiber/v2"
	"go.uber.org/fx"
	"netidhub-saas-be/app/module/approval_workflow_steps/controller"
	"netidhub-saas-be/app/module/approval_workflow_steps/repository"
	"netidhub-saas-be/app/module/approval_workflow_steps/service"
)

// ApprovalWorkflowStepsRouter struct of ApprovalWorkflowStepsRouter
type ApprovalWorkflowStepsRouter struct {
	App        fiber.Router
	Controller controller.ApprovalWorkflowStepsController
}

// NewApprovalWorkflowStepsModule register bulky of ApprovalWorkflowSteps module
var NewApprovalWorkflowStepsModule = fx.Options(
	// register repository of ApprovalWorkflowSteps module
	fx.Provide(repository.NewApprovalWorkflowStepsRepository),

	// register service of ApprovalWorkflowSteps module
	fx.Provide(service.NewApprovalWorkflowStepsService),

	// register controller of ApprovalWorkflowSteps module
	fx.Provide(controller.NewApprovalWorkflowStepsController),

	// register router of ApprovalWorkflowSteps module
	fx.Provide(NewApprovalWorkflowStepsRouter),
)

// NewApprovalWorkflowStepsRouter init ApprovalWorkflowStepsRouter
func NewApprovalWorkflowStepsRouter(fiber *fiber.App, controller controller.ApprovalWorkflowStepsController) *ApprovalWorkflowStepsRouter {
	return &ApprovalWorkflowStepsRouter{
		App:        fiber,
		Controller: controller,
	}
}

// RegisterApprovalWorkflowStepsRoutes register routes of ApprovalWorkflowSteps module
func (_i *ApprovalWorkflowStepsRouter) RegisterApprovalWorkflowStepsRoutes() {
	// define controllers
	approvalWorkflowStepsController := _i.Controller

	// define routes
	_i.App.Route("/approval-workflow-steps", func(router fiber.Router) {
		router.Get("/", approvalWorkflowStepsController.All)
		router.Get("/:id", approvalWorkflowStepsController.Show)
		router.Post("/", approvalWorkflowStepsController.Save)
		router.Put("/:id", approvalWorkflowStepsController.Update)
		router.Delete("/:id", approvalWorkflowStepsController.Delete)
		router.Get("/workflow/:workflowId", approvalWorkflowStepsController.GetByWorkflow)
		router.Get("/role/:roleId", approvalWorkflowStepsController.GetByRole)
		router.Post("/bulk", approvalWorkflowStepsController.BulkSave)
		router.Put("/workflow/:workflowId/reorder", approvalWorkflowStepsController.Reorder)
	})
}
