# app/modules/inventory/routes/pages/vendor.py
"""
Inventory Vendor Page Routes (HTML rendering).

Vendor pages for inventory management:
- Inventory list
"""

from fastapi import APIRouter, Depends, Path, Request
from fastapi.responses import HTMLResponse
from sqlalchemy.orm import Session

from app.api.deps import get_current_vendor_from_cookie_or_header, get_db
from app.modules.core.utils.page_context import get_vendor_context
from app.templates_config import templates
from app.modules.tenancy.models import User

router = APIRouter()


# ============================================================================
# INVENTORY MANAGEMENT
# ============================================================================


@router.get(
    "/{vendor_code}/inventory", response_class=HTMLResponse, include_in_schema=False
)
async def vendor_inventory_page(
    request: Request,
    vendor_code: str = Path(..., description="Vendor code"),
    current_user: User = Depends(get_current_vendor_from_cookie_or_header),
    db: Session = Depends(get_db),
):
    """
    Render inventory management page.
    JavaScript loads inventory data via API.
    """
    return templates.TemplateResponse(
        "inventory/vendor/inventory.html",
        get_vendor_context(request, db, current_user, vendor_code),
    )
