package router

import (
	"campaign-pool-be/app/module/activity_logs"
	"campaign-pool-be/app/module/campaign_destinations"
	"campaign-pool-be/app/module/campaign_types"
	"campaign-pool-be/app/module/campaigns"
	"campaign-pool-be/app/module/campaign_files"
	"campaign-pool-be/app/module/custom_static_pages"
	"campaign-pool-be/app/module/user_levels"
	"campaign-pool-be/app/module/user_role_accesses"
	"campaign-pool-be/app/module/user_roles"
	"campaign-pool-be/app/module/users"
	"campaign-pool-be/config/config"
	_ "campaign-pool-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
	CustomStaticPagesRouter      *custom_static_pages.CustomStaticPagesRouter
	UserLevelsRouter             *user_levels.UserLevelsRouter
	UserRoleAccessesRouter       *user_role_accesses.UserRoleAccessesRouter
	UserRolesRouter              *user_roles.UserRolesRouter
	UsersRouter                  *users.UsersRouter
	CampaignTypesRouter          *campaign_types.CampaignTypesRouter
	CampaignDestinationsRouter   *campaign_destinations.CampaignDestinationsRouter
	CampaignsRouter              *campaigns.CampaignsRouter
	CampaignFilesRouter          *campaign_files.CampaignFilesRouter
}

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

	activityLogsRouter *activity_logs.ActivityLogsRouter,
	customStaticPagesRouter *custom_static_pages.CustomStaticPagesRouter,
	userLevelsRouter *user_levels.UserLevelsRouter,
	userRoleAccessesRouter *user_role_accesses.UserRoleAccessesRouter,
	userRolesRouter *user_roles.UserRolesRouter,
	usersRouter *users.UsersRouter,
	campaignTypesRouter *campaign_types.CampaignTypesRouter,
	campaignDestinationsRouter *campaign_destinations.CampaignDestinationsRouter,
	campaignsRouter *campaigns.CampaignsRouter,
	campaignFilesRouter *campaign_files.CampaignFilesRouter,
) *Router {
	return &Router{
		App:                        fiber,
		Cfg:                        cfg,
		ActivityLogsRouter:         activityLogsRouter,
		CustomStaticPagesRouter:    customStaticPagesRouter,
		UserLevelsRouter:           userLevelsRouter,
		UserRoleAccessesRouter:     userRoleAccessesRouter,
		UserRolesRouter:            userRolesRouter,
		UsersRouter:                usersRouter,
		CampaignTypesRouter:        campaignTypesRouter,
		CampaignDestinationsRouter: campaignDestinationsRouter,
		CampaignsRouter:            campaignsRouter,
		CampaignFilesRouter:        campaignFilesRouter,
	}
}

// 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.CustomStaticPagesRouter.RegisterCustomStaticPagesRoutes()
	r.UserLevelsRouter.RegisterUserLevelsRoutes()
	r.UserRoleAccessesRouter.RegisterUserRoleAccessesRoutes()
	r.UsersRouter.RegisterUsersRoutes()
	r.UserRolesRouter.RegisterUserRolesRoutes()
	r.CampaignTypesRouter.RegisterCampaignTypesRoutes()
	r.CampaignDestinationsRouter.RegisterCampaignDestinationsRoutes()
	r.CampaignsRouter.RegisterCampaignsRoutes()
	r.CampaignFilesRouter.RegisterCampaignFilesRoutes()
}
