# retoor <retoor@molodetz.nl>

import logging

from fastapi import APIRouter, Request
from fastapi.responses import HTMLResponse

from devplacepy.seo import base_seo_context
from devplacepy.services.gitea.config import gitea_config
from devplacepy.templating import templates
from devplacepy.utils import require_admin

logger = logging.getLogger(__name__)
router = APIRouter()


@router.get("/issues/planning", response_class=HTMLResponse)
async def admin_issues_planning(request: Request):
    admin = require_admin(request)
    seo_ctx = base_seo_context(
        request,
        title="Ticket Planning - Admin",
        description="Generate a grouped, ordered planning report of all open tickets.",
        robots="noindex,nofollow",
        breadcrumbs=[
            {"name": "Home", "url": "/feed"},
            {"name": "Admin", "url": "/admin"},
            {"name": "Issues", "url": "/issues"},
        ],
    )
    context = {
        **seo_ctx,
        "request": request,
        "user": admin,
        "admin_section": "issues",
        "configured": gitea_config().is_configured,
    }
    return templates.TemplateResponse(request, "admin_issues_planning.html", context)
