require full teams for bracket initialization
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -168,4 +168,9 @@ Folgende Dateien wurden in diesem Prompt verändert:
|
||||
- Rename the settings page to Profile
|
||||
Folgende Dateien wurden in diesem Prompt verändert:
|
||||
- frontend_splatournament_manager/lib/pages/settings_page.dart
|
||||
- frontend_splatournament_manager/lib/pages/home_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
|
||||
@@ -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)),
|
||||
),
|
||||
];
|
||||
},
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -114,7 +119,7 @@ class TeamProvider extends ChangeNotifier {
|
||||
Future<List<Map<String, dynamic>>> getMyTeamsTournaments() async {
|
||||
final userTeams = await getUserTeams();
|
||||
final Set<Map<String, dynamic>> tournamentsSet = {};
|
||||
|
||||
|
||||
for (final team in userTeams) {
|
||||
try {
|
||||
final tournaments = await _teamService.getTournamentsByTeam(team.id);
|
||||
@@ -123,8 +128,7 @@ class TeamProvider extends ChangeNotifier {
|
||||
// If a team has no tournaments, continue with others
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return tournamentsSet.toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user