from typing import Annotated

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

from app.rips.application.catalogs import (
    CONCEPTO_RECAUDO,
    LST_SI_NO,
    RIPS_TIPO_USUARIO_VERSION2,
    TIPO_OTRO_SERVICIO,
    ZONA_VERSION2,
)
from app.routes.shell_navigation import build_shell_context

from .common import CurrentUser, ServicesDep


router = APIRouter()


@router.get("/rips/operativo", response_class=HTMLResponse)
async def rips_operativo(
    request: Request,
    services: ServicesDep,
    current_user: CurrentUser,
    case_key: Annotated[str | None, Query()] = None,
):
    templates = services.templates
    bootstrap = {
        "selected_case_key": str(case_key or "").strip(),
        "catalogs": {
            "tipo_usuario": RIPS_TIPO_USUARIO_VERSION2,
            "zona": ZONA_VERSION2,
            "lst_si_no": LST_SI_NO,
            "concepto_recaudo": CONCEPTO_RECAUDO,
            "tipo_otro_servicio": TIPO_OTRO_SERVICIO,
        },
    }
    return templates.TemplateResponse(
        request,
        "rips_operativo.html",
        {
            "request": request,
            "user": current_user,
            "bootstrap": bootstrap,
            **build_shell_context(request=request, user=current_user),
        },
    )
