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 tournamentId = +req.params.id;
|
||||||
const teams = await teamService.getTeamsByTournamentId(tournamentId);
|
const teams = await teamService.getTeamsByTournamentId(tournamentId);
|
||||||
const teamIds = teams.map(team => team.id);
|
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) {
|
if (teamIds.length < 2) {
|
||||||
return res.status(400).send({error: 'Mindestens 2 Teams sind erforderlich, um den Turnierbaum zu initialisieren'});
|
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);
|
await matchService.initializeBracket(tournamentId, teamIds);
|
||||||
res.status(201).send({message: 'Turnierbaum erfolgreich initialisiert'});
|
res.status(201).send({message: 'Turnierbaum erfolgreich initialisiert'});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -169,3 +169,8 @@ Folgende Dateien wurden in diesem Prompt verändert:
|
|||||||
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/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: 1, child: Text('Profil')),
|
||||||
const PopupMenuItem(
|
const PopupMenuItem(
|
||||||
value: 2,
|
value: 2,
|
||||||
child: Text(
|
child: Text('Abmelden', style: TextStyle(color: Colors.red)),
|
||||||
'Abmelden',
|
|
||||||
style: TextStyle(color: Colors.red),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -158,15 +158,17 @@ class _TournamentBracketPageState extends State<TournamentBracketPage> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: teams.length >= 2 ? _initializeBracket : null,
|
onPressed: teams.length >= widget.tournament.maxTeamAmount
|
||||||
|
? _initializeBracket
|
||||||
|
: null,
|
||||||
child: const Text('Turnierbaum initialisieren'),
|
child: const Text('Turnierbaum initialisieren'),
|
||||||
),
|
),
|
||||||
if (teams.length < 2)
|
if (teams.length < widget.tournament.maxTeamAmount)
|
||||||
const Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(top: 8),
|
padding: const EdgeInsets.only(top: 8),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Mindestens 2 Teams erforderlich',
|
'${teams.length}/${widget.tournament.maxTeamAmount} Teams angemeldet',
|
||||||
style: TextStyle(color: Colors.red),
|
style: const TextStyle(color: Colors.red),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -61,7 +61,12 @@ class TeamProvider extends ChangeNotifier {
|
|||||||
String? tag,
|
String? tag,
|
||||||
String? description,
|
String? description,
|
||||||
}) async {
|
}) async {
|
||||||
await _teamService.updateTeam(id, name: name, tag: tag, description: description);
|
await _teamService.updateTeam(
|
||||||
|
id,
|
||||||
|
name: name,
|
||||||
|
tag: tag,
|
||||||
|
description: description,
|
||||||
|
);
|
||||||
await refreshTeams();
|
await refreshTeams();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,4 +132,3 @@ class TeamProvider extends ChangeNotifier {
|
|||||||
return tournamentsSet.toList();
|
return tournamentsSet.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,9 @@ class MyTeamsWidget extends StatelessWidget {
|
|||||||
final memberCountText = team.memberCount != null
|
final memberCountText = team.memberCount != null
|
||||||
? "${team.memberCount}/4 Mitglieder"
|
? "${team.memberCount}/4 Mitglieder"
|
||||||
: "Keine Mitglieder";
|
: "Keine Mitglieder";
|
||||||
final description =
|
final description = team.description.isEmpty
|
||||||
team.description.isEmpty ? "Keine Beschreibung" : team.description;
|
? "Keine Beschreibung"
|
||||||
|
: team.description;
|
||||||
|
|
||||||
return Card(
|
return Card(
|
||||||
margin: const EdgeInsets.only(bottom: 12),
|
margin: const EdgeInsets.only(bottom: 12),
|
||||||
@@ -93,9 +94,10 @@ class MyTeamsWidget extends StatelessWidget {
|
|||||||
|
|
||||||
if (confirmed == true && context.mounted) {
|
if (confirmed == true && context.mounted) {
|
||||||
try {
|
try {
|
||||||
await Provider.of<TeamProvider>(context, listen: false).leaveTeam(
|
await Provider.of<TeamProvider>(
|
||||||
team.id,
|
context,
|
||||||
);
|
listen: false,
|
||||||
|
).leaveTeam(team.id);
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
ScaffoldMessenger.of(
|
ScaffoldMessenger.of(
|
||||||
context,
|
context,
|
||||||
|
|||||||
Reference in New Issue
Block a user