package article_approvals

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

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

// register bulky of ArticleApprovals module
var NewArticleApprovalsModule = fx.Options(
	// register repository of ArticleApprovals module
	fx.Provide(repository.NewArticleApprovalsRepository),

	// register service of ArticleApprovals module
	fx.Provide(service.NewArticleApprovalsService),

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

	// register router of ArticleApprovals module
	fx.Provide(NewArticleApprovalsRouter),
)

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

// register routes of ArticleApprovals module
func (_i *ArticleApprovalsRouter) RegisterArticleApprovalsRoutes() {
	// define controllers
	articleApprovalsController := _i.Controller.ArticleApprovals

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