i think working bracket runner
This commit is contained in:
@@ -40,17 +40,6 @@ export const Route = createFileRoute("/_authed/admin/tournaments/run/$id")({
|
|||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const { data: tournament } = useTournament(id);
|
const { data: tournament } = useTournament(id);
|
||||||
const queryClient = useQueryClient();
|
|
||||||
|
|
||||||
const start = useServerMutation({
|
|
||||||
mutationFn: startMatch,
|
|
||||||
successMessage: "Match started!",
|
|
||||||
onSuccess: () => {
|
|
||||||
queryClient.invalidateQueries({
|
|
||||||
queryKey: tournamentKeys.details(tournament.id),
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const bracket: BracketData = useMemo(() => {
|
const bracket: BracketData = useMemo(() => {
|
||||||
if (!tournament.matches || tournament.matches.length === 0) {
|
if (!tournament.matches || tournament.matches.length === 0) {
|
||||||
@@ -86,14 +75,6 @@ function RouteComponent() {
|
|||||||
return { winners, losers };
|
return { winners, losers };
|
||||||
}, [tournament.matches]);
|
}, [tournament.matches]);
|
||||||
|
|
||||||
const handleStartMatch = async (match: Match) => {
|
|
||||||
await start.mutate({
|
|
||||||
data: match.id
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log(tournament.matches);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container size="md">
|
<Container size="md">
|
||||||
{tournament.matches?.length ? (
|
{tournament.matches?.length ? (
|
||||||
|
|||||||
@@ -91,8 +91,6 @@ export const MatchCard: React.FC<MatchCardProps> = ({
|
|||||||
[match.id, editSheet]
|
[match.id, editSheet]
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(homeSlot, awaySlot)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex direction="row" align="center" justify="end" gap={8}>
|
<Flex direction="row" align="center" justify="end" gap={8}>
|
||||||
<Text c="dimmed" fw="bolder">
|
<Text c="dimmed" fw="bolder">
|
||||||
|
|||||||
@@ -76,8 +76,6 @@ export const MatchForm: React.FC<MatchFormProps> = ({
|
|||||||
onSubmit(transformedValues);
|
onSubmit(transformedValues);
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(match)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<Stack gap="md">
|
<Stack gap="md">
|
||||||
|
|||||||
@@ -181,9 +181,6 @@ export const endMatch = createServerFn()
|
|||||||
|
|
||||||
// winner -> where to send match winner to, loser same
|
// winner -> where to send match winner to, loser same
|
||||||
const { winner, loser } = await pbAdmin.getChildMatches(matchId)
|
const { winner, loser } = await pbAdmin.getChildMatches(matchId)
|
||||||
|
|
||||||
console.log('match winner:', matchWinner)
|
|
||||||
console.log('match loser:', matchLoser)
|
|
||||||
|
|
||||||
if (winner) {
|
if (winner) {
|
||||||
await pbAdmin.updateMatch(winner.id, {
|
await pbAdmin.updateMatch(winner.id, {
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ export function createMatchesService(pb: PocketBase) {
|
|||||||
const winnerMatch = result.find(m => (m.home_from_lid === match.lid && !m.home_from_loser) || (m.away_from_lid === match.lid && !m.away_from_loser));
|
const winnerMatch = result.find(m => (m.home_from_lid === match.lid && !m.home_from_loser) || (m.away_from_lid === match.lid && !m.away_from_loser));
|
||||||
const loserMatch = result.find(m => (m.home_from_lid === match.lid && m.home_from_loser) || (m.away_from_lid === match.lid && m.away_from_loser));
|
const loserMatch = result.find(m => (m.home_from_lid === match.lid && m.home_from_loser) || (m.away_from_lid === match.lid && m.away_from_loser));
|
||||||
|
|
||||||
console.log(winnerMatch, loserMatch)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
winner: winnerMatch ? transformMatch(winnerMatch) : undefined,
|
winner: winnerMatch ? transformMatch(winnerMatch) : undefined,
|
||||||
loser: loserMatch ? transformMatch(loserMatch) : undefined
|
loser: loserMatch ? transformMatch(loserMatch) : undefined
|
||||||
|
|||||||
Reference in New Issue
Block a user