package route

import (
	"gitlab.com/mbugroup/lti-api.git/internal/common/validation"
	trim "gitlab.com/mbugroup/lti-api.git/internal/middleware/trim"
	"gitlab.com/mbugroup/lti-api.git/internal/modules"

	"github.com/gofiber/fiber/v2"
	"gorm.io/gorm"

	approvals "gitlab.com/mbugroup/lti-api.git/internal/modules/approvals"
	closings "gitlab.com/mbugroup/lti-api.git/internal/modules/closings"
	constants "gitlab.com/mbugroup/lti-api.git/internal/modules/constants"
	dailyChecklists "gitlab.com/mbugroup/lti-api.git/internal/modules/daily-checklists"
	expenses "gitlab.com/mbugroup/lti-api.git/internal/modules/expenses"
	finance "gitlab.com/mbugroup/lti-api.git/internal/modules/finance"
	inventory "gitlab.com/mbugroup/lti-api.git/internal/modules/inventory"
	marketing "gitlab.com/mbugroup/lti-api.git/internal/modules/marketing"
	master "gitlab.com/mbugroup/lti-api.git/internal/modules/master"
	production "gitlab.com/mbugroup/lti-api.git/internal/modules/production"
	purchases "gitlab.com/mbugroup/lti-api.git/internal/modules/purchases"
	repports "gitlab.com/mbugroup/lti-api.git/internal/modules/repports"
	ssoModule "gitlab.com/mbugroup/lti-api.git/internal/modules/sso"
	users "gitlab.com/mbugroup/lti-api.git/internal/modules/users"
	dashboards "gitlab.com/mbugroup/lti-api.git/internal/modules/dashboards"
	// MODULE IMPORTS
)

func Routes(app *fiber.App, db *gorm.DB) {
	validate := validation.Validator()
	api := app.Group("/api")
	api.Use(trim.JSONBody())

	// root modules di sini
	allModules := []modules.Module{
		users.UserModule{},
		master.MasterModule{},
		constants.ConstantModule{},
		inventory.InventoryModule{},
		purchases.PurchaseModule{},
		production.ProductionModule{},
		approvals.ApprovalModule{},
		purchases.PurchaseModule{},
		marketing.MarketingModule{},
		ssoModule.Module{},
		expenses.ExpenseModule{},
		ssoModule.Module{},
		closings.ClosingModule{},
		repports.RepportModule{},
		finance.FinanceModule{},
		dailyChecklists.DailyChecklistModule{},
				dashboards.DashboardModule{},
		// MODULE REGISTRY
	}

	// daftarkan root modules
	for _, m := range allModules {
		m.RegisterRoutes(api, db, validate)
	}

}
