package about_us_contents

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

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

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

// register module
var NewAboutUsContentsModule = fx.Options(
	// repository
	fx.Provide(repository.NewAboutUsContentRepository),

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

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

	// router
	fx.Provide(NewAboutUsContentsRouter),
)

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

// register routes
func (_i *AboutUsContentsRouter) RegisterAboutUsContentsRoutes() {
	aboutController := _i.Controller.AboutUsContent

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

		// BASIC CRUD (mirip articles tapi tanpa middleware & fitur tambahan)
		router.Get("/", aboutController.All)        // get all
		router.Get("/:id", aboutController.Show)    // get by id
		router.Post("/", aboutController.Save)      // create
		router.Put("/:id", aboutController.Update)  // update
		router.Delete("/:id", aboutController.Delete) // delete
	})
}