League division tournament sub text styling

This commit is contained in:
Kalle
2026-06-11 21:52:49 +03:00
parent f09a4f347e
commit f33d4ded53
10 changed files with 85 additions and 10 deletions

View File

@@ -6834,6 +6834,7 @@ export const LOW_INK_DECEMBER_2024 = (): TournamentData => ({
id: 815,
eventId: 2614,
parentTournamentId: null,
parentTournamentName: null,
tier: null,
tentativeTier: null,
discordUrl: "https://discord.gg/F7RaNUR",

View File

@@ -1934,6 +1934,7 @@ export const SWIM_OR_SINK_167 = (
ctx: {
id: 672,
parentTournamentId: null,
parentTournamentName: null,
tier: null,
tentativeTier: null,
eventId: 2425,

View File

@@ -323,6 +323,7 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
mapPickingStyle: "TO",
hasRules: true,
parentTournamentId: null,
parentTournamentName: null,
name: "Zones Weekly 38",
startTime: 1734685200,
isFinalized: 0,

View File

@@ -1399,6 +1399,7 @@ export const PADDLING_POOL_257 = () =>
tier: null,
tentativeTier: null,
parentTournamentId: null,
parentTournamentName: null,
tags: null,
eventId: 1352,
bracketProgressionOverrides: [],
@@ -8068,6 +8069,7 @@ export const PADDLING_POOL_255 = () =>
tier: null,
tentativeTier: null,
parentTournamentId: null,
parentTournamentName: null,
tags: null,
eventId: 1286,
bracketProgressionOverrides: [],
@@ -15074,6 +15076,7 @@ export const IN_THE_ZONE_32 = ({
ctx: {
id: 11,
parentTournamentId: null,
parentTournamentName: null,
organization: null,
tier: null,
tentativeTier: null,

View File

@@ -67,6 +67,7 @@ export const testTournament = ({
tier: null,
tentativeTier: null,
parentTournamentId: null,
parentTournamentName: null,
hasRules: false,
logoUrl: "/test.avif",
discordUrl: null,

View File

@@ -58,6 +58,15 @@ export async function findById(id: number) {
"Tournament.mapPickingStyle",
sql<boolean>`"Tournament"."rules" is not null`.as("hasRules"),
"Tournament.parentTournamentId",
eb
.selectFrom("CalendarEvent as ParentCalendarEvent")
.select("ParentCalendarEvent.name")
.whereRef(
"ParentCalendarEvent.tournamentId",
"=",
"Tournament.parentTournamentId",
)
.as("parentTournamentName"),
"Tournament.tier",
"CalendarEvent.name",
"CalendarEventDate.startTime",

View File

@@ -16,14 +16,11 @@ import {
tournamentPage,
userPage,
} from "~/utils/urls";
import { splitTournamentName } from "../tournament-utils";
import { tournamentNameParts } from "../tournament-utils";
import styles from "./TournamentHeader.module.css";
export function TournamentHeader({ tournament }: { tournament: Tournament }) {
const { name, subtext } = splitTournamentName(
tournament.ctx.name,
tournament.ctx.organization?.series ?? [],
);
const { name, subtext } = tournamentNameParts(tournament);
const startTimes = R.uniqueBy(
[

View File

@@ -26,7 +26,7 @@ import {
tournamentInfoPage,
tournamentRulesPage,
} from "~/utils/urls";
import { splitTournamentName } from "../tournament-utils";
import { tournamentNameParts } from "../tournament-utils";
import styles from "./TournamentNav.module.css";
type NavItemKey =
@@ -77,10 +77,7 @@ export function TournamentNav({
const overflowItems = navItems.slice(visibleCount);
const { name, subtext } = splitTournamentName(
tournament.ctx.name,
tournament.ctx.organization?.series ?? [],
);
const { name, subtext } = tournamentNameParts(tournament);
const homeHref = tournament.isLeagueDivision
? tournamentInfoPage(tournament.ctx.parentTournamentId!)

View File

@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
import type { CastedMatchesInfo } from "~/db/tables";
import * as Seasons from "../mmr/core/Seasons";
import type { ParsedBracket } from "../tournament-bracket/core/Progression";
import { testTournament } from "../tournament-bracket/core/tests/test-utils";
import {
bracketProgressionLabel,
compareTeamsForOrdering,
@@ -11,6 +12,7 @@ import {
splitTournamentName,
type TeamForOrdering,
tournamentInWeaponReportingWindow,
tournamentNameParts,
updatedCastedMatchesInfo,
} from "./tournament-utils";
@@ -756,6 +758,44 @@ describe("splitTournamentName", () => {
});
});
describe("tournamentNameParts", () => {
it("uses the parent tournament name and division subtext for a league division", () => {
const tournament = testTournament({
ctx: {
name: "LUTI: Season 17 - Division 1",
parentTournamentId: 1,
parentTournamentName: "LUTI: Season 17",
},
});
expect(tournamentNameParts(tournament)).toEqual({
name: "LUTI: Season 17",
subtext: "Division 1",
});
});
it("falls back to the organization series when not a league division", () => {
const tournament = testTournament({
ctx: {
name: "In The Zone 54",
organization: {
id: 1,
name: "Sendou's Tournaments",
slug: "sendou",
logoUrl: null,
members: [],
series: [{ name: "In The Zone" }],
},
},
});
expect(tournamentNameParts(tournament)).toEqual({
name: "In The Zone",
subtext: "54",
});
});
});
describe("bracketProgressionLabel", () => {
it("returns the short code for a single stage", () => {
expect(bracketProgressionLabel([{ type: "single_elimination" }])).toBe(

View File

@@ -464,6 +464,31 @@ export function splitTournamentName(
return { name: matchingSeries.name, subtext };
}
/**
* Resolves the display name and subtext for a tournament's identity.
*
* For a league division the parent tournament name is used as the base name and
* the division name (e.g. `"Division 1"`) becomes the subtext. For all other
* tournaments the split is based on the organization's tournament series.
*
* @see {@link splitTournamentName}
*/
export function tournamentNameParts(tournament: TournamentClass): {
name: string;
subtext?: string;
} {
if (tournament.isLeagueDivision && tournament.ctx.parentTournamentName) {
return splitTournamentName(tournament.ctx.name, [
{ name: tournament.ctx.parentTournamentName },
]);
}
return splitTournamentName(
tournament.ctx.name,
tournament.ctx.organization?.series ?? [],
);
}
const STAGE_TYPE_TO_SHORT_CODE: Record<
Tables["TournamentStage"]["type"],
string