require full teams for bracket initialization

This commit is contained in:
2026-03-13 15:04:17 +01:00
parent cc7faf477b
commit 95897ccc07
6 changed files with 40 additions and 22 deletions

View File

@@ -75,11 +75,19 @@ app.post('/tournaments/:id/bracket', authMiddleware, async (req: Request, res: R
const tournamentId = +req.params.id;
const teams = await teamService.getTeamsByTournamentId(tournamentId);
const teamIds = teams.map(team => team.id);
const tournament = await tournamentService.getTournamentById(tournamentId);
if (!tournament) {
return res.status(404).send({error: 'Turnier nicht gefunden'});
}
if (teamIds.length < 2) {
return res.status(400).send({error: 'Mindestens 2 Teams sind erforderlich, um den Turnierbaum zu initialisieren'});
}
if (teamIds.length < tournament.maxTeamAmount) {
return res.status(400).send({error: `Es müssen alle ${tournament.maxTeamAmount} Teams angemeldet sein, um den Turnierbaum zu initialisieren`});
}
await matchService.initializeBracket(tournamentId, teamIds);
res.status(201).send({message: 'Turnierbaum erfolgreich initialisiert'});
} catch (err) {

View File

@@ -169,3 +169,8 @@ Folgende Dateien wurden in diesem Prompt verändert:
Folgende Dateien wurden in diesem Prompt verändert:
- frontend_splatournament_manager/lib/pages/settings_page.dart
- frontend_splatournament_manager/lib/pages/home_page.dart
- Always require the full amount of teams for initializing the bracket.
Folgende Dateien wurden in diesem Prompt verändert:
- backend_splatournament_manager/src/app.ts
- frontend_splatournament_manager/lib/pages/tournament_bracket_page.dart

View File

@@ -70,10 +70,7 @@ class _HomePageState extends State<HomePage> {
const PopupMenuItem(value: 1, child: Text('Profil')),
const PopupMenuItem(
value: 2,
child: Text(
'Abmelden',
style: TextStyle(color: Colors.red),
),
child: Text('Abmelden', style: TextStyle(color: Colors.red)),
),
];
},

View File

@@ -158,15 +158,17 @@ class _TournamentBracketPageState extends State<TournamentBracketPage> {
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: teams.length >= 2 ? _initializeBracket : null,
onPressed: teams.length >= widget.tournament.maxTeamAmount
? _initializeBracket
: null,
child: const Text('Turnierbaum initialisieren'),
),
if (teams.length < 2)
const Padding(
padding: EdgeInsets.only(top: 8),
if (teams.length < widget.tournament.maxTeamAmount)
Padding(
padding: const EdgeInsets.only(top: 8),
child: Text(
'Mindestens 2 Teams erforderlich',
style: TextStyle(color: Colors.red),
'${teams.length}/${widget.tournament.maxTeamAmount} Teams angemeldet',
style: const TextStyle(color: Colors.red),
),
),
],

View File

@@ -61,7 +61,12 @@ class TeamProvider extends ChangeNotifier {
String? tag,
String? description,
}) async {
await _teamService.updateTeam(id, name: name, tag: tag, description: description);
await _teamService.updateTeam(
id,
name: name,
tag: tag,
description: description,
);
await refreshTeams();
}
@@ -127,4 +132,3 @@ class TeamProvider extends ChangeNotifier {
return tournamentsSet.toList();
}
}

View File

@@ -52,8 +52,9 @@ class MyTeamsWidget extends StatelessWidget {
final memberCountText = team.memberCount != null
? "${team.memberCount}/4 Mitglieder"
: "Keine Mitglieder";
final description =
team.description.isEmpty ? "Keine Beschreibung" : team.description;
final description = team.description.isEmpty
? "Keine Beschreibung"
: team.description;
return Card(
margin: const EdgeInsets.only(bottom: 12),
@@ -93,9 +94,10 @@ class MyTeamsWidget extends StatelessWidget {
if (confirmed == true && context.mounted) {
try {
await Provider.of<TeamProvider>(context, listen: false).leaveTeam(
team.id,
);
await Provider.of<TeamProvider>(
context,
listen: false,
).leaveTeam(team.id);
if (context.mounted) {
ScaffoldMessenger.of(
context,