refactoring

sync3
Laurent 6 months ago
parent 6cefe91b37
commit c7575d1d67
  1. 2
      PadelClub/Views/Calling/GroupStageCallingView.swift
  2. 14
      PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift
  3. 2
      PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift
  4. 2
      PadelClub/Views/GroupStage/GroupStageView.swift
  5. 6
      PadelClub/Views/GroupStage/GroupStagesSettingsView.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: {

@ -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)

@ -103,7 +103,7 @@ struct GroupStageTeamView: View {
team.groupStagePosition = nil
team.groupStage = nil
_save()
groupStage._matches().forEach({ $0.updateTeamScores() })
groupStage.matches().forEach({ $0.updateTeamScores() })
}
}
}

@ -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 {

@ -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)

Loading…
Cancel
Save