package master_statuses

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

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

// register bulky of MasterStatuses module
var NewMasterStatusesModule = fx.Options(
	// register repository of MasterStatuses module
	fx.Provide(repository.NewMasterStatusesRepository),

	// register service of MasterStatuses module
	fx.Provide(service.NewMasterStatusesService),

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

	// register router of MasterStatuses module
	fx.Provide(NewMasterStatusesRouter),
)

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

// register routes of MasterStatuses module
func (_i *MasterStatusesRouter) RegisterMasterStatusesRoutes() {
	// define controllers
	masterStatusesController := _i.Controller.MasterStatuses

	// define routes
	_i.App.Route("/master-statuses", func(router fiber.Router) {
		router.Get("/", masterStatusesController.All)
		router.Get("/:id", masterStatusesController.Show)
		router.Post("/", masterStatusesController.Save)
		router.Put("/:id", masterStatusesController.Update)
		router.Delete("/:id", masterStatusesController.Delete)
	})
}