package knowledge_base

import (
	"narasi-ahli-be/app/module/knowledge_base/controller"
	"narasi-ahli-be/app/module/knowledge_base/repository"
	"narasi-ahli-be/app/module/knowledge_base/service"

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

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

// register bulky of KnowledgeBase module
var NewKnowledgeBaseModule = fx.Options(
	// register repository of KnowledgeBase module
	fx.Provide(repository.NewKnowledgeBaseRepository),

	// register service of KnowledgeBase module
	fx.Provide(service.NewKnowledgeBaseService),

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

	// register router of KnowledgeBase module
	fx.Provide(NewKnowledgeBaseRouter),
)

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

// register routes of KnowledgeBase module
func (r *KnowledgeBaseRouter) RegisterKnowledgeBaseRoutes() {
	kbController := r.Controller.KnowledgeBase

	r.App.Route("/knowledge-base", func(router fiber.Router) {
		router.Get("/", kbController.All)
		router.Get("/:id", kbController.Show)
		router.Post("/", kbController.Create)
		router.Put("/:id", kbController.Update)
		router.Delete("/:id", kbController.Delete)
		router.Get("/viewer/:filename", kbController.Viewer)
		router.Patch("/:id/status", kbController.UpdateStatus)
		router.Patch("/:id/document", kbController.UpdateDocumentId)


	})
}
