package about_us_content_images

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

	"web-qudo-be/app/module/about_us_content_images/controller"
	"web-qudo-be/app/module/about_us_content_images/repository"
	"web-qudo-be/app/module/about_us_content_images/service"
)

// struct router
type AboutUsContentImageRouter struct {
	App        fiber.Router
	Controller *controller.Controller
}

// register module
var NewAboutUsContentImageModule = fx.Options(
	// repository
	fx.Provide(repository.NewAboutUsContentImageRepository),

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

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

	// router
	fx.Provide(NewAboutUsContentImageRouter),
)

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

// register routes
func (_i *AboutUsContentImageRouter) RegisterAboutUsContentImageRoutes() {

	aboutUsContentImageController := _i.Controller.AboutUsContentImage

	_i.App.Route("/about-us-content-images", func(router fiber.Router) {

		router.Get("/", aboutUsContentImageController.All)
		router.Post("/url", aboutUsContentImageController.SaveRemote)
		router.Get("/:id", aboutUsContentImageController.Show)

		// upload image (pakai form-data)
		router.Post("/", aboutUsContentImageController.Save)

		router.Delete("/:id", aboutUsContentImageController.Delete)
	})
}