from fastapi import APIRouter, Request
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
import logging

logger = logging.getLogger(__name__)

router = APIRouter()
templates = Jinja2Templates(directory=["app/prepaid/frontend", "app/shared/frontend", "app"])


@router.get("/prepaid-cards", response_class=HTMLResponse)
async def prepaid_cards_page(request: Request):
    """
    Prepaid cards overview page
    """
    logger.info("🔍 Rendering prepaid cards page")
    return templates.TemplateResponse("index.html", {
        "request": request,
        "page_title": "Prepaid Cards"
    })


@router.get("/prepaid-cards/{card_id}", response_class=HTMLResponse)
async def prepaid_card_detail(request: Request, card_id: int):
    """
    Prepaid card detail page
    """
    logger.info(f"🔍 Rendering prepaid card detail: {card_id}")
    return templates.TemplateResponse("detail.html", {
        "request": request,
        "page_title": "Card Details",
        "card_id": card_id
    })
