work on team enrollment

This commit is contained in:
yohlo
2025-09-16 09:24:21 -05:00
parent 9a105b30c6
commit cde74a04d5
45 changed files with 1244 additions and 457 deletions

View File

@@ -1,9 +1,11 @@
import { useServerSuspenseQuery, useServerQuery } from "@/lib/tanstack-query/hooks";
import { getTeam, getTeamStats } from "./server";
import { getTeam, getTeamMatches, getTeamStats } from "./server";
export const teamKeys = {
list: ['teams', 'list'] as const,
details: (id: string) => ['teams', 'details', id] as const,
stats: (id: string) => ['teams', 'stats', id] as const,
matches: (id: string) => ['teams', 'matches', id] as const,
};
export const teamQueries = {
@@ -15,14 +17,17 @@ export const teamQueries = {
queryKey: teamKeys.stats(id),
queryFn: () => getTeamStats({ data: id }),
}),
matches: (id: string) => ({
queryKey: teamKeys.matches(id),
queryFn: () => getTeamMatches({ data: id })
})
};
export const useTeam = (id: string) =>
useServerSuspenseQuery(teamQueries.details(id));
export const useTeamStats = (id: string) =>
useServerQuery({
...teamQueries.stats(id),
retry: 1,
staleTime: 5 * 60 * 1000, // 5 minutes
});
useServerQuery(teamQueries.stats(id));
export const useTeamMatches = (id: string) =>
useServerQuery(teamQueries.matches(id));