package partner_contents

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

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

type PartnerContentsRouter struct {
	App        fiber.Router
	Controller *controller.Controller
}

var NewPartnerContentsModule = fx.Options(
	// repository
	fx.Provide(repository.NewPartnerContentRepository),

	// service
	fx.Provide(service.NewPartnerContentService),

	// controller
	fx.Provide(controller.NewController),

	// router
	fx.Provide(NewPartnerContentsRouter),
)

// init router
func NewPartnerContentsRouter(fiber *fiber.App, controller *controller.Controller) *PartnerContentsRouter {
	return &PartnerContentsRouter{
		App:        fiber,
		Controller: controller,
	}
}

func (_i *PartnerContentsRouter) RegisterPartnerContentsRoutes() {
	partnerController := _i.Controller.PartnerContent

	_i.App.Route("/partner-contents", func(router fiber.Router) {
		router.Get("/", partnerController.Show)
		router.Post("/", partnerController.Save)
		router.Post("/:id/logo", partnerController.UploadLogo)
		router.Put("/:id", partnerController.Update)
		router.Delete("/:id", partnerController.Delete)
	})
}