feat(safety): needs attention card on dashboard

Add a "Needs Attention" card above the orders table that surfaces:
- Import errors count (click → ERROR filter)
- Unmapped SKUs count (click → Missing SKUs page)
- Uninvoiced orders >3 days (click → UNINVOICED filter)
Shows green "Totul in ordine" when all metrics are zero.

Backend: add uninvoiced_old count to get_orders() and unresolved_skus
from get_dashboard_stats() to dashboard/orders API response.

Cache-bust: style.css?v=21, dashboard.js?v=29

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-03-27 12:28:18 +00:00
parent 3bd0556f73
commit a10a00aa4d
6 changed files with 77 additions and 2 deletions

View File

@@ -564,6 +564,13 @@ async def dashboard_orders(page: int = 1, per_page: int = 50,
counts["facturate"] = max(0, imported_total - counts["nefacturate"])
counts.setdefault("total", counts.get("imported", 0) + counts.get("skipped", 0) + counts.get("error", 0))
# Attention metrics: add unresolved SKUs count
try:
stats = await sqlite_service.get_dashboard_stats()
counts["unresolved_skus"] = stats.get("unresolved_skus", 0)
except Exception:
counts["unresolved_skus"] = 0
# For UNINVOICED filter: apply server-side filtering + pagination
if is_uninvoiced_filter:
filtered = [o for o in all_orders if o.get("status") in ("IMPORTED", "ALREADY_IMPORTED") and not o.get("invoice")]