mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-21 18:04:39 -05:00
Tournament fixes (#2596)
This commit is contained in:
parent
63f101ea6d
commit
48bf097107
|
|
@ -196,10 +196,10 @@ export function PlacementsTable({
|
|||
|
||||
const key = () => {
|
||||
if (overridenDestinationBracket === null) {
|
||||
return "null";
|
||||
return `${s.team.id}-null`;
|
||||
}
|
||||
|
||||
return overridenDestinationBracket?.idx;
|
||||
return `${s.team.id}-${overridenDestinationBracket?.idx}`;
|
||||
};
|
||||
|
||||
const renderQualifiedRow =
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import type { adminActionSchema } from "~/features/tournament/actions/to.$id.admin.server";
|
||||
import type { adminActionSchema } from "~/features/tournament/tournament-schemas.server";
|
||||
import {
|
||||
dbInsertTournament,
|
||||
dbInsertTournamentTeam,
|
||||
|
|
|
|||
|
|
@ -509,7 +509,8 @@
|
|||
}
|
||||
|
||||
.tournament-bracket__compactify-button svg {
|
||||
width: 0.85rem;
|
||||
min-width: 0.85rem;
|
||||
max-width: 0.85rem;
|
||||
}
|
||||
|
||||
.tournament-bracket__cast-info-container {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import type { ActionFunction } from "@remix-run/node";
|
||||
import { z } from "zod/v4";
|
||||
import { requireUser } from "~/features/auth/core/user.server";
|
||||
import { userIsBanned } from "~/features/ban/core/banned.server";
|
||||
import { bracketProgressionSchema } from "~/features/calendar/calendar-schemas";
|
||||
import * as ShowcaseTournaments from "~/features/front-page/core/ShowcaseTournaments.server";
|
||||
import { notify } from "~/features/notifications/core/notify.server";
|
||||
import * as TournamentTeamRepository from "~/features/tournament/TournamentTeamRepository.server";
|
||||
|
|
@ -11,7 +9,6 @@ import {
|
|||
clearTournamentDataCache,
|
||||
tournamentFromDB,
|
||||
} from "~/features/tournament-bracket/core/Tournament.server";
|
||||
import { USER } from "~/features/user-page/user-page-constants";
|
||||
import invariant from "~/utils/invariant";
|
||||
import { logger } from "~/utils/logger";
|
||||
import {
|
||||
|
|
@ -22,13 +19,12 @@ import {
|
|||
successToast,
|
||||
} from "~/utils/remix.server";
|
||||
import { assertUnreachable } from "~/utils/types";
|
||||
import { _action, id, idObject } from "../../../utils/zod";
|
||||
import { bracketIdx } from "../../tournament-bracket/tournament-bracket-schemas.server";
|
||||
import { idObject } from "../../../utils/zod";
|
||||
import { changeTeamOwner } from "../queries/changeTeamOwner.server";
|
||||
import { deleteTeam } from "../queries/deleteTeam.server";
|
||||
import { joinTeam, leaveTeam } from "../queries/joinLeaveTeam.server";
|
||||
import * as TournamentRepository from "../TournamentRepository.server";
|
||||
import { teamName } from "../tournament-schemas.server";
|
||||
import { adminActionSchema } from "../tournament-schemas.server";
|
||||
import { inGameNameIfNeeded } from "../tournament-utils.server";
|
||||
|
||||
export const action: ActionFunction = async ({ request, params }) => {
|
||||
|
|
@ -458,95 +454,3 @@ export const action: ActionFunction = async ({ request, params }) => {
|
|||
|
||||
return successToast(message);
|
||||
};
|
||||
|
||||
export const adminActionSchema = z.union([
|
||||
z.object({
|
||||
_action: _action("CHANGE_TEAM_OWNER"),
|
||||
teamId: id,
|
||||
memberId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("CHANGE_TEAM_NAME"),
|
||||
teamId: id,
|
||||
teamName,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("CHECK_IN"),
|
||||
teamId: id,
|
||||
bracketIdx,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("CHECK_OUT"),
|
||||
teamId: id,
|
||||
bracketIdx,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("ADD_MEMBER"),
|
||||
teamId: id,
|
||||
userId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("REMOVE_MEMBER"),
|
||||
teamId: id,
|
||||
memberId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("DELETE_TEAM"),
|
||||
teamId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("ADD_TEAM"),
|
||||
userId: id,
|
||||
teamName,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("ADD_STAFF"),
|
||||
userId: id,
|
||||
role: z.enum(["ORGANIZER", "STREAMER"]),
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("REMOVE_STAFF"),
|
||||
userId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("DROP_TEAM_OUT"),
|
||||
teamId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("UNDO_DROP_TEAM_OUT"),
|
||||
teamId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("DELETE_LOGO"),
|
||||
teamId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("UPDATE_CAST_TWITCH_ACCOUNTS"),
|
||||
castTwitchAccounts: z.preprocess(
|
||||
(val) =>
|
||||
typeof val === "string"
|
||||
? val
|
||||
.split(",")
|
||||
.map((account) => account.trim())
|
||||
.map((account) => account.toLowerCase())
|
||||
: val,
|
||||
z.array(z.string()),
|
||||
),
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("RESET_BRACKET"),
|
||||
stageId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("UPDATE_IN_GAME_NAME"),
|
||||
inGameNameText: z.string().max(USER.IN_GAME_NAME_TEXT_MAX_LENGTH),
|
||||
inGameNameDiscriminator: z
|
||||
.string()
|
||||
.refine((val) => /^[0-9a-z]{4,5}$/.test(val)),
|
||||
memberId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("UPDATE_TOURNAMENT_PROGRESSION"),
|
||||
bracketProgression: bracketProgressionSchema,
|
||||
}),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -330,7 +330,17 @@ function TeamActions() {
|
|||
<label htmlFor="bracket">Bracket</label>
|
||||
<select id="bracket" name="bracketIdx">
|
||||
{tournament.brackets.map((bracket, bracketIdx) => (
|
||||
<option key={bracket.name} value={bracketIdx}>
|
||||
<option
|
||||
key={bracket.name}
|
||||
value={
|
||||
// no sources means it's a starting bracket
|
||||
// in terms of check out and check in
|
||||
// bracket idx = 0 refers to the check-in for the tournament as a whole
|
||||
!bracket.sources || bracket.sources.length === 0
|
||||
? 0
|
||||
: bracketIdx
|
||||
}
|
||||
>
|
||||
{bracket.name}
|
||||
</option>
|
||||
))}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ import {
|
|||
safeStringSchema,
|
||||
stageId,
|
||||
} from "~/utils/zod";
|
||||
import { bracketProgressionSchema } from "../calendar/calendar-schemas";
|
||||
import { bracketIdx } from "../tournament-bracket/tournament-bracket-schemas.server";
|
||||
import { USER } from "../user-page/user-page-constants";
|
||||
import { TOURNAMENT } from "./tournament-constants";
|
||||
|
||||
export const teamName = safeStringSchema({
|
||||
|
|
@ -75,3 +77,95 @@ export const seedsActionSchema = z.union([
|
|||
export const joinSchema = z.object({
|
||||
trust: z.preprocess(checkboxValueToBoolean, z.boolean()),
|
||||
});
|
||||
|
||||
export const adminActionSchema = z.union([
|
||||
z.object({
|
||||
_action: _action("CHANGE_TEAM_OWNER"),
|
||||
teamId: id,
|
||||
memberId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("CHANGE_TEAM_NAME"),
|
||||
teamId: id,
|
||||
teamName,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("CHECK_IN"),
|
||||
teamId: id,
|
||||
bracketIdx,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("CHECK_OUT"),
|
||||
teamId: id,
|
||||
bracketIdx,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("ADD_MEMBER"),
|
||||
teamId: id,
|
||||
userId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("REMOVE_MEMBER"),
|
||||
teamId: id,
|
||||
memberId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("DELETE_TEAM"),
|
||||
teamId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("ADD_TEAM"),
|
||||
userId: id,
|
||||
teamName,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("ADD_STAFF"),
|
||||
userId: id,
|
||||
role: z.enum(["ORGANIZER", "STREAMER"]),
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("REMOVE_STAFF"),
|
||||
userId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("DROP_TEAM_OUT"),
|
||||
teamId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("UNDO_DROP_TEAM_OUT"),
|
||||
teamId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("DELETE_LOGO"),
|
||||
teamId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("UPDATE_CAST_TWITCH_ACCOUNTS"),
|
||||
castTwitchAccounts: z.preprocess(
|
||||
(val) =>
|
||||
typeof val === "string"
|
||||
? val
|
||||
.split(",")
|
||||
.map((account) => account.trim())
|
||||
.map((account) => account.toLowerCase())
|
||||
: val,
|
||||
z.array(z.string()),
|
||||
),
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("RESET_BRACKET"),
|
||||
stageId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("UPDATE_IN_GAME_NAME"),
|
||||
inGameNameText: z.string().max(USER.IN_GAME_NAME_TEXT_MAX_LENGTH),
|
||||
inGameNameDiscriminator: z
|
||||
.string()
|
||||
.refine((val) => /^[0-9a-z]{4,5}$/.test(val)),
|
||||
memberId: id,
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("UPDATE_TOURNAMENT_PROGRESSION"),
|
||||
bracketProgression: bracketProgressionSchema,
|
||||
}),
|
||||
]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user