refactor(enrollment): drop count header, keep player-count warnings

This commit is contained in:
2026-08-26 19:12:33 -07:00
parent 4106c3c846
commit f13e5b752a
8 changed files with 70 additions and 105 deletions
@@ -1,48 +0,0 @@
import { Alert, Group, Stack, Text } from "@mantine/core";
import { WarningCircleIcon } from "@phosphor-icons/react";
import { Trans, Plural } from "@lingui/react/macro";
interface EnrollmentStatsProps {
count: number;
regional?: boolean;
}
const EnrollmentStats = (props: EnrollmentStatsProps) => {
const hasOddPlayers = props.count % 2 !== 0;
const hasEnoughPlayers = props.count >= 2;
return (
<Stack gap="xs">
<Group gap="xs" align="baseline">
<Text size="xl" fw={700}>
{props.count}
</Text>
<Text size="sm" c="dimmed">
{props.regional ? (
<Plural
value={props.count}
one="player enrolled"
other="players enrolled"
/>
) : (
<Trans>Enrolled Teams</Trans>
)}
</Text>
</Group>
{props.regional && !hasEnoughPlayers && (
<Alert color="yellow" icon={<WarningCircleIcon size={16} />}>
<Trans>Need at least 2 players to create teams</Trans>
</Alert>
)}
{props.regional && hasOddPlayers && (
<Alert color="red" icon={<WarningCircleIcon size={16} />}>
<Trans>Cannot create teams with an odd number of players. Please have one player unenroll.</Trans>
</Alert>
)}
</Stack>
);
};
export default EnrollmentStats;
@@ -0,0 +1,28 @@
import { Alert, Stack } from "@mantine/core";
import { WarningCircleIcon } from "@phosphor-icons/react";
import { Trans } from "@lingui/react/macro";
const EnrollmentWarnings = ({ count }: { count: number }) => {
const hasOddPlayers = count % 2 !== 0;
const hasEnoughPlayers = count >= 2;
if (hasEnoughPlayers && !hasOddPlayers) return null;
return (
<Stack gap="xs">
{!hasEnoughPlayers && (
<Alert color="yellow" icon={<WarningCircleIcon size={16} />}>
<Trans>Need at least 2 players to create teams</Trans>
</Alert>
)}
{hasEnoughPlayers && hasOddPlayers && (
<Alert color="red" icon={<WarningCircleIcon size={16} />}>
<Trans>Cannot create teams with an odd number of players. Please have one player unenroll.</Trans>
</Alert>
)}
</Stack>
);
};
export default EnrollmentWarnings;
@@ -18,7 +18,7 @@ import Typeahead, { TypeaheadOption } from "@/components/typeahead";
import { usePlayers } from "@/features/players/queries";
import useAdminEnrollPlayer from "../../hooks/use-admin-enroll-player";
import useAdminUnenrollPlayer from "../../hooks/use-admin-unenroll-player";
import EnrollmentStats from "./enrollment-stats";
import EnrollmentWarnings from "./enrollment-warnings";
interface FreeAgentSectionProps {
tournamentId: string;
@@ -117,7 +117,7 @@ const FreeAgentSection = ({ tournamentId }: FreeAgentSectionProps) => {
return (
<Stack gap="lg" w="100%">
<EnrollmentStats count={enrolledPlayers.length} regional />
<EnrollmentWarnings count={enrolledPlayers.length} />
<Box
pos="sticky"
@@ -21,7 +21,6 @@ import Sheet from "@/components/sheet/sheet";
import TeamForm from "@/features/teams/components/team-form";
import { useTeam } from "@/features/teams/queries";
import { useSheet } from "@/hooks/use-sheet";
import EnrollmentStats from "./enrollment-stats";
interface TeamSectionProps {
tournamentId: string;
@@ -200,8 +199,6 @@ const TeamSection = ({ tournamentId }: TeamSectionProps) => {
return (
<>
<Stack gap="lg" w="100%">
<EnrollmentStats count={enrolledTeams.length} />
<Box
pos="sticky"
top={0}
+10 -13
View File
@@ -59,7 +59,7 @@ msgstr "{0, plural, one {# Spieler} other {# Spieler}}"
#. placeholder {0}: enrolledTeams.length
#. placeholder {0}: group.teams.length
#. placeholder {0}: orderedTeams.length
#: src/features/tournaments/components/enrollment/team-section.tsx:243
#: src/features/tournaments/components/enrollment/team-section.tsx:240
#: src/features/tournaments/components/group-preview.tsx:27
#: src/features/tournaments/components/seed-tournament.tsx:116
#: src/features/tournaments/components/setup-group-stage.tsx:224
@@ -87,9 +87,7 @@ msgid "{0, plural, one {# wildcard} other {# wildcards}}"
msgstr "{0, plural, one {# Wildcard} other {# Wildcards}}"
#. placeholder {0}: freeAgents.length
#. placeholder {0}: props.count
#: src/app/routes/_authed/admin/tournaments/$id/assign-partners.tsx:124
#: src/features/tournaments/components/enrollment/enrollment-stats.tsx:22
msgid "{0, plural, one {player enrolled} other {players enrolled}}"
msgstr "{0, plural, one {Spieler angemeldet} other {Spieler angemeldet}}"
@@ -441,7 +439,7 @@ msgstr "Leg FLXN auf deinen Homescreen für ein flüssigeres Erlebnis"
msgid "Add Player"
msgstr "Spieler hinzufügen"
#: src/features/tournaments/components/enrollment/team-section.tsx:213
#: src/features/tournaments/components/enrollment/team-section.tsx:210
msgid "Add Team"
msgstr "Team hinzufügen"
@@ -680,7 +678,7 @@ msgid "Cannot create groups"
msgstr "Gruppen können nicht erstellt werden"
#: src/app/routes/_authed/admin/tournaments/$id/assign-partners.tsx:136
#: src/features/tournaments/components/enrollment/enrollment-stats.tsx:41
#: src/features/tournaments/components/enrollment/enrollment-warnings.tsx:21
msgid "Cannot create teams with an odd number of players. Please have one player unenroll."
msgstr "Teams können nicht mit einer ungeraden Anzahl an Spielern erstellt werden. Bitte lass einen Spieler austragen."
@@ -953,7 +951,7 @@ msgstr "Frühere regionale Formate werden in der App nicht unterstützt. Die Rei
#. placeholder {0}: team.name
#: src/features/teams/components/manage-teams.tsx:35
#: src/features/tournaments/components/enrollment/team-section.tsx:96
#: src/features/tournaments/components/enrollment/team-section.tsx:95
msgid "Edit {0}"
msgstr "{0} bearbeiten"
@@ -976,7 +974,7 @@ msgid "Edit Rules"
msgstr "Regeln bearbeiten"
#: src/features/teams/components/manage-teams.tsx:35
#: src/features/tournaments/components/enrollment/team-section.tsx:96
#: src/features/tournaments/components/enrollment/team-section.tsx:95
msgid "Edit Team"
msgstr "Team bearbeiten"
@@ -1042,8 +1040,7 @@ msgstr "Angemeldet"
msgid "Enrolled Players"
msgstr "Angemeldete Spieler"
#: src/features/tournaments/components/enrollment/enrollment-stats.tsx:28
#: src/features/tournaments/components/enrollment/team-section.tsx:240
#: src/features/tournaments/components/enrollment/team-section.tsx:237
#: src/features/tournaments/components/started-tournament/sections/nav-grid.tsx:126
#: src/features/tournaments/components/upcoming-tournament/team-list-button.tsx:31
msgid "Enrolled Teams"
@@ -1537,7 +1534,7 @@ msgstr "Verwalten"
msgid "Manage {name}"
msgstr "{name} verwalten"
#: src/features/tournaments/components/enrollment/team-section.tsx:234
#: src/features/tournaments/components/enrollment/team-section.tsx:231
msgid "Manage Team Songs/Logos"
msgstr "Team-Songs/Logos verwalten"
@@ -1657,7 +1654,7 @@ msgid "Name updated successfully!"
msgstr "Name erfolgreich aktualisiert!"
#: src/app/routes/_authed/admin/tournaments/$id/assign-partners.tsx:130
#: src/features/tournaments/components/enrollment/enrollment-stats.tsx:35
#: src/features/tournaments/components/enrollment/enrollment-warnings.tsx:15
msgid "Need at least 2 players to create teams"
msgstr "Mindestens 2 Spieler nötig, um Teams zu erstellen"
@@ -1810,7 +1807,7 @@ msgstr "Keine Teams zugewiesen"
msgid "No Teams Enrolled"
msgstr "Keine Teams angemeldet"
#: src/features/tournaments/components/enrollment/team-section.tsx:253
#: src/features/tournaments/components/enrollment/team-section.tsx:250
msgid "No teams enrolled yet"
msgstr "Noch keine Teams angemeldet"
@@ -2208,7 +2205,7 @@ msgstr "Spieler zum Anmelden suchen..."
msgid "Search for songs..."
msgstr "Nach Songs suchen..."
#: src/features/tournaments/components/enrollment/team-section.tsx:216
#: src/features/tournaments/components/enrollment/team-section.tsx:213
msgid "Search for teams to enroll..."
msgstr "Teams zum Anmelden suchen..."
+10 -13
View File
@@ -59,7 +59,7 @@ msgstr "{0, plural, one {# player} other {# players}}"
#. placeholder {0}: enrolledTeams.length
#. placeholder {0}: group.teams.length
#. placeholder {0}: orderedTeams.length
#: src/features/tournaments/components/enrollment/team-section.tsx:243
#: src/features/tournaments/components/enrollment/team-section.tsx:240
#: src/features/tournaments/components/group-preview.tsx:27
#: src/features/tournaments/components/seed-tournament.tsx:116
#: src/features/tournaments/components/setup-group-stage.tsx:224
@@ -87,9 +87,7 @@ msgid "{0, plural, one {# wildcard} other {# wildcards}}"
msgstr "{0, plural, one {# wildcard} other {# wildcards}}"
#. placeholder {0}: freeAgents.length
#. placeholder {0}: props.count
#: src/app/routes/_authed/admin/tournaments/$id/assign-partners.tsx:124
#: src/features/tournaments/components/enrollment/enrollment-stats.tsx:22
msgid "{0, plural, one {player enrolled} other {players enrolled}}"
msgstr "{0, plural, one {player enrolled} other {players enrolled}}"
@@ -441,7 +439,7 @@ msgstr "Add FLXN to your home screen for a smoother experience"
msgid "Add Player"
msgstr "Add Player"
#: src/features/tournaments/components/enrollment/team-section.tsx:213
#: src/features/tournaments/components/enrollment/team-section.tsx:210
msgid "Add Team"
msgstr "Add Team"
@@ -680,7 +678,7 @@ msgid "Cannot create groups"
msgstr "Cannot create groups"
#: src/app/routes/_authed/admin/tournaments/$id/assign-partners.tsx:136
#: src/features/tournaments/components/enrollment/enrollment-stats.tsx:41
#: src/features/tournaments/components/enrollment/enrollment-warnings.tsx:21
msgid "Cannot create teams with an odd number of players. Please have one player unenroll."
msgstr "Cannot create teams with an odd number of players. Please have one player unenroll."
@@ -953,7 +951,7 @@ msgstr "Earlier regional formats aren't supported in the app and order of matche
#. placeholder {0}: team.name
#: src/features/teams/components/manage-teams.tsx:35
#: src/features/tournaments/components/enrollment/team-section.tsx:96
#: src/features/tournaments/components/enrollment/team-section.tsx:95
msgid "Edit {0}"
msgstr "Edit {0}"
@@ -976,7 +974,7 @@ msgid "Edit Rules"
msgstr "Edit Rules"
#: src/features/teams/components/manage-teams.tsx:35
#: src/features/tournaments/components/enrollment/team-section.tsx:96
#: src/features/tournaments/components/enrollment/team-section.tsx:95
msgid "Edit Team"
msgstr "Edit Team"
@@ -1042,8 +1040,7 @@ msgstr "Enrolled"
msgid "Enrolled Players"
msgstr "Enrolled Players"
#: src/features/tournaments/components/enrollment/enrollment-stats.tsx:28
#: src/features/tournaments/components/enrollment/team-section.tsx:240
#: src/features/tournaments/components/enrollment/team-section.tsx:237
#: src/features/tournaments/components/started-tournament/sections/nav-grid.tsx:126
#: src/features/tournaments/components/upcoming-tournament/team-list-button.tsx:31
msgid "Enrolled Teams"
@@ -1537,7 +1534,7 @@ msgstr "Manage"
msgid "Manage {name}"
msgstr "Manage {name}"
#: src/features/tournaments/components/enrollment/team-section.tsx:234
#: src/features/tournaments/components/enrollment/team-section.tsx:231
msgid "Manage Team Songs/Logos"
msgstr "Manage Team Songs/Logos"
@@ -1657,7 +1654,7 @@ msgid "Name updated successfully!"
msgstr "Name updated successfully!"
#: src/app/routes/_authed/admin/tournaments/$id/assign-partners.tsx:130
#: src/features/tournaments/components/enrollment/enrollment-stats.tsx:35
#: src/features/tournaments/components/enrollment/enrollment-warnings.tsx:15
msgid "Need at least 2 players to create teams"
msgstr "Need at least 2 players to create teams"
@@ -1810,7 +1807,7 @@ msgstr "No teams assigned"
msgid "No Teams Enrolled"
msgstr "No Teams Enrolled"
#: src/features/tournaments/components/enrollment/team-section.tsx:253
#: src/features/tournaments/components/enrollment/team-section.tsx:250
msgid "No teams enrolled yet"
msgstr "No teams enrolled yet"
@@ -2208,7 +2205,7 @@ msgstr "Search for players to enroll..."
msgid "Search for songs..."
msgstr "Search for songs..."
#: src/features/tournaments/components/enrollment/team-section.tsx:216
#: src/features/tournaments/components/enrollment/team-section.tsx:213
msgid "Search for teams to enroll..."
msgstr "Search for teams to enroll..."
+10 -13
View File
@@ -59,7 +59,7 @@ msgstr "{0, plural, one {# jugador} other {# jugadores}}"
#. placeholder {0}: enrolledTeams.length
#. placeholder {0}: group.teams.length
#. placeholder {0}: orderedTeams.length
#: src/features/tournaments/components/enrollment/team-section.tsx:243
#: src/features/tournaments/components/enrollment/team-section.tsx:240
#: src/features/tournaments/components/group-preview.tsx:27
#: src/features/tournaments/components/seed-tournament.tsx:116
#: src/features/tournaments/components/setup-group-stage.tsx:224
@@ -87,9 +87,7 @@ msgid "{0, plural, one {# wildcard} other {# wildcards}}"
msgstr "{0, plural, one {# comodín} other {# comodines}}"
#. placeholder {0}: freeAgents.length
#. placeholder {0}: props.count
#: src/app/routes/_authed/admin/tournaments/$id/assign-partners.tsx:124
#: src/features/tournaments/components/enrollment/enrollment-stats.tsx:22
msgid "{0, plural, one {player enrolled} other {players enrolled}}"
msgstr "{0, plural, one {jugador inscrito} other {jugadores inscritos}}"
@@ -441,7 +439,7 @@ msgstr "Agrega FLXN a tu pantalla de inicio para una experiencia más fluida"
msgid "Add Player"
msgstr "Agregar Jugador"
#: src/features/tournaments/components/enrollment/team-section.tsx:213
#: src/features/tournaments/components/enrollment/team-section.tsx:210
msgid "Add Team"
msgstr "Agregar Equipo"
@@ -680,7 +678,7 @@ msgid "Cannot create groups"
msgstr "No se pueden crear grupos"
#: src/app/routes/_authed/admin/tournaments/$id/assign-partners.tsx:136
#: src/features/tournaments/components/enrollment/enrollment-stats.tsx:41
#: src/features/tournaments/components/enrollment/enrollment-warnings.tsx:21
msgid "Cannot create teams with an odd number of players. Please have one player unenroll."
msgstr "No se pueden crear equipos con un número impar de jugadores. Pide que un jugador se dé de baja."
@@ -953,7 +951,7 @@ msgstr "Los formatos regionales anteriores no son compatibles con la app, así q
#. placeholder {0}: team.name
#: src/features/teams/components/manage-teams.tsx:35
#: src/features/tournaments/components/enrollment/team-section.tsx:96
#: src/features/tournaments/components/enrollment/team-section.tsx:95
msgid "Edit {0}"
msgstr "Editar {0}"
@@ -976,7 +974,7 @@ msgid "Edit Rules"
msgstr "Editar reglas"
#: src/features/teams/components/manage-teams.tsx:35
#: src/features/tournaments/components/enrollment/team-section.tsx:96
#: src/features/tournaments/components/enrollment/team-section.tsx:95
msgid "Edit Team"
msgstr "Editar equipo"
@@ -1042,8 +1040,7 @@ msgstr "Inscrito"
msgid "Enrolled Players"
msgstr "Jugadores inscritos"
#: src/features/tournaments/components/enrollment/enrollment-stats.tsx:28
#: src/features/tournaments/components/enrollment/team-section.tsx:240
#: src/features/tournaments/components/enrollment/team-section.tsx:237
#: src/features/tournaments/components/started-tournament/sections/nav-grid.tsx:126
#: src/features/tournaments/components/upcoming-tournament/team-list-button.tsx:31
msgid "Enrolled Teams"
@@ -1537,7 +1534,7 @@ msgstr "Administrar"
msgid "Manage {name}"
msgstr "Administrar {name}"
#: src/features/tournaments/components/enrollment/team-section.tsx:234
#: src/features/tournaments/components/enrollment/team-section.tsx:231
msgid "Manage Team Songs/Logos"
msgstr "Administrar canciones/logos del equipo"
@@ -1657,7 +1654,7 @@ msgid "Name updated successfully!"
msgstr "¡Nombre actualizado con éxito!"
#: src/app/routes/_authed/admin/tournaments/$id/assign-partners.tsx:130
#: src/features/tournaments/components/enrollment/enrollment-stats.tsx:35
#: src/features/tournaments/components/enrollment/enrollment-warnings.tsx:15
msgid "Need at least 2 players to create teams"
msgstr "Se necesitan al menos 2 jugadores para crear equipos"
@@ -1810,7 +1807,7 @@ msgstr "No hay equipos asignados"
msgid "No Teams Enrolled"
msgstr "No hay equipos inscritos"
#: src/features/tournaments/components/enrollment/team-section.tsx:253
#: src/features/tournaments/components/enrollment/team-section.tsx:250
msgid "No teams enrolled yet"
msgstr "Aún no hay equipos inscritos"
@@ -2208,7 +2205,7 @@ msgstr "Buscar jugadores para inscribir..."
msgid "Search for songs..."
msgstr "Buscar canciones..."
#: src/features/tournaments/components/enrollment/team-section.tsx:216
#: src/features/tournaments/components/enrollment/team-section.tsx:213
msgid "Search for teams to enroll..."
msgstr "Buscar equipos para inscribir..."
+10 -13
View File
@@ -59,7 +59,7 @@ msgstr "{0, plural, one {#人のプレイヤー} other {#人のプレイヤー}}
#. placeholder {0}: enrolledTeams.length
#. placeholder {0}: group.teams.length
#. placeholder {0}: orderedTeams.length
#: src/features/tournaments/components/enrollment/team-section.tsx:243
#: src/features/tournaments/components/enrollment/team-section.tsx:240
#: src/features/tournaments/components/group-preview.tsx:27
#: src/features/tournaments/components/seed-tournament.tsx:116
#: src/features/tournaments/components/setup-group-stage.tsx:224
@@ -87,9 +87,7 @@ msgid "{0, plural, one {# wildcard} other {# wildcards}}"
msgstr "{0, plural, one {ワイルドカード#枠} other {ワイルドカード#枠}}"
#. placeholder {0}: freeAgents.length
#. placeholder {0}: props.count
#: src/app/routes/_authed/admin/tournaments/$id/assign-partners.tsx:124
#: src/features/tournaments/components/enrollment/enrollment-stats.tsx:22
msgid "{0, plural, one {player enrolled} other {players enrolled}}"
msgstr "{0, plural, one {人のプレイヤーが登録済み} other {人のプレイヤーが登録済み}}"
@@ -441,7 +439,7 @@ msgstr "FLXNをホーム画面に追加すると、もっと快適に使えま
msgid "Add Player"
msgstr "プレイヤーを追加"
#: src/features/tournaments/components/enrollment/team-section.tsx:213
#: src/features/tournaments/components/enrollment/team-section.tsx:210
msgid "Add Team"
msgstr "チームを追加"
@@ -680,7 +678,7 @@ msgid "Cannot create groups"
msgstr "グループを作成できません"
#: src/app/routes/_authed/admin/tournaments/$id/assign-partners.tsx:136
#: src/features/tournaments/components/enrollment/enrollment-stats.tsx:41
#: src/features/tournaments/components/enrollment/enrollment-warnings.tsx:21
msgid "Cannot create teams with an odd number of players. Please have one player unenroll."
msgstr "参加者が奇数のためチームを作成できません。どなたか1人、参加を取り消してください。"
@@ -953,7 +951,7 @@ msgstr "以前の地域フォーマットはアプリでサポートされてい
#. placeholder {0}: team.name
#: src/features/teams/components/manage-teams.tsx:35
#: src/features/tournaments/components/enrollment/team-section.tsx:96
#: src/features/tournaments/components/enrollment/team-section.tsx:95
msgid "Edit {0}"
msgstr "{0}を編集"
@@ -976,7 +974,7 @@ msgid "Edit Rules"
msgstr "ルールを編集"
#: src/features/teams/components/manage-teams.tsx:35
#: src/features/tournaments/components/enrollment/team-section.tsx:96
#: src/features/tournaments/components/enrollment/team-section.tsx:95
msgid "Edit Team"
msgstr "チームを編集"
@@ -1042,8 +1040,7 @@ msgstr "登録済み"
msgid "Enrolled Players"
msgstr "登録済みプレイヤー"
#: src/features/tournaments/components/enrollment/enrollment-stats.tsx:28
#: src/features/tournaments/components/enrollment/team-section.tsx:240
#: src/features/tournaments/components/enrollment/team-section.tsx:237
#: src/features/tournaments/components/started-tournament/sections/nav-grid.tsx:126
#: src/features/tournaments/components/upcoming-tournament/team-list-button.tsx:31
msgid "Enrolled Teams"
@@ -1537,7 +1534,7 @@ msgstr "管理"
msgid "Manage {name}"
msgstr "{name}を管理"
#: src/features/tournaments/components/enrollment/team-section.tsx:234
#: src/features/tournaments/components/enrollment/team-section.tsx:231
msgid "Manage Team Songs/Logos"
msgstr "チームの曲・ロゴを管理"
@@ -1657,7 +1654,7 @@ msgid "Name updated successfully!"
msgstr "名前を更新しました!"
#: src/app/routes/_authed/admin/tournaments/$id/assign-partners.tsx:130
#: src/features/tournaments/components/enrollment/enrollment-stats.tsx:35
#: src/features/tournaments/components/enrollment/enrollment-warnings.tsx:15
msgid "Need at least 2 players to create teams"
msgstr "チームを作成するには2人以上のプレイヤーが必要です"
@@ -1810,7 +1807,7 @@ msgstr "割り当てられたチームがありません"
msgid "No Teams Enrolled"
msgstr "登録されたチームがありません"
#: src/features/tournaments/components/enrollment/team-section.tsx:253
#: src/features/tournaments/components/enrollment/team-section.tsx:250
msgid "No teams enrolled yet"
msgstr "まだチームが登録されていません"
@@ -2208,7 +2205,7 @@ msgstr "登録するプレイヤーを検索..."
msgid "Search for songs..."
msgstr "曲を検索..."
#: src/features/tournaments/components/enrollment/team-section.tsx:216
#: src/features/tournaments/components/enrollment/team-section.tsx:213
msgid "Search for teams to enroll..."
msgstr "登録するチームを検索..."