package router

import (
	swagger "github.com/arsmn/fiber-swagger/v2"
	"github.com/gofiber/fiber/v2"
	"web-medols-be/app/module/activity_logs"
	"web-medols-be/app/module/advertisement"
	"web-medols-be/app/module/article_approvals"
	"web-medols-be/app/module/article_categories"
	"web-medols-be/app/module/article_category_details"
	"web-medols-be/app/module/article_comments"
	"web-medols-be/app/module/article_files"
	"web-medols-be/app/module/article_nulis_ai"
	"web-medols-be/app/module/articles"
	"web-medols-be/app/module/cities"
	"web-medols-be/app/module/clients"
	"web-medols-be/app/module/custom_static_pages"
	"web-medols-be/app/module/districts"
	"web-medols-be/app/module/feedbacks"
	"web-medols-be/app/module/magazine_files"
	"web-medols-be/app/module/magazines"
	"web-medols-be/app/module/master_menus"
	"web-medols-be/app/module/master_modules"
	"web-medols-be/app/module/provinces"
	"web-medols-be/app/module/subscription"
	"web-medols-be/app/module/user_levels"
	"web-medols-be/app/module/user_role_accesses"
	"web-medols-be/app/module/user_roles"
	"web-medols-be/app/module/users"
	"web-medols-be/config/config"
	_ "web-medols-be/docs/swagger"
)

type Router struct {
	App fiber.Router
	Cfg *config.Config

	ActivityLogsRouter           *activity_logs.ActivityLogsRouter
	AdvertisementRouter          *advertisement.AdvertisementRouter
	ArticleCategoriesRouter      *article_categories.ArticleCategoriesRouter
	ArticleCategoryDetailsRouter *article_category_details.ArticleCategoryDetailsRouter
	ArticleFilesRouter           *article_files.ArticleFilesRouter
	ArticleCommentsRouter        *article_comments.ArticleCommentsRouter
	ArticleApprovalsRouter       *article_approvals.ArticleApprovalsRouter
	ArticlesRouter               *articles.ArticlesRouter
	ArticleNulisAIRouter         *article_nulis_ai.ArticleNulisAIRouter
	CitiesRouter                 *cities.CitiesRouter
	ClientsRouter                *clients.ClientsRouter
	CustomStaticPagesRouter      *custom_static_pages.CustomStaticPagesRouter
	DistrictsRouter              *districts.DistrictsRouter
	FeedbacksRouter              *feedbacks.FeedbacksRouter
	MagazineFilesRouter          *magazine_files.MagazineFilesRouter
	MagazinesRouter              *magazines.MagazinesRouter
	MasterMenusRouter            *master_menus.MasterMenusRouter
	MasterModulesRouter          *master_modules.MasterModulesRouter
	ProvincesRouter              *provinces.ProvincesRouter
	SubscriptionRouter           *subscription.SubscriptionRouter
	UserLevelsRouter             *user_levels.UserLevelsRouter
	UserRoleAccessesRouter       *user_role_accesses.UserRoleAccessesRouter
	UserRolesRouter              *user_roles.UserRolesRouter
	UsersRouter                  *users.UsersRouter
}

func NewRouter(
	fiber *fiber.App,
	cfg *config.Config,

	activityLogsRouter *activity_logs.ActivityLogsRouter,
	advertisementRouter *advertisement.AdvertisementRouter,
	articleCategoriesRouter *article_categories.ArticleCategoriesRouter,
	articleCategoryDetailsRouter *article_category_details.ArticleCategoryDetailsRouter,
	articleFilesRouter *article_files.ArticleFilesRouter,
	articleCommentsRouter *article_comments.ArticleCommentsRouter,
	articleApprovalsRouter *article_approvals.ArticleApprovalsRouter,
	articlesRouter *articles.ArticlesRouter,
	articleNulisRouter *article_nulis_ai.ArticleNulisAIRouter,
	citiesRouter *cities.CitiesRouter,
	clientsRouter *clients.ClientsRouter,
	customStaticPagesRouter *custom_static_pages.CustomStaticPagesRouter,
	districtsRouter *districts.DistrictsRouter,
	feedbacksRouter *feedbacks.FeedbacksRouter,
	magazineFilesRouter *magazine_files.MagazineFilesRouter,
	magazinesRouter *magazines.MagazinesRouter,
	masterMenuRouter *master_menus.MasterMenusRouter,
	masterModuleRouter *master_modules.MasterModulesRouter,
	provincesRouter *provinces.ProvincesRouter,
	subscriptionRouter *subscription.SubscriptionRouter,
	userLevelsRouter *user_levels.UserLevelsRouter,
	userRoleAccessesRouter *user_role_accesses.UserRoleAccessesRouter,
	userRolesRouter *user_roles.UserRolesRouter,
	usersRouter *users.UsersRouter,
) *Router {
	return &Router{
		App:                          fiber,
		Cfg:                          cfg,
		ActivityLogsRouter:           activityLogsRouter,
		AdvertisementRouter:          advertisementRouter,
		ArticleCategoriesRouter:      articleCategoriesRouter,
		ArticleCategoryDetailsRouter: articleCategoryDetailsRouter,
		ArticleFilesRouter:           articleFilesRouter,
		ArticleCommentsRouter:        articleCommentsRouter,
		ArticleApprovalsRouter:       articleApprovalsRouter,
		ArticlesRouter:               articlesRouter,
		ArticleNulisAIRouter:         articleNulisRouter,
		CitiesRouter:                 citiesRouter,
		ClientsRouter:                clientsRouter,
		CustomStaticPagesRouter:      customStaticPagesRouter,
		DistrictsRouter:              districtsRouter,
		FeedbacksRouter:              feedbacksRouter,
		MagazineFilesRouter:          magazineFilesRouter,
		MagazinesRouter:              magazinesRouter,
		MasterMenusRouter:            masterMenuRouter,
		MasterModulesRouter:          masterModuleRouter,
		ProvincesRouter:              provincesRouter,
		SubscriptionRouter:           subscriptionRouter,
		UserLevelsRouter:             userLevelsRouter,
		UserRoleAccessesRouter:       userRoleAccessesRouter,
		UserRolesRouter:              userRolesRouter,
		UsersRouter:                  usersRouter,
	}
}

// Register routes
func (r *Router) Register() {
	// Test Routes
	r.App.Get("/ping", func(c *fiber.Ctx) error {
		return c.SendString("Pong! 👋")
	})

	//Swagger Documentation
	r.App.Get("/swagger/*", swagger.HandlerDefault)

	// Register routes of modules
	r.ActivityLogsRouter.RegisterActivityLogsRoutes()
	r.AdvertisementRouter.RegisterAdvertisementRoutes()
	r.ArticleCategoriesRouter.RegisterArticleCategoriesRoutes()
	r.ArticleCategoryDetailsRouter.RegisterArticleCategoryDetailsRoutes()
	r.ArticleFilesRouter.RegisterArticleFilesRoutes()
	r.ArticleApprovalsRouter.RegisterArticleApprovalsRoutes()
	r.ArticlesRouter.RegisterArticlesRoutes()
	r.ArticleCommentsRouter.RegisterArticleCommentsRoutes()
	r.ArticleNulisAIRouter.RegisterArticleNulisAIRoutes()
	r.CitiesRouter.RegisterCitiesRoutes()
	r.ClientsRouter.RegisterClientsRoutes()
	r.CustomStaticPagesRouter.RegisterCustomStaticPagesRoutes()
	r.DistrictsRouter.RegisterDistrictsRoutes()
	r.FeedbacksRouter.RegisterFeedbacksRoutes()
	r.MagazinesRouter.RegisterMagazinesRoutes()
	r.MagazineFilesRouter.RegisterMagazineFilesRoutes()
	r.MasterMenusRouter.RegisterMasterMenusRoutes()
	r.MasterModulesRouter.RegisterMasterModulesRoutes()
	r.ProvincesRouter.RegisterProvincesRoutes()
	r.SubscriptionRouter.RegisterSubscriptionRoutes()
	r.UserLevelsRouter.RegisterUserLevelsRoutes()
	r.UserRoleAccessesRouter.RegisterUserRoleAccessesRoutes()
	r.UsersRouter.RegisterUsersRoutes()
	r.UserRolesRouter.RegisterUserRolesRoutes()
}
