17 lines
641 B
TypeScript
17 lines
641 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { useInject } from '@/lib/di/hooks/useInject';
|
|
import { LEAGUE_SERVICE_TOKEN } from '@/lib/di/tokens';
|
|
import { enhanceQueryResult } from '@/lib/di/hooks/useReactQueryWithApiError';
|
|
|
|
export function useLeagueDetail(leagueId: string, currentDriverId: string) {
|
|
const leagueService = useInject(LEAGUE_SERVICE_TOKEN);
|
|
|
|
const queryResult = useQuery({
|
|
queryKey: ['leagueDetail', leagueId, currentDriverId],
|
|
queryFn: () => leagueService.getLeagueDetail(leagueId, currentDriverId),
|
|
enabled: !!leagueId && !!currentDriverId,
|
|
});
|
|
|
|
return enhanceQueryResult(queryResult);
|
|
}
|