match h2h
This commit is contained in:
24
src/features/matches/queries.ts
Normal file
24
src/features/matches/queries.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { useServerQuery } from "@/lib/tanstack-query/hooks";
|
||||
import { getMatchesBetweenTeams, getMatchesBetweenPlayers } from "./server";
|
||||
|
||||
export const matchKeys = {
|
||||
headToHeadTeams: (team1Id: string, team2Id: string) => ['matches', 'headToHead', 'teams', team1Id, team2Id] as const,
|
||||
headToHeadPlayers: (player1Id: string, player2Id: string) => ['matches', 'headToHead', 'players', player1Id, player2Id] as const,
|
||||
};
|
||||
|
||||
export const matchQueries = {
|
||||
headToHeadTeams: (team1Id: string, team2Id: string) => ({
|
||||
queryKey: matchKeys.headToHeadTeams(team1Id, team2Id),
|
||||
queryFn: () => getMatchesBetweenTeams({ data: { team1Id, team2Id } }),
|
||||
}),
|
||||
headToHeadPlayers: (player1Id: string, player2Id: string) => ({
|
||||
queryKey: matchKeys.headToHeadPlayers(player1Id, player2Id),
|
||||
queryFn: () => getMatchesBetweenPlayers({ data: { player1Id, player2Id } }),
|
||||
}),
|
||||
};
|
||||
|
||||
export const useTeamHeadToHead = (team1Id: string, team2Id: string) =>
|
||||
useServerQuery(matchQueries.headToHeadTeams(team1Id, team2Id));
|
||||
|
||||
export const usePlayerHeadToHead = (player1Id: string, player2Id: string) =>
|
||||
useServerQuery(matchQueries.headToHeadPlayers(player1Id, player2Id));
|
||||
Reference in New Issue
Block a user