"""
Billing Frontend Views
Serves HTML pages for billing features
"""

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

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


@router.get("/billing/supplier-invoices", response_class=HTMLResponse)
async def supplier_invoices_page(request: Request):
    """Supplier invoices (kassekladde) page"""
    return templates.TemplateResponse("billing/frontend/supplier_invoices.html", {
        "request": request,
        "title": "Leverandør fakturaer"
    })


@router.get("/billing/supplier-invoices2", response_class=HTMLResponse)
async def supplier_invoices_v1_backup(request: Request):
    """Supplier invoices V1 backup - original version"""
    return templates.TemplateResponse("billing/frontend/supplier_invoices_v1_backup.html", {
        "request": request,
        "title": "Leverandør fakturaer (V1 Backup)"
    })


@router.get("/billing/template-builder", response_class=HTMLResponse)
async def template_builder_page(request: Request):
    """Template builder for supplier invoice extraction"""
    return templates.TemplateResponse("billing/frontend/template_builder.html", {
        "request": request,
        "title": "Template Builder"
    })


@router.get("/billing/templates", response_class=HTMLResponse)
async def templates_list_page(request: Request):
    """Templates list and management page"""
    return templates.TemplateResponse("billing/frontend/templates_list.html", {
        "request": request,
        "title": "Templates"
    })


@router.get("/billing/sync-dashboard", response_class=HTMLResponse)
async def billing_sync_dashboard_page(request: Request):
    """Operational sync dashboard for ordre_drafts lifecycle."""
    return templates.TemplateResponse("billing/frontend/sync_dashboard.html", {
        "request": request,
        "title": "Billing Sync Dashboard"
    })
