// YouTube API quota usage: the signed-in user's own totals and the admin cross-user view.
// Only touches core's req.
import { req } from "./core";

export interface MyUsage {
  today: number;
  last_7d: number;
  last_30d: number;
  all_time: number;
  by_action: Record<string, number>;
}

export interface AdminQuotaRow {
  user_id: number | null;
  email: string;
  total: number;
  by_action: Record<string, number>;
}

export interface AdminQuota {
  range_days: number;
  rows: AdminQuotaRow[];
  daily: { day: string; total: number }[];
}

export const quotaApi = {
  myUsage: (): Promise<MyUsage> => req("/api/quota/my-usage"),
  adminQuota: (days = 30): Promise<AdminQuota> => req(`/api/quota/admin?days=${days}`),
};
