<?php
namespace App\Http\Controllers\Api\V1;
use App\Models\{AddressCollection,Invoice,OperationsAlert,Payout,ProviderCoinSyncRun,RiskScreening,WalletAddress};
use App\Support\ApiResponse;
final class OperatorDashboardController {
 public function __invoke(){
  return ApiResponse::success([
   'payments'=>[
    'waiting'=>Invoice::where('status','waiting')->count(),
    'confirming'=>Invoice::where('status','confirming')->count(),
    'manual_review'=>Invoice::where('status','manual_review')->count(),
   ],
   'payouts'=>[
    'pending_approval'=>Payout::where('status','pending_approval')->count(),
    'manual_review'=>Payout::where('status','manual_review')->count(),
   ],
   'treasury'=>[
    'active_addresses'=>WalletAddress::where('status','active')->count(),
    'collections_pending'=>AddressCollection::whereIn('status',['requesting','submitted'])->count(),
   ],
   'risk'=>['manual_review'=>RiskScreening::where('status','manual_review')->count()],
   'operations'=>['open_alerts'=>OperationsAlert::whereNull('acknowledged_at')->count()],
   'last_coin_sync'=>ProviderCoinSyncRun::latest()->first(),
  ]);
 }
}
