'use client';

import { useQuery } from '@tanstack/react-query';
import { useInject } from '@/lib/di/hooks/useInject';
import { DRIVER_SERVICE_TOKEN } from '@/lib/di/tokens';

/**
 * Hook for driver leaderboard data
 */
export function useDriverLeaderboard() {
  const driverService = useInject(DRIVER_SERVICE_TOKEN);

  const query = useQuery({
    queryKey: ['driverLeaderboard'],
    queryFn: async () => {
      return await driverService.getDriverLeaderboard();
    },
    staleTime: 5 * 60 * 1000, // 5 minutes
    gcTime: 10 * 60 * 1000, // 10 minutes
    retry: false,
    refetchOnWindowFocus: false,
  });

  return {
    data: query.data,
    isLoading: query.isLoading,
    error: query.error,
    retry: query.refetch,
  };
}