From c7575d1d675328f31e0ea4a91d91b84037e7114e Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 26 May 2025 12:31:39 +0200 Subject: [PATCH] refactoring --- .../Views/Calling/GroupStageCallingView.swift | 2 +- .../Components/GroupStageSettingsView.swift | 14 +++++++------- .../GroupStage/Components/GroupStageTeamView.swift | 2 +- PadelClub/Views/GroupStage/GroupStageView.swift | 2 +- .../Views/GroupStage/GroupStagesSettingsView.swift | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/PadelClub/Views/Calling/GroupStageCallingView.swift b/PadelClub/Views/Calling/GroupStageCallingView.swift index bfade2a..7dc9f34 100644 --- a/PadelClub/Views/Calling/GroupStageCallingView.swift +++ b/PadelClub/Views/Calling/GroupStageCallingView.swift @@ -114,7 +114,7 @@ struct GroupStageCallingView: View { } } .overlay { - if groupStage.startDate == nil && groupStage._matches().filter({ $0.startDate != nil }).isEmpty { + if groupStage.startDate == nil && groupStage.matches().filter({ $0.startDate != nil }).isEmpty { ContentUnavailableView { Label("Aucun horaire défini", systemImage: "clock.badge.questionmark") } description: { diff --git a/PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift b/PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift index a7968eb..9a84d8c 100644 --- a/PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift +++ b/PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift @@ -27,7 +27,7 @@ struct GroupStageSettingsView: View { _groupStage = Bindable(groupStage) _groupStageName = .init(wrappedValue: groupStage.name ?? "") _size = .init(wrappedValue: groupStage.size) - _courtIndex = .init(wrappedValue: groupStage._matches().first?.courtIndex ?? 0) + _courtIndex = .init(wrappedValue: groupStage.matches().first?.courtIndex ?? 0) } var tournamentStore: TournamentStore? { @@ -66,12 +66,12 @@ struct GroupStageSettingsView: View { Section { CourtPicker(title: "Terrain dédié", selection: $courtIndex, maxCourt: tournament.courtCount) RowButtonView("Confirmer", role: .destructive) { - groupStage._matches().forEach { match in + groupStage.matches().forEach { match in match.setCourt(courtIndex) } do { - try tournamentStore?.matches.addOrUpdate(contentOfs: groupStage._matches()) + try tournamentStore?.matches.addOrUpdate(contentOfs: groupStage.matches()) } catch { Logger.error(error) } @@ -91,7 +91,7 @@ struct GroupStageSettingsView: View { teams.forEach { team in team.groupStagePosition = nil team.groupStage = nil - groupStage._matches().forEach({ $0.updateTeamScores() }) + groupStage.matches().forEach({ $0.updateTeamScores() }) } do { try tournamentStore?.teamRegistrations.addOrUpdate(contentOfs: teams) @@ -111,13 +111,13 @@ struct GroupStageSettingsView: View { Section { RowButtonView("Retirer tous les horaires", role: .destructive) { - groupStage._matches().forEach { match in + groupStage.matches().forEach { match in match.startDate = nil match.endDate = nil } do { - try tournamentStore?.matches.addOrUpdate(contentOfs: groupStage._matches()) + try tournamentStore?.matches.addOrUpdate(contentOfs: groupStage.matches()) } catch { Logger.error(error) } @@ -130,7 +130,7 @@ struct GroupStageSettingsView: View { teams.forEach { team in team.groupStagePosition = nil team.groupStage = nil - groupStage._matches().forEach({ $0.updateTeamScores() }) + groupStage.matches().forEach({ $0.updateTeamScores() }) } do { try tournamentStore?.teamRegistrations.addOrUpdate(contentOfs: teams) diff --git a/PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift b/PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift index 2ed3de8..cb93030 100644 --- a/PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift +++ b/PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift @@ -103,7 +103,7 @@ struct GroupStageTeamView: View { team.groupStagePosition = nil team.groupStage = nil _save() - groupStage._matches().forEach({ $0.updateTeamScores() }) + groupStage.matches().forEach({ $0.updateTeamScores() }) } } } diff --git a/PadelClub/Views/GroupStage/GroupStageView.swift b/PadelClub/Views/GroupStage/GroupStageView.swift index f0bff80..a85d47d 100644 --- a/PadelClub/Views/GroupStage/GroupStageView.swift +++ b/PadelClub/Views/GroupStage/GroupStageView.swift @@ -245,7 +245,7 @@ struct GroupStageView: View { print(team.pasteData()) team.groupStage = groupStage.id team.groupStagePosition = index - groupStage._matches().forEach({ $0.updateTeamScores() }) + groupStage.matches().forEach({ $0.updateTeamScores() }) do { try tournamentStore?.teamRegistrations.addOrUpdate(instance: team) } catch { diff --git a/PadelClub/Views/GroupStage/GroupStagesSettingsView.swift b/PadelClub/Views/GroupStage/GroupStagesSettingsView.swift index 67dff1c..a9cd798 100644 --- a/PadelClub/Views/GroupStage/GroupStagesSettingsView.swift +++ b/PadelClub/Views/GroupStage/GroupStagesSettingsView.swift @@ -144,8 +144,8 @@ struct GroupStagesSettingsView: View { Section { RowButtonView("Retirer tous les horaires", role: .destructive) { - let matches = tournament.groupStages().flatMap({ $0._matches() }) - tournament.groupStages().flatMap({ $0._matches() }).forEach { match in + let matches = tournament.groupStages().flatMap({ $0.matches() }) + tournament.groupStages().flatMap({ $0.matches() }).forEach { match in match.startDate = nil match.endDate = nil } @@ -239,7 +239,7 @@ struct GroupStagesSettingsView: View { teams.forEach { team in team.groupStagePosition = nil team.groupStage = nil - groupStage._matches().forEach({ $0.updateTeamScores() }) + groupStage.matches().forEach({ $0.updateTeamScores() }) } do { try tournamentStore?.teamRegistrations.addOrUpdate(contentOfs: teams)