website refactor
This commit is contained in:
26
apps/website/hooks/team/useTeamStandings.ts
Normal file
26
apps/website/hooks/team/useTeamStandings.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
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 useTeamStandings(teamId: string, leagues: string[]) {
|
||||
const leagueService = useInject(LEAGUE_SERVICE_TOKEN);
|
||||
|
||||
const queryResult = useQuery({
|
||||
queryKey: ['teamStandings', teamId, leagues],
|
||||
queryFn: async () => {
|
||||
// For demo purposes, create mock standings
|
||||
return leagues.map(leagueId => ({
|
||||
leagueId,
|
||||
leagueName: `League ${leagueId}`,
|
||||
position: Math.floor(Math.random() * 10) + 1,
|
||||
points: Math.floor(Math.random() * 100),
|
||||
wins: Math.floor(Math.random() * 5),
|
||||
racesCompleted: Math.floor(Math.random() * 10),
|
||||
}));
|
||||
},
|
||||
enabled: leagues.length > 0,
|
||||
});
|
||||
|
||||
return enhanceQueryResult(queryResult);
|
||||
}
|
||||
Reference in New Issue
Block a user