fix seed removing not deleting team score

add a refresh team button in groupestage setting view
set tournament date start date when finishing a match before the set startdate
paca_championship
Raz 1 year ago
parent 31ee3cef62
commit c21d4688e3
  1. 12
      PadelClub/Data/Match.swift
  2. 10
      PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift
  3. 10
      PadelClub/Views/Match/MatchSetupView.swift

@ -546,7 +546,17 @@ defer {
groupStageObject?.updateGroupStageState() groupStageObject?.updateGroupStageState()
roundObject?.updateTournamentState() roundObject?.updateTournamentState()
currentTournament()?.updateTournamentState() if let tournament = currentTournament(), let endDate, let startDate {
if endDate.isEarlierThan(tournament.startDate) {
tournament.startDate = startDate
}
do {
try DataStore.shared.tournaments.addOrUpdate(instance: tournament)
} catch {
Logger.error(error)
}
tournament.updateTournamentState()
}
updateFollowingMatchTeamScore() updateFollowingMatchTeamScore()
} }

@ -149,6 +149,16 @@ struct GroupStageSettingsView: View {
Text("Tous les matchs seront recronstruits, les données des matchs seront perdus.") Text("Tous les matchs seront recronstruits, les données des matchs seront perdus.")
} }
Section {
RowButtonView("Rafraichir", role: .destructive) {
let playedMatches = groupStage.playedMatches()
playedMatches.forEach { match in
match.updateTeamScores()
}
}
} footer: {
Text("Mets à jour les équipes de la poule si jamais une erreur est persistante.")
}
} }
.onChange(of: size) { .onChange(of: size) {
if size != groupStage.size { if size != groupStage.size {

@ -190,15 +190,21 @@ struct MatchSetupView: View {
func _removeTeam(team: TeamRegistration, teamPosition: TeamPosition) -> some View { func _removeTeam(team: TeamRegistration, teamPosition: TeamPosition) -> some View {
Button(role: .cancel) { Button(role: .cancel) {
//todo
if match.isSeededBy(team: team, inTeamPosition: teamPosition) { if match.isSeededBy(team: team, inTeamPosition: teamPosition) {
if let score = match.teamScore(ofTeam: team) {
do {
try tournamentStore.teamScores.delete(instance: score)
} catch {
Logger.error(error)
}
}
team.bracketPosition = nil team.bracketPosition = nil
do { do {
try tournamentStore.teamRegistrations.addOrUpdate(instance: team) try tournamentStore.teamRegistrations.addOrUpdate(instance: team)
} catch { } catch {
Logger.error(error) Logger.error(error)
} }
//match.updateTeamScores()
match.previousMatches().forEach { previousMatch in match.previousMatches().forEach { previousMatch in
if previousMatch.disabled { if previousMatch.disabled {
previousMatch.enableMatch() previousMatch.enableMatch()

Loading…
Cancel
Save