package ppid_datas

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

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

// register bulky of PpidDatas module
var NewPpidDatasModule = fx.Options(
	// register repository of PpidDatas module
	fx.Provide(repository.NewPpidDatasRepository),

	// register service of PpidDatas module
	fx.Provide(service.NewPpidDatasService),

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

	// register router of PpidDatas module
	fx.Provide(NewPpidDatasRouter),
)

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

// register routes of PpidDatas module
func (_i *PpidDatasRouter) RegisterPpidDatasRoutes() {
	// define controllers
	ppidDatasController := _i.Controller.PpidDatas

	// define routes
	_i.App.Route("/ppid-datas", func(router fiber.Router) {
		router.Get("/", ppidDatasController.All)
		router.Get("/:id", ppidDatasController.Show)
		router.Post("/", ppidDatasController.Save)
		router.Put("/:id", ppidDatasController.Update)
		router.Put("/approval", ppidDatasController.UpdateApprovalStatus)
		router.Delete("/:id", ppidDatasController.Delete)
	})
}
