from fastapi import APIRouter, Request
from fastapi.templating import Jinja2Templates
from fastapi.responses import HTMLResponse
from app.core.config import settings

router = APIRouter()
templates = Jinja2Templates(directory="app")

@router.get("/customers", response_class=HTMLResponse)
async def customers_page(request: Request):
    """
    Render the customers page
    """
    return templates.TemplateResponse("customers/frontend/customers.html", {"request": request})


@router.get("/customers/{customer_id}", response_class=HTMLResponse)
async def customer_detail_page(request: Request, customer_id: int):
    """
    Render the customer detail page
    """
    return templates.TemplateResponse("customers/frontend/customer_detail.html", {
        "request": request,
        "customer_id": customer_id,
        "customer_default_margin_percent": settings.CUSTOMER_DEFAULT_MARGIN_PERCENT,
        "customer_default_invoice_fee": settings.CUSTOMER_DEFAULT_INVOICE_FEE,
        "customer_default_hourly_rate": settings.CUSTOMER_DEFAULT_HOURLY_RATE,
    })


@router.get("/admin/bmc-office-upload", response_class=HTMLResponse)
async def bmc_office_upload_page(request: Request):
    """BMC Office subscriptions upload page"""
    return templates.TemplateResponse(
        "customers/frontend/bmc_office_upload.html",
        {"request": request}
    )


@router.get("/pipeline", response_class=HTMLResponse)
async def pipeline_page(request: Request):
    """Render the pipeline page"""
    return templates.TemplateResponse("customers/frontend/pipeline.html", {"request": request})
