package router

import (
	"jaecoo-be/app/module/activity_logs"
	"jaecoo-be/app/module/article_approvals"
	"jaecoo-be/app/module/article_categories"
	"jaecoo-be/app/module/article_category_details"
	"jaecoo-be/app/module/article_comments"
	"jaecoo-be/app/module/article_files"
	"jaecoo-be/app/module/articles"
	"jaecoo-be/app/module/banners"
	"jaecoo-be/app/module/cities"
	"jaecoo-be/app/module/custom_static_pages"
	"jaecoo-be/app/module/districts"
	"jaecoo-be/app/module/feedbacks"
	"jaecoo-be/app/module/galleries"
	"jaecoo-be/app/module/gallery_files"
	"jaecoo-be/app/module/product_specifications"
	"jaecoo-be/app/module/products"
	"jaecoo-be/app/module/promotions"
	"jaecoo-be/app/module/provinces"
	"jaecoo-be/app/module/sales_agents"
	"jaecoo-be/app/module/user_levels"
	"jaecoo-be/app/module/user_role_accesses"
	"jaecoo-be/app/module/user_roles"
	"jaecoo-be/app/module/users"
	"jaecoo-be/config/config"
	_ "jaecoo-be/docs/swagger"

	swagger "github.com/arsmn/fiber-swagger/v2"
	"github.com/gofiber/fiber/v2"
)

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

	ActivityLogsRouter           *activity_logs.ActivityLogsRouter
	ArticleCategoriesRouter      *article_categories.ArticleCategoriesRouter
	ArticleCategoryDetailsRouter *article_category_details.ArticleCategoryDetailsRouter
	ArticleFilesRouter           *article_files.ArticleFilesRouter
	ArticleCommentsRouter        *article_comments.ArticleCommentsRouter
	ArticleApprovalsRouter       *article_approvals.ArticleApprovalsRouter
	ArticlesRouter               *articles.ArticlesRouter
	BannersRouter                *banners.BannersRouter
	CitiesRouter                 *cities.CitiesRouter
	CustomStaticPagesRouter      *custom_static_pages.CustomStaticPagesRouter
	DistrictsRouter              *districts.DistrictsRouter
	FeedbacksRouter              *feedbacks.FeedbacksRouter
	GalleriesRouter              *galleries.GalleriesRouter
	GalleryFilesRouter           *gallery_files.GalleryFilesRouter
	ProductSpecificationsRouter  *product_specifications.ProductSpecificationsRouter
	ProductsRouter               *products.ProductsRouter
	PromotionsRouter             *promotions.PromotionsRouter
	ProvincesRouter              *provinces.ProvincesRouter
	SalesAgentsRouter            *sales_agents.SalesAgentsRouter
	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,
	articleCategoriesRouter *article_categories.ArticleCategoriesRouter,
	articleCategoryDetailsRouter *article_category_details.ArticleCategoryDetailsRouter,
	articleFilesRouter *article_files.ArticleFilesRouter,
	articleCommentsRouter *article_comments.ArticleCommentsRouter,
	articleApprovalsRouter *article_approvals.ArticleApprovalsRouter,
	articlesRouter *articles.ArticlesRouter,
	bannersRouter *banners.BannersRouter,
	citiesRouter *cities.CitiesRouter,
	customStaticPagesRouter *custom_static_pages.CustomStaticPagesRouter,
	districtsRouter *districts.DistrictsRouter,
	feedbacksRouter *feedbacks.FeedbacksRouter,
	galleriesRouter *galleries.GalleriesRouter,
	galleryFilesRouter *gallery_files.GalleryFilesRouter,
	productSpecificationsRouter *product_specifications.ProductSpecificationsRouter,
	productsRouter *products.ProductsRouter,
	promotionsRouter *promotions.PromotionsRouter,
	provincesRouter *provinces.ProvincesRouter,
	salesAgentsRouter *sales_agents.SalesAgentsRouter,
	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,
		ArticleCategoriesRouter:      articleCategoriesRouter,
		ArticleCategoryDetailsRouter: articleCategoryDetailsRouter,
		ArticleFilesRouter:           articleFilesRouter,
		ArticleCommentsRouter:        articleCommentsRouter,
		ArticleApprovalsRouter:       articleApprovalsRouter,
		ArticlesRouter:               articlesRouter,
		BannersRouter:                bannersRouter,
		CitiesRouter:                 citiesRouter,
		CustomStaticPagesRouter:      customStaticPagesRouter,
		DistrictsRouter:              districtsRouter,
		FeedbacksRouter:              feedbacksRouter,
		GalleriesRouter:              galleriesRouter,
		GalleryFilesRouter:           galleryFilesRouter,
		ProductSpecificationsRouter:  productSpecificationsRouter,
		ProductsRouter:               productsRouter,
		PromotionsRouter:             promotionsRouter,
		ProvincesRouter:              provincesRouter,
		SalesAgentsRouter:            salesAgentsRouter,
		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.ArticleCategoriesRouter.RegisterArticleCategoriesRoutes()
	r.ArticleCategoryDetailsRouter.RegisterArticleCategoryDetailsRoutes()
	r.ArticleFilesRouter.RegisterArticleFilesRoutes()
	r.ArticleApprovalsRouter.RegisterArticleApprovalsRoutes()
	r.ArticlesRouter.RegisterArticlesRoutes()
	r.ArticleCommentsRouter.RegisterArticleCommentsRoutes()
	r.BannersRouter.RegisterBannersRoutes()
	r.CitiesRouter.RegisterCitiesRoutes()
	r.CustomStaticPagesRouter.RegisterCustomStaticPagesRoutes()
	r.DistrictsRouter.RegisterDistrictsRoutes()
	r.FeedbacksRouter.RegisterFeedbacksRoutes()
	r.GalleriesRouter.RegisterGalleriesRoutes()
	r.GalleryFilesRouter.RegisterGalleryFilesRoutes()
	r.ProductSpecificationsRouter.RegisterProductSpecificationsRoutes()
	r.ProductsRouter.RegisterProductsRoutes()
	r.PromotionsRouter.RegisterPromotionsRoutes()
	r.ProvincesRouter.RegisterProvincesRoutes()
	r.SalesAgentsRouter.RegisterSalesAgentsRoutes()
	r.UserLevelsRouter.RegisterUserLevelsRoutes()
	r.UserRoleAccessesRouter.RegisterUserRoleAccessesRoutes()
	r.UsersRouter.RegisterUsersRoutes()
	r.UserRolesRouter.RegisterUserRolesRoutes()
}
