package controllers

import (
	"html/template"

	"github.com/gofiber/fiber/v2"
)

type AdminController struct{}

func NewAdminController() *AdminController {
	return &AdminController{}
}

func (ac *AdminController) Dashboard(c *fiber.Ctx) error {
	viewData := map[string]any{
		"Title":      "Admin Dashboard",
		"NavSection": "admin",
	}
	for k, v := range localsTemplateData(c) {
		viewData[k] = v
	}

	tmpl, err := template.ParseFiles(
		"web/templates/layout.html",
		"web/templates/admin/_navbar.html",
		"web/templates/partials/language_dropdown.html",
		"web/templates/public/_flash.html",
		"web/templates/admin/dashboard.html",
	)
	if err != nil {
		return err
	}

	return executeLayout(c, tmpl, viewData)
}
