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

from app.core.response import ok
from app.db.models import User
from app.db.session import get_db
from app.deps import require_staff
from app.services import admin as admin_service

router = APIRouter(prefix="/api/admin", tags=["Admin"])


@router.get("/dashboard")
def admin_dashboard(
    request: Request,
    db: Session = Depends(get_db),
    current_user: User = Depends(require_staff),
):
    metrics = admin_service.get_dashboard_metrics(db, tenant_id=current_user.tenant_id)
    return ok(metrics, request_id=request.state.request_id)
