import adminClient from "./client"
import type { ApiResponse } from "../../types"

export interface AdminDashboardStats {
  users_total: number
  today_income_cents: number
  products_total: number
  products_active: number
  cloud_nodes_total: number
  cloud_nodes_online: number
  cloud_nodes_enabled: number
}

export interface AdminDashboardOverview {
  order_processing_percent: number
  cloud_connectivity_percent: number
  finance_reconcile_percent: number
  pending_orders: number
  pending_recharges: number
  failed_resource_actions: number
}

export interface AdminDashboardEvent {
  key: string
  type: string
  action: string
  status: string
  time: string | null
}

export interface AdminDashboardData {
  stats: AdminDashboardStats
  overview: AdminDashboardOverview
  recent_events: AdminDashboardEvent[]
}

export async function getAdminDashboard() {
  const { data } = await adminClient.get<ApiResponse<AdminDashboardData>>("/v1/admin/dashboard")
  return data
}
