package campaign_types

import (
	"campaign-pool-be/app/module/campaign_types/controller"
	"campaign-pool-be/app/module/campaign_types/repository"
	"campaign-pool-be/app/module/campaign_types/service"

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

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

// NewCampaignTypesModule register bulky of CampaignTypes module
var NewCampaignTypesModule = fx.Options(
	// register repository of CampaignTypes module
	fx.Provide(repository.NewCampaignTypesRepository),

	// register service of CampaignTypes module
	fx.Provide(service.NewCampaignTypesService),

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

	// register router of CampaignTypes module
	fx.Provide(NewCampaignTypesRouter),
)

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

// RegisterCampaignTypesRoutes register routes of CampaignTypes module
func (_i *CampaignTypesRouter) RegisterCampaignTypesRoutes() {
	// define controllers
	campaignTypesController := _i.Controller.CampaignTypes

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

