From e8d41853ff89245da09a728125136dba89256bf5 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Wed, 4 Jun 2025 07:54:40 +0200 Subject: [PATCH] add a forfait button in team group stage view --- .../Components/GroupStageTeamView.swift | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift b/PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift index 2ed3de8..00e83b9 100644 --- a/PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift +++ b/PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift @@ -106,6 +106,29 @@ struct GroupStageTeamView: View { groupStage._matches().forEach({ $0.updateTeamScores() }) } } + + if let groupStagePosition = team.groupStagePosition { + Section { + RowButtonView("Forfait", role: .destructive) { + team.walkOut = true + let matches = groupStage.matches(forGroupStagePosition: groupStagePosition) + .filter({ + $0.hasStarted() == false && $0.hasEnded() == false + }) + + matches + .forEach({ + if let teamPosition = $0.teamPosition(for: team) { + $0.setWalkOut(teamPosition) + } + }) + tournamentStore?.matches.addOrUpdate(contentOfs: matches) + _save() + } + } footer: { + Text("En indiquant cette équipe forfaite, le résultat des matchs restant dans la poule seront mis à \(defaultScore) pour leur adversaire.") + } + } } } } @@ -184,6 +207,10 @@ struct GroupStageTeamView: View { .navigationTitle("Détail de l'équipe") } + private var defaultScore: String { + groupStage.matchFormat.defaultWalkOutScore(false).compactMap({ String($0) + "/0" }).joined(separator: " ") + } + private var _networkErrorMessage: String { ContactManagerError.getNetworkErrorMessage(sentError: sentError, networkMonitorConnected: networkMonitor.connected) }