package countryregion

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

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

func RegisterRoutes(protected *gin.RouterGroup, h *Handler) {
	if h == nil {
		return
	}

	protected.GET("/admin/countries", middleware.RequirePermission("country:view"), h.ListCountries)
	protected.GET("/admin/countries/:country_id", middleware.RequirePermission("country:view"), h.GetCountry)
	protected.POST("/admin/countries", middleware.RequirePermission("country:create"), h.CreateCountry)
	protected.PATCH("/admin/countries/:country_id", middleware.RequirePermission("country:update"), h.UpdateCountry)
	protected.POST("/admin/countries/:country_id/rename-code", middleware.RequirePermission("country:update"), h.RenameCountryCode)
	protected.POST("/admin/countries/:country_id/enable", middleware.RequirePermission("country:status"), h.EnableCountry)
	protected.POST("/admin/countries/:country_id/disable", middleware.RequirePermission("country:status"), h.DisableCountry)
	protected.DELETE("/admin/countries/:country_id", middleware.RequirePermission("country:status"), h.DisableCountry)

	protected.GET("/admin/regions", middleware.RequirePermission("region:view"), h.ListRegions)
	protected.GET("/admin/regions/:region_id", middleware.RequirePermission("region:view"), h.GetRegion)
	protected.POST("/admin/regions", middleware.RequirePermission("region:create"), h.CreateRegion)
	protected.PATCH("/admin/regions/:region_id", middleware.RequirePermission("region:update"), h.UpdateRegion)
	protected.PUT("/admin/regions/:region_id/countries", middleware.RequirePermission("region:update"), h.ReplaceRegionCountries)
	protected.POST("/admin/regions/:region_id/enable", middleware.RequirePermission("region:status"), h.EnableRegion)
	protected.DELETE("/admin/regions/:region_id", middleware.RequirePermission("region:status"), h.DisableRegion)
}
