import { useQuery } from "@tanstack/react-query"

import type { ClubStats, Distribution } from "@/types/api"

import { apiClient } from "@/lib/api-client"

// --- Query Hooks ---

export function useClubStatsQuery() {
  return useQuery({
    queryKey: ["dashboard", "stats"],
    queryFn: () => apiClient<ClubStats>("/dashboard/stats"),
    refetchInterval: 60 * 1000, // auto-refresh every 60s
  })
}

export function useRecentDistributionsQuery(limit = 5) {
  return useQuery({
    queryKey: ["dashboard", "recent-distributions", limit],
    queryFn: () =>
      apiClient<Distribution[]>("/distributions/recent", {
        params: { limit },
      }),
  })
}
