package ppid_data_approval_histories

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

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

// register bulky of PpidDataApprovalHistories module
var NewPpidDataApprovalHistoriesModule = fx.Options(
	// register repository of PpidDataApprovalHistories module
	fx.Provide(repository.NewPpidDataApprovalHistoriesRepository),

	// register service of PpidDataApprovalHistories module
	fx.Provide(service.NewPpidDataApprovalHistoriesService),

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

	// register router of PpidDataApprovalHistories module
	fx.Provide(NewPpidDataApprovalHistoriesRouter),
)

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

// register routes of PpidDataApprovalHistories module
func (_i *PpidDataApprovalHistoriesRouter) RegisterPpidDataApprovalHistoriesRoutes() {
	// define controllers
	ppidDataApprovalHistoriesController := _i.Controller.PpidDataApprovalHistories

	// define routes
	_i.App.Route("/ppid-data-approval-histories", func(router fiber.Router) {
		router.Get("/", ppidDataApprovalHistoriesController.All)
		router.Get("/:id", ppidDataApprovalHistoriesController.Show)
		router.Get("/ppid-data/:ppidDataId", ppidDataApprovalHistoriesController.ShowByPpidData)
		router.Post("/", ppidDataApprovalHistoriesController.Save)
		router.Delete("/:id", ppidDataApprovalHistoriesController.Delete)
	})
}
