package client_approval_settings

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

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

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

// NewClientApprovalSettingsModule register bulky of ClientApprovalSettings module
var NewClientApprovalSettingsModule = fx.Options(
	// register repository of ClientApprovalSettings module
	fx.Provide(repository.NewClientApprovalSettingsRepository),

	// register service of ClientApprovalSettings module
	fx.Provide(service.NewClientApprovalSettingsService),

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

	// register router of ClientApprovalSettings module
	fx.Provide(NewClientApprovalSettingsRouter),
)

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

// RegisterClientApprovalSettingsRoutes register routes of ClientApprovalSettings
func (_i *ClientApprovalSettingsRouter) RegisterClientApprovalSettingsRoutes() {
	// define controllers
	clientApprovalSettingsController := _i.Controller.ClientApprovalSettings

	// define routes
	_i.App.Route("/client-approval-settings", func(router fiber.Router) {
		// Basic CRUD routes
		router.Post("/", clientApprovalSettingsController.CreateSettings)
		router.Get("/", clientApprovalSettingsController.GetSettings)
		router.Put("/", clientApprovalSettingsController.UpdateSettings)
		router.Delete("/", clientApprovalSettingsController.DeleteSettings)

		// Approval management routes
		router.Post("/toggle-approval", clientApprovalSettingsController.ToggleApproval)
		router.Post("/enable-approval", clientApprovalSettingsController.EnableApproval)
		router.Post("/disable-approval", clientApprovalSettingsController.DisableApproval)
		router.Put("/default-workflow", clientApprovalSettingsController.SetDefaultWorkflow)

		// Exemption management routes
		router.Post("/exempt-users", clientApprovalSettingsController.ManageExemptUsers)
		router.Post("/exempt-roles", clientApprovalSettingsController.ManageExemptRoles)
		router.Post("/exempt-categories", clientApprovalSettingsController.ManageExemptCategories)
	})
}
