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

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

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

from app.api.deps import (
    get_db,
    get_resolved_store_code,
    require_store_page_permission,
)
from app.modules.core.utils.page_context import get_store_context
from app.modules.tenancy.models import User
from app.templates_config import templates

router = APIRouter()


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


@router.get(
    "/inventory", response_class=HTMLResponse, include_in_schema=False
)
async def store_inventory_page(
    request: Request,
    store_code: str = Depends(get_resolved_store_code),
    current_user: User = Depends(require_store_page_permission("stock.view")),
    db: Session = Depends(get_db),
):
    """
    Render inventory management page.
    JavaScript loads inventory data via API.
    """
    return templates.TemplateResponse(
        "inventory/store/inventory.html",
        get_store_context(request, db, current_user, store_code),
    )
