import type { Recordable } from '@vben/types';

import { requestClient } from '#/api/request';

export namespace DashboardApi {
  export interface OrderStatistics {
    today_count: number;
    month_count: number;
    total_count: number;
    yesterday_count: number;
    change_rate: number;
  }

  export interface RevenueStatistics {
    today_amount: number;
    month_amount: number;
    total_amount: number;
    yesterday_amount: number;
    change_rate: number;
  }

  export interface AgentStatistics {
    total_count: number;
    today_new: number;
    month_new: number;
  }

  export interface ProfitStatistics {
    today_profit: number;
    month_profit: number;
    total_profit: number;
    today_profit_rate: number;
    month_profit_rate: number;
    total_profit_rate: number;
  }

  export interface TrendData {
    date: string;
    value: number;
  }

  export interface DashboardStatistics {
    order_stats: OrderStatistics;
    revenue_stats: RevenueStatistics;
    agent_stats: AgentStatistics;
    profit_stats: ProfitStatistics;
    order_trend: TrendData[];
    revenue_trend: TrendData[];
  }
}

export async function getDashboardStatistics(): Promise<DashboardApi.DashboardStatistics> {
  return await requestClient.get<DashboardApi.DashboardStatistics>(
    '/api/v1/admin/dashboard/statistics',
  );
}

