match list

This commit is contained in:
yohlo
2025-09-14 21:59:15 -05:00
parent d11e50d4ef
commit 8efc0a7a4b
9 changed files with 411 additions and 111 deletions

View File

@@ -1,5 +1,5 @@
import { useServerSuspenseQuery } from "@/lib/tanstack-query/hooks";
import { listPlayers, getPlayer, getUnassociatedPlayers, fetchMe, getPlayerStats, getAllPlayerStats } from "./server";
import { listPlayers, getPlayer, getUnassociatedPlayers, fetchMe, getPlayerStats, getAllPlayerStats, getPlayerMatches } from "./server";
export const playerKeys = {
auth: ['auth'],
@@ -8,6 +8,7 @@ export const playerKeys = {
unassociated: ['players','unassociated'],
stats: (id: string) => ['players', 'stats', id],
allStats: ['players', 'stats', 'all'],
matches: (id: string) => ['players', 'matches', id],
};
export const playerQueries = {
@@ -35,6 +36,10 @@ export const playerQueries = {
queryKey: playerKeys.allStats,
queryFn: async () => await getAllPlayerStats()
}),
matches: (id: string) => ({
queryKey: playerKeys.matches(id),
queryFn: async () => await getPlayerMatches({ data: id })
}),
};
export const useMe = () => {
@@ -73,4 +78,7 @@ export const usePlayerStats = (id: string) =>
useServerSuspenseQuery(playerQueries.stats(id));
export const useAllPlayerStats = () =>
useServerSuspenseQuery(playerQueries.allStats());
useServerSuspenseQuery(playerQueries.allStats());
export const usePlayerMatches = (id: string) =>
useServerSuspenseQuery(playerQueries.matches(id));