package work_history

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

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

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

// register bulky of WorkHistory module
var NewWorkHistoryModule = fx.Options(
	// register repository of WorkHistory module
	fx.Provide(repository.NewWorkHistoryRepository),

	// register service of WorkHistory module
	fx.Provide(service.NewWorkHistoryService),

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

	// register router of WorkHistory module
	fx.Provide(NewWorkHistoryRouter),
)

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

// register routes of WorkHistory module
func (_i *WorkHistoryRouter) RegisterWorkHistoryRoutes() {
	// define controllers
	workHistoryController := _i.Controller.WorkHistory

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