player stats in profile
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { useServerSuspenseQuery } from "@/lib/tanstack-query/hooks";
|
||||
import { listPlayers, getPlayer, getUnassociatedPlayers, fetchMe } from "./server";
|
||||
import { listPlayers, getPlayer, getUnassociatedPlayers, fetchMe, getPlayerStats } from "./server";
|
||||
|
||||
export const playerKeys = {
|
||||
auth: ['auth'],
|
||||
list: ['players', 'list'],
|
||||
details: (id: string) => ['players', 'details', id],
|
||||
unassociated: ['players','unassociated'],
|
||||
stats: (id: string) => ['players', 'stats', id],
|
||||
};
|
||||
|
||||
export const playerQueries = {
|
||||
@@ -25,6 +26,10 @@ export const playerQueries = {
|
||||
queryKey: playerKeys.unassociated,
|
||||
queryFn: async () => await getUnassociatedPlayers()
|
||||
}),
|
||||
stats: (id: string) => ({
|
||||
queryKey: playerKeys.stats(id),
|
||||
queryFn: async () => await getPlayerStats({ data: id })
|
||||
}),
|
||||
};
|
||||
|
||||
export const useMe = () => {
|
||||
@@ -57,4 +62,7 @@ export const usePlayers = () =>
|
||||
useServerSuspenseQuery(playerQueries.list());
|
||||
|
||||
export const useUnassociatedPlayers = () =>
|
||||
useServerSuspenseQuery(playerQueries.unassociated());
|
||||
useServerSuspenseQuery(playerQueries.unassociated());
|
||||
|
||||
export const usePlayerStats = (id: string) =>
|
||||
useServerSuspenseQuery(playerQueries.stats(id));
|
||||
Reference in New Issue
Block a user