package handler

import (
	"net/http"
	"path/filepath"
	"xboard-go/internal/service"

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

type adminPluginPageViewData struct {
	Title      string
	Kind       string
	KindLabel  string
	SecurePath string
}

func AdminPluginPanelPage(c *gin.Context) {
	kind := c.Param("kind")
	labels := map[string]string{
		"realname":         "实名认证",
		"online-devices":   "在线 IP 统计",
		"ipv6-subscription": "IPv6 子账号",
	}
	label, ok := labels[kind]
	if !ok {
		c.String(http.StatusNotFound, "plugin panel not found")
		return
	}

	renderPageTemplate(c, filepath.Join("frontend", "templates", "admin_plugin_panel.html"), adminPluginPageViewData{
		Title:      service.MustGetString("app_name", "XBoard") + " - " + label,
		Kind:       kind,
		KindLabel:  label,
		SecurePath: service.GetAdminSecurePath(),
	})
}
