feat(flow): map SKU + auto-retry consolidated banner

After saving a SKU mapping, check for SKIPPED orders containing that
SKU and show a floating banner with count + "Importa" button. Batch
retries up to 20 orders and shows result feedback.

Backend:
- get_skipped_orders_with_sku() in sqlite_service.py
- GET /api/orders/by-sku/{sku}/pending endpoint
- POST /api/orders/batch-retry endpoint (max 20, sequential)

Frontend:
- Auto-retry banner after quickMap save with batch import button
- Success/error feedback, auto-dismiss after 15s

Cache-bust: shared.js?v=19

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-03-27 12:38:10 +00:00
parent 7a789b4fe7
commit b52313faf6
4 changed files with 90 additions and 2 deletions

View File

@@ -494,6 +494,42 @@ async def retry_order(order_number: str):
return result
@router.get("/api/orders/by-sku/{sku}/pending")
async def get_pending_orders_for_sku(sku: str):
"""Get SKIPPED orders that contain the given SKU."""
order_numbers = await sqlite_service.get_skipped_orders_with_sku(sku)
return {"sku": sku, "order_numbers": order_numbers, "count": len(order_numbers)}
@router.post("/api/orders/batch-retry")
async def batch_retry_orders(request: Request):
"""Batch retry multiple orders."""
from ..services import retry_service
body = await request.json()
order_numbers = body.get("order_numbers", [])
if not order_numbers:
return {"success": False, "message": "No orders specified"}
app_settings = await sqlite_service.get_app_settings()
results = {"imported": 0, "errors": 0, "messages": []}
for on in order_numbers[:20]: # Limit to 20 to avoid timeout
result = await retry_service.retry_single_order(str(on), app_settings)
if result.get("success"):
results["imported"] += 1
else:
results["errors"] += 1
results["messages"].append(f"{on}: {result.get('message', 'Error')}")
return {
"success": results["imported"] > 0,
"imported": results["imported"],
"errors": results["errors"],
"message": f"{results['imported']} importate, {results['errors']} erori" if results["errors"] else f"{results['imported']} importate cu succes",
"details": results["messages"][:5],
}
@router.get("/api/dashboard/orders")
async def dashboard_orders(page: int = 1, per_page: int = 50,
search: str = "", status: str = "all",