package hostorg

import (
	"hyapp-admin-server/internal/middleware"

	"github.com/gin-gonic/gin"
)

func RegisterRoutes(protected *gin.RouterGroup, h *Handler) {
	protected.GET("/admin/bd-leaders", middleware.RequirePermission("bd:view"), h.ListBDLeaders)
	protected.POST("/admin/bd-leaders", middleware.RequirePermission("bd:create"), h.CreateBDLeader)
	protected.PATCH("/admin/bd-leaders/:user_id/status", middleware.RequirePermission("bd:update"), h.SetBDStatus)
	protected.PATCH("/admin/bd-leaders/:user_id/position-alias", middleware.RequirePermission("bd:update"), h.UpdateBDLeaderPositionAlias)
	protected.DELETE("/admin/bd-leaders/:user_id", middleware.RequirePermission("bd:update"), h.DeleteBDLeader)
	protected.GET("/admin/bds", middleware.RequirePermission("bd:view"), h.ListBDs)
	protected.POST("/admin/bds", middleware.RequirePermission("bd:create"), h.CreateBD)
	protected.PATCH("/admin/bds/:user_id/status", middleware.RequirePermission("bd:update"), h.SetBDStatus)
	protected.GET("/admin/managers", middleware.RequirePermission("bd:view"), h.ListManagers)
	protected.POST("/admin/managers", middleware.RequirePermission("bd:create"), h.CreateManager)
	protected.PUT("/admin/managers/:user_id", middleware.RequirePermission("bd:update"), h.UpdateManager)
	protected.GET("/admin/agencies", middleware.RequirePermission("agency:view"), h.ListAgencies)
	protected.POST("/admin/agencies", middleware.RequirePermission("agency:create"), h.CreateAgency)
	protected.POST("/admin/agencies/:agency_id/hosts", middleware.RequirePermission("agency:create"), h.AdminAddAgencyHost)
	protected.POST("/admin/agencies/:agency_id/close", middleware.RequirePermission("agency:status"), h.CloseAgency)
	protected.PATCH("/admin/agencies/:agency_id/status", middleware.RequirePermission("agency:status"), h.SetAgencyStatus)
	protected.POST("/admin/agencies/:agency_id/delete", middleware.RequirePermission("agency:delete"), h.DeleteAgency)
	protected.POST("/admin/agencies/:agency_id/join-enabled", middleware.RequirePermission("agency:status"), h.SetAgencyJoinEnabled)
	protected.GET("/admin/hosts", middleware.RequirePermission("host:view"), h.ListHosts)
	protected.GET("/admin/host-org/salary-wallets/history", middleware.RequireAnyPermission("host:view", "agency:view", "bd:view"), h.ListSalaryWalletHistory)
	protected.POST("/admin/host-org/salary-wallets/adjust", middleware.RequirePermission("host-salary-settlement:settle"), h.AdjustSalaryWallet)
	protected.GET("/admin/coin-sellers", middleware.RequirePermission("coin-seller:view"), h.ListCoinSellers)
	protected.POST("/admin/coin-sellers", middleware.RequirePermission("coin-seller:create"), h.CreateCoinSeller)
	protected.PATCH("/admin/coin-sellers/:user_id/status", middleware.RequirePermission("coin-seller:update"), h.SetCoinSellerStatus)
	protected.GET("/admin/coin-sellers/:user_id/sub-sellers", middleware.RequirePermission("coin-seller:view"), h.ListCoinSellerSubSellers)
	protected.GET("/admin/coin-seller-sub-applications", middleware.RequirePermission("coin-seller-sub-application:view"), h.ListCoinSellerSubApplications)
	protected.POST("/admin/coin-seller-sub-applications/:application_id/approve", middleware.RequirePermission("coin-seller-sub-application:audit"), h.ApproveCoinSellerSubApplication)
	protected.POST("/admin/coin-seller-sub-applications/:application_id/reject", middleware.RequirePermission("coin-seller-sub-application:audit"), h.RejectCoinSellerSubApplication)
	protected.POST("/admin/coin-sellers/:user_id/stock-credits", middleware.RequirePermission("coin-seller:stock-credit"), h.CreditCoinSellerStock)
	protected.POST("/admin/coin-sellers/:user_id/stock-debits", middleware.RequirePermission("coin-seller:stock-credit"), h.DebitCoinSellerStock)
	protected.GET("/admin/coin-seller-salary-rates/:region_id", middleware.RequirePermission("coin-seller:exchange-rate"), h.GetCoinSellerSalaryRates)
	protected.PUT("/admin/coin-seller-salary-rates/:region_id", middleware.RequirePermission("coin-seller:exchange-rate"), h.ReplaceCoinSellerSalaryRates)
}
