From 13b7d7e2a7d288584b156782d5d418d54dee633d Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sat, 25 Jul 2026 07:50:28 +0300 Subject: [PATCH] KO refactor --- .../match-page/MatchActionTab.module.css | 2 +- app/components/match-page/MatchActionTab.tsx | 27 +++--- .../routes/match-page-test.tsx | 2 +- .../scrims/components/ScrimMatchActionTab.tsx | 2 +- .../components/SendouQMatchActionTab.tsx | 2 +- .../tournament-bracket/core/engine/types.ts | 2 +- .../tournament-bracket-schemas.server.ts | 30 +------ .../actions/to.$id.matches.$mid.server.ts | 82 +++++++++---------- .../components/TournamentMatchActionTab.tsx | 8 +- .../components/TournamentMatchAdminTab.tsx | 25 ++---- 10 files changed, 72 insertions(+), 110 deletions(-) diff --git a/app/components/match-page/MatchActionTab.module.css b/app/components/match-page/MatchActionTab.module.css index b8b018a77..870054a45 100644 --- a/app/components/match-page/MatchActionTab.module.css +++ b/app/components/match-page/MatchActionTab.module.css @@ -21,7 +21,7 @@ } } -.withPoints { +.withKo { grid-template-areas: "header header header" "actions actions actions" diff --git a/app/components/match-page/MatchActionTab.tsx b/app/components/match-page/MatchActionTab.tsx index 34536f839..791fcac32 100644 --- a/app/components/match-page/MatchActionTab.tsx +++ b/app/components/match-page/MatchActionTab.tsx @@ -39,8 +39,8 @@ interface MatchActionTabProps { ownTeamId: number | null; stageId: StageId; mode: ModeShort; - withPoints: boolean; - onSubmit?: (data: { winnerId: number; points?: [number, number] }) => void; + withKo: boolean; + onSubmit?: (data: { winnerId: number; ko?: boolean }) => void; isSubmitting?: boolean; setEnding?: SetEndingData; actionButtons?: React.ReactNode; @@ -52,7 +52,7 @@ export function MatchActionTab({ ownTeamId, stageId, mode, - withPoints, + withKo, onSubmit, isSubmitting, setEnding, @@ -73,14 +73,7 @@ export function MatchActionTab({ const submit = () => { if (winnerId === null) return; - const submitPoints: [number, number] | undefined = withPoints - ? isKo - ? winnerId === teams[0].id - ? [100, 0] - : [0, 100] - : [0, 0] - : undefined; - onSubmit?.({ winnerId, points: submitPoints }); + onSubmit?.({ winnerId, ko: withKo ? isKo : undefined }); }; return ( @@ -92,14 +85,14 @@ export function MatchActionTab({ mode={mode} winnerId={winnerId} teams={teams} - withPoints={withPoints} + withKo={withKo} isKo={isKo} isSubmitting={isSubmitting} onBack={() => setConfirming(false)} onConfirm={submit} /> ) : ( -
+
{t("q:match.action.selectWinner")}
{actionButtons ? (
{actionButtons}
@@ -156,7 +149,7 @@ export function MatchActionTab({ /> - {withPoints ? ( + {withKo ? (
@@ -375,12 +375,12 @@ function EditReportedScoreRow({ index, result, teams, - withPoints, + withKo, }: { index: number; result: TournamentMatchLoaderData["results"][number]; teams: [TournamentDataTeam, TournamentDataTeam]; - withPoints: boolean; + withKo: boolean; }) { const { t } = useTranslation(["common", "game-misc", "tournament"]); const tournament = useTournament(); @@ -433,7 +433,7 @@ function EditReportedScoreRow({ fetcher={fetcher} result={result} teams={teams} - withPoints={withPoints} + withKo={withKo} minMembersPerTeam={tournament.minMembersPerTeam} onCancel={() => setEditing(false)} index={index} @@ -445,7 +445,7 @@ function EditReportedScoreForm({ fetcher, result, teams, - withPoints, + withKo, minMembersPerTeam, onCancel, index, @@ -453,7 +453,7 @@ function EditReportedScoreForm({ fetcher: ReturnType; result: TournamentMatchLoaderData["results"][number]; teams: [TournamentDataTeam, TournamentDataTeam]; - withPoints: boolean; + withKo: boolean; minMembersPerTeam: number; onCancel: () => void; index: number; @@ -475,13 +475,6 @@ function EditReportedScoreForm({ result.opponentOnePoints === 100 || result.opponentTwoPoints === 100, ); - const team0Won = result.winnerTeamId === teams[0].id; - const points: [number, number] = isKO - ? team0Won - ? [100, 0] - : [0, 100] - : [0, 0]; - const formValid = checkedPlayers.every( (team) => team.length === minMembersPerTeam, ); @@ -536,9 +529,9 @@ function EditReportedScoreForm({ name="rosters" value={JSON.stringify(checkedPlayers)} /> - {withPoints ? ( + {withKo ? ( <> - +