This commit is contained in:
Kalle (Sendou)
2022-01-12 23:04:02 +02:00
parent 3bff18fae8
commit 18aaef9854
4 changed files with 20 additions and 17 deletions

View File

@@ -1,22 +1,22 @@
import { ActionFunction, json, useLoaderData, useMatches } from "remix";
import type { LinksFunction, LoaderFunction } from "remix";
import { EliminationBracket } from "~/components/tournament/EliminationBracket";
import styles from "~/styles/tournament-bracket.css";
import { ActionFunction, json, useMatches } from "remix";
import invariant from "tiny-invariant";
import type { FindTournamentByNameForUrlI } from "~/services/tournament";
import { bracketById, reportScore, undoLastScore } from "~/services/bracket";
import type { BracketModified } from "~/services/bracket";
import { useEvents, useUser } from "~/utils/hooks";
import { BracketActions } from "~/components/tournament/BracketActions";
import { z } from "zod";
import { BracketActions } from "~/components/tournament/BracketActions";
import { EliminationBracket } from "~/components/tournament/EliminationBracket";
import { BEST_OF_OPTIONS, TOURNAMENT_TEAM_ROSTER_MIN_SIZE } from "~/constants";
import { useBracketDataWithEvents } from "~/hooks/useBracketDataWithEvents";
import type { BracketModified } from "~/services/bracket";
import { bracketById, reportScore, undoLastScore } from "~/services/bracket";
import type { FindTournamentByNameForUrlI } from "~/services/tournament";
import styles from "~/styles/tournament-bracket.css";
import {
parseRequestFormData,
requireEvents,
requireUser,
safeJSONParse,
} from "~/utils";
import { BEST_OF_OPTIONS, TOURNAMENT_TEAM_ROSTER_MIN_SIZE } from "~/constants";
import { useBracketDataWithEvents } from "~/hooks/useBracketDataWithEvents";
import { useUser } from "~/utils/hooks";
export const links: LinksFunction = () => {
return [{ rel: "stylesheet", href: styles }];

View File

@@ -259,16 +259,18 @@ export async function reportScore({
reporterId: userId,
winner: winnerTeam.order,
});
const upperParticipant = match.participants.find(
(p) => p.order === "UPPER"
)!;
);
const lowerParticipant = match.participants.find(
(p) => p.order === "LOWER"
)!;
);
return [
match.position,
upperParticipant.team.name,
lowerParticipant.team.name,
upperParticipant?.team.name ?? null,
lowerParticipant?.team.name ?? null,
newScore[0],
newScore[1],
];

View File

@@ -31,6 +31,7 @@ export const useEvents = (
});
source.addEventListener("message", (e) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
handleEvent(JSON.parse(e.data));
});

View File

@@ -4,8 +4,8 @@ import { v4 as uuidv4 } from "uuid";
export type BracketData = [
matchNumber: number,
teamUpper: string,
teamLower: string,
teamUpper: string | null,
teamLower: string | null,
scoreUpper: number,
scoreLower: number
];
@@ -70,7 +70,7 @@ const sendEvent = ({
data,
}: {
res: Response;
data: Array<string | number>;
data: Array<string | number | null>;
}) => {
res.write(`data: ${JSON.stringify(data)}\n\n`);
};