update apischedule public func

update try? to try catch
multistore
Razmig Sarkissian 1 year ago
parent 7fdfb0aec2
commit 41650dfa90
  1. 6
      PadelClub/Data/GroupStage.swift
  2. 54
      PadelClub/Data/Match.swift
  3. 24
      PadelClub/Data/MatchScheduler.swift
  4. 6
      PadelClub/Data/MonthData.swift
  5. 24
      PadelClub/Data/Round.swift
  6. 6
      PadelClub/Data/TeamRegistration.swift
  7. 60
      PadelClub/Data/Tournament.swift
  8. 12
      PadelClub/Views/Calling/CallSettingsView.swift
  9. 7
      PadelClub/Views/Calling/CallView.swift
  10. 13
      PadelClub/Views/Cashier/CashierSettingsView.swift
  11. 19
      PadelClub/Views/Club/CourtView.swift
  12. 7
      PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift
  13. 6
      PadelClub/Views/GroupStage/GroupStageSettingsView.swift
  14. 7
      PadelClub/Views/Match/MatchDetailView.swift
  15. 67
      PadelClub/Views/Match/MatchSetupView.swift
  16. 7
      PadelClub/Views/Navigation/Agenda/CalendarView.swift
  17. 30
      PadelClub/Views/Navigation/Toolbox/ToolboxView.swift
  18. 31
      PadelClub/Views/Planning/CourtAvailabilitySettingsView.swift
  19. 7
      PadelClub/Views/Planning/GroupStageScheduleEditorView.swift
  20. 7
      PadelClub/Views/Planning/LoserRoundScheduleEditorView.swift
  21. 7
      PadelClub/Views/Planning/LoserRoundStepScheduleEditorView.swift
  22. 7
      PadelClub/Views/Planning/RoundScheduleEditorView.swift
  23. 25
      PadelClub/Views/Player/Components/EditablePlayerView.swift
  24. 7
      PadelClub/Views/Player/Components/PlayerPayView.swift
  25. 13
      PadelClub/Views/Player/PlayerDetailView.swift
  26. 7
      PadelClub/Views/Player/PlayerView.swift
  27. 24
      PadelClub/Views/Round/RoundSettingsView.swift
  28. 13
      PadelClub/Views/Round/RoundView.swift
  29. 7
      PadelClub/Views/Team/EditingTeamView.swift
  30. 6
      PadelClub/Views/Tournament/FileImportView.swift
  31. 12
      PadelClub/Views/Tournament/Screen/Components/TournamentMatchFormatsSettingsView.swift
  32. 48
      PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift

@ -233,7 +233,11 @@ class GroupStage: ModelObject, Storable {
} }
private func _removeMatches() { private func _removeMatches() {
try? DataStore.shared.matches.delete(contentOfs: _matches()) do {
try DataStore.shared.matches.delete(contentOfs: _matches())
} catch {
Logger.error(error)
}
} }
private func _numberOfMatchesToBuild() -> Int { private func _numberOfMatchesToBuild() -> Int {

@ -184,15 +184,27 @@ class Match: ModelObject, Storable {
func teamWillBeWalkOut(_ team: TeamRegistration) { func teamWillBeWalkOut(_ team: TeamRegistration) {
resetMatch() resetMatch()
let previousScores = teamScores.filter({ $0.luckyLoser != nil }) let previousScores = teamScores.filter({ $0.luckyLoser != nil })
try? DataStore.shared.teamScores.delete(contentOfs: previousScores) do {
try DataStore.shared.teamScores.delete(contentOfs: previousScores)
} catch {
Logger.error(error)
}
if let existingTeamScore = teamScore(ofTeam: team) { if let existingTeamScore = teamScore(ofTeam: team) {
try? DataStore.shared.teamScores.delete(instance: existingTeamScore) do {
try DataStore.shared.teamScores.delete(instance: existingTeamScore)
} catch {
Logger.error(error)
}
} }
let teamScoreWalkout = TeamScore(match: id, team: team) let teamScoreWalkout = TeamScore(match: id, team: team)
teamScoreWalkout.walkOut = 1 teamScoreWalkout.walkOut = 1
try? DataStore.shared.teamScores.addOrUpdate(instance: teamScoreWalkout) do {
try DataStore.shared.teamScores.addOrUpdate(instance: teamScoreWalkout)
} catch {
Logger.error(error)
}
} }
func luckyLosers() -> [TeamRegistration] { func luckyLosers() -> [TeamRegistration] {
@ -206,17 +218,29 @@ class Match: ModelObject, Storable {
func setLuckyLoser(team: TeamRegistration, teamPosition: TeamPosition) { func setLuckyLoser(team: TeamRegistration, teamPosition: TeamPosition) {
resetMatch() resetMatch()
let previousScores = teamScores.filter({ $0.luckyLoser != nil }) let previousScores = teamScores.filter({ $0.luckyLoser != nil })
try? DataStore.shared.teamScores.delete(contentOfs: previousScores) do {
try DataStore.shared.teamScores.delete(contentOfs: previousScores)
} catch {
Logger.error(error)
}
if let existingTeamScore = teamScore(ofTeam: team) { if let existingTeamScore = teamScore(ofTeam: team) {
try? DataStore.shared.teamScores.delete(instance: existingTeamScore) do {
try DataStore.shared.teamScores.delete(instance: existingTeamScore)
} catch {
Logger.error(error)
}
} }
let matchIndex = index let matchIndex = index
let position = matchIndex * 2 + teamPosition.rawValue let position = matchIndex * 2 + teamPosition.rawValue
let teamScoreLuckyLoser = TeamScore(match: id, team: team) let teamScoreLuckyLoser = TeamScore(match: id, team: team)
teamScoreLuckyLoser.luckyLoser = position teamScoreLuckyLoser.luckyLoser = position
try? DataStore.shared.teamScores.addOrUpdate(instance: teamScoreLuckyLoser) do {
try DataStore.shared.teamScores.addOrUpdate(instance: teamScoreLuckyLoser)
} catch {
Logger.error(error)
}
} }
func disableMatch() { func disableMatch() {
@ -299,7 +323,11 @@ class Match: ModelObject, Storable {
//if disabled == state { return } //if disabled == state { return }
disabled = state disabled = state
//byeState = false //byeState = false
//try? DataStore.shared.matches.addOrUpdate(instance: self) do {
try DataStore.shared.matches.addOrUpdate(instance: self)
} catch {
Logger.error(error)
}
_toggleLoserMatchDisableState(state) _toggleLoserMatchDisableState(state)
if forward { if forward {
@ -403,7 +431,11 @@ class Match: ModelObject, Storable {
teamScoreWalkout.walkOut = 0 teamScoreWalkout.walkOut = 0
let teamScoreWinning = teamScore(teamPosition.otherTeam) ?? TeamScore(match: id, team: team(teamPosition.otherTeam)) let teamScoreWinning = teamScore(teamPosition.otherTeam) ?? TeamScore(match: id, team: team(teamPosition.otherTeam))
teamScoreWinning.walkOut = nil teamScoreWinning.walkOut = nil
try? DataStore.shared.teamScores.addOrUpdate(contentOfs: [teamScoreWalkout, teamScoreWinning]) do {
try DataStore.shared.teamScores.addOrUpdate(contentOfs: [teamScoreWalkout, teamScoreWinning])
} catch {
Logger.error(error)
}
if endDate == nil { if endDate == nil {
endDate = Date() endDate = Date()
@ -433,7 +465,11 @@ class Match: ModelObject, Storable {
teamScoreOne.score = matchDescriptor.teamOneScores.joined(separator: ",") teamScoreOne.score = matchDescriptor.teamOneScores.joined(separator: ",")
let teamScoreTwo = teamScore(.two) ?? TeamScore(match: id, team: team(.two)) let teamScoreTwo = teamScore(.two) ?? TeamScore(match: id, team: team(.two))
teamScoreTwo.score = matchDescriptor.teamTwoScores.joined(separator: ",") teamScoreTwo.score = matchDescriptor.teamTwoScores.joined(separator: ",")
try? DataStore.shared.teamScores.addOrUpdate(contentOfs: [teamScoreOne, teamScoreTwo]) do {
try DataStore.shared.teamScores.addOrUpdate(contentOfs: [teamScoreOne, teamScoreTwo])
} catch {
Logger.error(error)
}
matchFormat = matchDescriptor.matchFormat matchFormat = matchDescriptor.matchFormat
} }

@ -98,7 +98,11 @@ class MatchScheduler : ModelObject, Storable {
if let first = times.first { if let first = times.first {
if first.isEarlierThan(tournament.startDate) { if first.isEarlierThan(tournament.startDate) {
tournament.startDate = first tournament.startDate = first
try? DataStore.shared.tournaments.addOrUpdate(instance: tournament) do {
try DataStore.shared.tournaments.addOrUpdate(instance: tournament)
} catch {
Logger.error(error)
}
} }
} }
@ -123,7 +127,11 @@ class MatchScheduler : ModelObject, Storable {
groupStages.filter({ $0.startDate == nil || times.contains($0.startDate!) == false }).chunked(into: computedGroupStageChunkCount).forEach { groups in groupStages.filter({ $0.startDate == nil || times.contains($0.startDate!) == false }).chunked(into: computedGroupStageChunkCount).forEach { groups in
groups.forEach({ $0.startDate = lastDate }) groups.forEach({ $0.startDate = lastDate })
try? DataStore.shared.groupStages.addOrUpdate(contentOfs: groups) do {
try DataStore.shared.groupStages.addOrUpdate(contentOfs: groups)
} catch {
Logger.error(error)
}
let dispatch = groupStageDispatcher(numberOfCourtsAvailablePerRotation: numberOfCourtsAvailablePerRotation, groupStages: groups, startingDate: lastDate) let dispatch = groupStageDispatcher(numberOfCourtsAvailablePerRotation: numberOfCourtsAvailablePerRotation, groupStages: groups, startingDate: lastDate)
@ -140,7 +148,11 @@ class MatchScheduler : ModelObject, Storable {
} }
} }
} }
try? DataStore.shared.matches.addOrUpdate(contentOfs: matches) do {
try DataStore.shared.matches.addOrUpdate(contentOfs: matches)
} catch {
Logger.error(error)
}
return lastDate return lastDate
} }
@ -609,7 +621,11 @@ class MatchScheduler : ModelObject, Storable {
} }
} }
try? DataStore.shared.matches.addOrUpdate(contentOfs: allMatches) do {
try DataStore.shared.matches.addOrUpdate(contentOfs: allMatches)
} catch {
Logger.error(error)
}
} }

@ -47,7 +47,11 @@ class MonthData : ModelObject, Storable {
currentMonthData.femaleUnrankedValue = lastDataSourceFemaleUnranked?.0 currentMonthData.femaleUnrankedValue = lastDataSourceFemaleUnranked?.0
currentMonthData.femaleCount = lastDataSourceFemaleUnranked?.1 currentMonthData.femaleCount = lastDataSourceFemaleUnranked?.1
currentMonthData.anonymousCount = anonymousCount currentMonthData.anonymousCount = anonymousCount
try? DataStore.shared.monthData.addOrUpdate(instance: currentMonthData) do {
try DataStore.shared.monthData.addOrUpdate(instance: currentMonthData)
} catch {
Logger.error(error)
}
} }
} }
} }

@ -281,9 +281,17 @@ class Round: ModelObject, Storable {
_matches.forEach { match in _matches.forEach { match in
match.disabled = disable match.disabled = disable
match.resetMatch() match.resetMatch()
try? DataStore.shared.teamScores.delete(contentOfs: match.teamScores) do {
try DataStore.shared.teamScores.delete(contentOfs: match.teamScores)
} catch {
Logger.error(error)
}
}
do {
try DataStore.shared.matches.addOrUpdate(contentOfs: _matches)
} catch {
Logger.error(error)
} }
try? DataStore.shared.matches.addOrUpdate(contentOfs: _matches)
} }
var cumulativeMatchCount: Int { var cumulativeMatchCount: Int {
@ -425,7 +433,11 @@ class Round: ModelObject, Storable {
return round return round
} }
try? DataStore.shared.rounds.addOrUpdate(contentOfs: rounds) do {
try DataStore.shared.rounds.addOrUpdate(contentOfs: rounds)
} catch {
Logger.error(error)
}
let matchCount = RoundRule.numberOfMatches(forTeams: currentRoundMatchCount) let matchCount = RoundRule.numberOfMatches(forTeams: currentRoundMatchCount)
let matches = (0..<matchCount).map { //0 is final match let matches = (0..<matchCount).map { //0 is final match
@ -434,7 +446,11 @@ class Round: ModelObject, Storable {
return Match(round: round.id, index: $0, matchFormat: loserBracketMatchFormat, name: round.roundTitle()) return Match(round: round.id, index: $0, matchFormat: loserBracketMatchFormat, name: round.roundTitle())
} }
try? DataStore.shared.matches.addOrUpdate(contentOfs: matches) do {
try DataStore.shared.matches.addOrUpdate(contentOfs: matches)
} catch {
Logger.error(error)
}
loserRounds().forEach { round in loserRounds().forEach { round in
round.buildLoserBracket() round.buildLoserBracket()

@ -216,7 +216,11 @@ class TeamRegistration: ModelObject, Storable {
func updatePlayers(_ players: Set<PlayerRegistration>, inTournamentCategory tournamentCategory: TournamentCategory) { func updatePlayers(_ players: Set<PlayerRegistration>, inTournamentCategory tournamentCategory: TournamentCategory) {
try? DataStore.shared.playerRegistrations.delete(contentOfs: unsortedPlayers()) do {
try DataStore.shared.playerRegistrations.delete(contentOfs: unsortedPlayers())
} catch {
Logger.error(error)
}
setWeight(from: Array(players), inTournamentCategory: tournamentCategory) setWeight(from: Array(players), inTournamentCategory: tournamentCategory)
players.forEach { player in players.forEach { player in

@ -886,8 +886,16 @@ class Tournament : ModelObject, Storable {
} }
} }
try? DataStore.shared.teamRegistrations.addOrUpdate(contentOfs: teamsToImport) do {
try? DataStore.shared.playerRegistrations.addOrUpdate(contentOfs: teams.flatMap { $0.players }) try DataStore.shared.teamRegistrations.addOrUpdate(contentOfs: teamsToImport)
} catch {
Logger.error(error)
}
do {
try DataStore.shared.playerRegistrations.addOrUpdate(contentOfs: teams.flatMap { $0.players })
} catch {
Logger.error(error)
}
} }
@ -998,7 +1006,11 @@ class Tournament : ModelObject, Storable {
teams.forEach { team in teams.forEach { team in
team.lockedWeight = team.weight team.lockedWeight = team.weight
} }
try? DataStore.shared.teamRegistrations.addOrUpdate(contentOfs: teams) do {
try DataStore.shared.teamRegistrations.addOrUpdate(contentOfs: teams)
} catch {
Logger.error(error)
}
} }
func updateWeights() { func updateWeights() {
@ -1007,9 +1019,17 @@ class Tournament : ModelObject, Storable {
let players = team.unsortedPlayers() let players = team.unsortedPlayers()
players.forEach { $0.setComputedRank(in: self) } players.forEach { $0.setComputedRank(in: self) }
team.setWeight(from: players, inTournamentCategory: tournamentCategory) team.setWeight(from: players, inTournamentCategory: tournamentCategory)
try? DataStore.shared.playerRegistrations.addOrUpdate(contentOfs: players) do {
try DataStore.shared.playerRegistrations.addOrUpdate(contentOfs: players)
} catch {
Logger.error(error)
}
}
do {
try DataStore.shared.teamRegistrations.addOrUpdate(contentOfs: teams)
} catch {
Logger.error(error)
} }
try? DataStore.shared.teamRegistrations.addOrUpdate(contentOfs: teams)
} }
func updateRank(to newDate: Date?) async throws { func updateRank(to newDate: Date?) async throws {
@ -1023,7 +1043,11 @@ class Tournament : ModelObject, Storable {
let monthData = MonthData(monthKey: URL.importDateFormatter.string(from: newDate)) let monthData = MonthData(monthKey: URL.importDateFormatter.string(from: newDate))
monthData.maleUnrankedValue = lastRankMan monthData.maleUnrankedValue = lastRankMan
monthData.femaleUnrankedValue = lastRankWoman monthData.femaleUnrankedValue = lastRankWoman
try? DataStore.shared.monthData.addOrUpdate(instance: monthData) do {
try DataStore.shared.monthData.addOrUpdate(instance: monthData)
} catch {
Logger.error(error)
}
} }
} }
@ -1232,7 +1256,11 @@ class Tournament : ModelObject, Storable {
_groupStages.append(groupStage) _groupStages.append(groupStage)
} }
try? DataStore.shared.groupStages.addOrUpdate(contentOfs: _groupStages) do {
try DataStore.shared.groupStages.addOrUpdate(contentOfs: _groupStages)
} catch {
Logger.error(error)
}
refreshGroupStages() refreshGroupStages()
} }
@ -1250,7 +1278,11 @@ class Tournament : ModelObject, Storable {
Round(tournament: id, index: $0) Round(tournament: id, index: $0)
} }
try? DataStore.shared.rounds.addOrUpdate(contentOfs: rounds) do {
try DataStore.shared.rounds.addOrUpdate(contentOfs: rounds)
} catch {
Logger.error(error)
}
let matchCount = RoundRule.numberOfMatches(forTeams: bracketTeamCount()) let matchCount = RoundRule.numberOfMatches(forTeams: bracketTeamCount())
let matches = (0..<matchCount).map { //0 is final match let matches = (0..<matchCount).map { //0 is final match
@ -1263,7 +1295,11 @@ class Tournament : ModelObject, Storable {
(RoundRule.roundName(fromMatchIndex: $0.index), RoundRule.matchIndexWithinRound(fromMatchIndex: $0.index)) (RoundRule.roundName(fromMatchIndex: $0.index), RoundRule.matchIndexWithinRound(fromMatchIndex: $0.index))
}) })
try? DataStore.shared.matches.addOrUpdate(contentOfs: matches) do {
try DataStore.shared.matches.addOrUpdate(contentOfs: matches)
} catch {
Logger.error(error)
}
self.rounds().forEach { round in self.rounds().forEach { round in
round.buildLoserBracket() round.buildLoserBracket()
@ -1364,7 +1400,11 @@ class Tournament : ModelObject, Storable {
chunks[index][jIndex].groupStage = groupStages[jIndex].id chunks[index][jIndex].groupStage = groupStages[jIndex].id
chunks[index][jIndex].groupStagePosition = index chunks[index][jIndex].groupStagePosition = index
try? DataStore.shared.teamRegistrations.addOrUpdate(instance: chunks[index][jIndex]) do {
try DataStore.shared.teamRegistrations.addOrUpdate(instance: chunks[index][jIndex])
} catch {
Logger.error(error)
}
} }
} }

@ -58,7 +58,11 @@ struct CallSettingsView: View {
teams.forEach { team in teams.forEach { team in
team.callDate = nil team.callDate = nil
} }
try? dataStore.teamRegistrations.addOrUpdate(contentOfs: teams) do {
try dataStore.teamRegistrations.addOrUpdate(contentOfs: teams)
} catch {
Logger.error(error)
}
} }
} }
@ -68,7 +72,11 @@ struct CallSettingsView: View {
teams.forEach { team in teams.forEach { team in
team.callDate = team.expectedSummonDate() team.callDate = team.expectedSummonDate()
} }
try? dataStore.teamRegistrations.addOrUpdate(contentOfs: teams) do {
try dataStore.teamRegistrations.addOrUpdate(contentOfs: teams)
} catch {
Logger.error(error)
}
} }
} }
#endif #endif

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct CallView: View { struct CallView: View {
@ -76,7 +77,11 @@ struct CallView: View {
teams.forEach { team in teams.forEach { team in
team.callDate = callDate team.callDate = callDate
} }
try? dataStore.teamRegistrations.addOrUpdate(contentOfs: teams) do {
try dataStore.teamRegistrations.addOrUpdate(contentOfs: teams)
} catch {
Logger.error(error)
}
} }
} }

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct CashierSettingsView: View { struct CashierSettingsView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@ -29,7 +30,11 @@ struct CashierSettingsView: View {
player.paymentType = .gift player.paymentType = .gift
} }
} }
try? dataStore.playerRegistrations.addOrUpdate(contentOfs: players) do {
try dataStore.playerRegistrations.addOrUpdate(contentOfs: players)
} catch {
Logger.error(error)
}
} }
} footer: { } footer: {
Text("Passe tous les joueurs qui n'ont pas réglé en offert") Text("Passe tous les joueurs qui n'ont pas réglé en offert")
@ -41,7 +46,11 @@ struct CashierSettingsView: View {
players.forEach { player in players.forEach { player in
player.paymentType = nil player.paymentType = nil
} }
try? dataStore.playerRegistrations.addOrUpdate(contentOfs: players) do {
try dataStore.playerRegistrations.addOrUpdate(contentOfs: players)
} catch {
Logger.error(error)
}
} }
} footer: { } footer: {
Text("Remet à zéro le type d'encaissement de tous les joueurs") Text("Remet à zéro le type d'encaissement de tous les joueurs")

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct CourtView: View { struct CourtView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@ -31,7 +32,11 @@ struct CourtView: View {
if name.isEmpty { if name.isEmpty {
court.name = nil court.name = nil
} }
try? dataStore.courts.addOrUpdate(instance: court) do {
try dataStore.courts.addOrUpdate(instance: court)
} catch {
Logger.error(error)
}
} }
} label: { } label: {
Text("Nom du terrain") Text("Nom du terrain")
@ -41,7 +46,11 @@ struct CourtView: View {
FooterButtonView("nom par défaut") { FooterButtonView("nom par défaut") {
name = "" name = ""
court.name = nil court.name = nil
try? dataStore.courts.addOrUpdate(instance: court) do {
try dataStore.courts.addOrUpdate(instance: court)
} catch {
Logger.error(error)
}
} }
} }
} }
@ -56,7 +65,11 @@ struct CourtView: View {
} }
} }
.onChange(of: [court.indoor, court.exitAllowed]) { .onChange(of: [court.indoor, court.exitAllowed]) {
try? dataStore.courts.addOrUpdate(instance: court) do {
try dataStore.courts.addOrUpdate(instance: court)
} catch {
Logger.error(error)
}
} }
.navigationTitle(court.courtTitle()) .navigationTitle(court.courtTitle())
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct GroupStageTeamView: View { struct GroupStageTeamView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@ -83,7 +84,11 @@ struct GroupStageTeamView: View {
} }
private func _save() { private func _save() {
try? dataStore.teamRegistrations.addOrUpdate(instance: team) do {
try dataStore.teamRegistrations.addOrUpdate(instance: team)
} catch {
Logger.error(error)
}
dismiss() dismiss()
} }
} }

@ -82,7 +82,11 @@ struct GroupStageSettingsView: View {
groupStage.name = nil groupStage.name = nil
} }
} }
try? dataStore.groupStages.addOrUpdate(contentOfs: groupStages) do {
try dataStore.groupStages.addOrUpdate(contentOfs: groupStages)
} catch {
Logger.error(error)
}
} }
} }

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct MatchDetailView: View { struct MatchDetailView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@ -447,7 +448,11 @@ struct MatchDetailView: View {
private func save() { private func save() {
try? dataStore.matches.addOrUpdate(instance: match) do {
try dataStore.matches.addOrUpdate(instance: match)
} catch {
Logger.error(error)
}
} }
} }

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct MatchSetupView: View { struct MatchSetupView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@ -36,11 +37,23 @@ struct MatchSetupView: View {
team.bracketPosition = nil team.bracketPosition = nil
match.updateTeamScores() match.updateTeamScores()
match.enableMatch() match.enableMatch()
try? dataStore.matches.addOrUpdate(instance: match) do {
try? dataStore.teamRegistrations.addOrUpdate(instance: team) try dataStore.matches.addOrUpdate(instance: match)
} catch {
Logger.error(error)
}
do {
try dataStore.teamRegistrations.addOrUpdate(instance: team)
} catch {
Logger.error(error)
}
} else { } else {
match.teamWillBeWalkOut(team) match.teamWillBeWalkOut(team)
try? dataStore.matches.addOrUpdate(instance: match) do {
try dataStore.matches.addOrUpdate(instance: match)
} catch {
Logger.error(error)
}
} }
} label: { } label: {
Label("retirer", systemImage: "xmark") Label("retirer", systemImage: "xmark")
@ -60,11 +73,23 @@ struct MatchSetupView: View {
print(team.pasteData()) print(team.pasteData())
if walkOutSpot { if walkOutSpot {
match.setLuckyLoser(team: team, teamPosition: teamPosition) match.setLuckyLoser(team: team, teamPosition: teamPosition)
try? dataStore.matches.addOrUpdate(instance: match) do {
try dataStore.matches.addOrUpdate(instance: match)
} catch {
Logger.error(error)
}
} else { } else {
team.setSeedPosition(inSpot: match, slot: teamPosition, opposingSeeding: false) team.setSeedPosition(inSpot: match, slot: teamPosition, opposingSeeding: false)
try? dataStore.matches.addOrUpdate(instance: match) do {
try? dataStore.teamRegistrations.addOrUpdate(instance: team) try dataStore.matches.addOrUpdate(instance: match)
} catch {
Logger.error(error)
}
do {
try dataStore.teamRegistrations.addOrUpdate(instance: team)
} catch {
Logger.error(error)
}
} }
}) })
if let tournament = match.currentTournament() { if let tournament = match.currentTournament() {
@ -75,7 +100,11 @@ struct MatchSetupView: View {
Button { Button {
if let randomTeam = luckyLosers.randomElement() { if let randomTeam = luckyLosers.randomElement() {
match.setLuckyLoser(team: randomTeam, teamPosition: teamPosition) match.setLuckyLoser(team: randomTeam, teamPosition: teamPosition)
try? dataStore.matches.addOrUpdate(instance: match) do {
try dataStore.matches.addOrUpdate(instance: match)
} catch {
Logger.error(error)
}
} }
} label: { } label: {
Label("Repêchage", systemImage: "dice") Label("Repêchage", systemImage: "dice")
@ -85,8 +114,16 @@ struct MatchSetupView: View {
Button { Button {
if let randomTeam = tournament.randomSeed(fromSeedGroup: seedGroup) { if let randomTeam = tournament.randomSeed(fromSeedGroup: seedGroup) {
randomTeam.setSeedPosition(inSpot: match, slot: teamPosition, opposingSeeding: false) randomTeam.setSeedPosition(inSpot: match, slot: teamPosition, opposingSeeding: false)
try? dataStore.matches.addOrUpdate(instance: match) do {
try? dataStore.teamRegistrations.addOrUpdate(instance: randomTeam) try dataStore.matches.addOrUpdate(instance: match)
} catch {
Logger.error(error)
}
do {
try dataStore.teamRegistrations.addOrUpdate(instance: randomTeam)
} catch {
Logger.error(error)
}
} }
} label: { } label: {
Label(seedGroup.localizedLabel(), systemImage: "dice") Label(seedGroup.localizedLabel(), systemImage: "dice")
@ -101,7 +138,11 @@ struct MatchSetupView: View {
if match.isSeedLocked(atTeamPosition: teamPosition) { if match.isSeedLocked(atTeamPosition: teamPosition) {
Button { Button {
match.unlockSeedPosition(atTeamPosition: teamPosition) match.unlockSeedPosition(atTeamPosition: teamPosition)
try? dataStore.matches.addOrUpdate(instance: match) do {
try dataStore.matches.addOrUpdate(instance: match)
} catch {
Logger.error(error)
}
} label: { } label: {
Text("Libérer") Text("Libérer")
.underline() .underline()
@ -109,7 +150,11 @@ struct MatchSetupView: View {
} else { } else {
Button { Button {
_ = match.lockAndGetSeedPosition(atTeamPosition: teamPosition) _ = match.lockAndGetSeedPosition(atTeamPosition: teamPosition)
try? dataStore.matches.addOrUpdate(instance: match) do {
try dataStore.matches.addOrUpdate(instance: match)
} catch {
Logger.error(error)
}
} label: { } label: {
Text("Réserver") Text("Réserver")
.underline() .underline()

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct CalendarView: View { struct CalendarView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@ -164,7 +165,11 @@ struct CalendarView: View {
newTournament.dayDuration = federalTournament.dayDuration newTournament.dayDuration = federalTournament.dayDuration
newTournament.startDate = federalTournament.startDate.atBeginningOfDay(hourInt: 9) newTournament.startDate = federalTournament.startDate.atBeginningOfDay(hourInt: 9)
newTournament.setupFederalSettings() newTournament.setupFederalSettings()
try? dataStore.tournaments.addOrUpdate(instance: newTournament) do {
try dataStore.tournaments.addOrUpdate(instance: newTournament)
} catch {
Logger.error(error)
}
navigation.path.append(newTournament) navigation.path.append(newTournament)
} }
} }

@ -17,21 +17,21 @@ struct ToolboxView: View {
NavigationStack(path: $navigation.toolboxPath) { NavigationStack(path: $navigation.toolboxPath) {
List { List {
#if DEBUG #if DEBUG
// Section { Section {
// RowButtonView("Reset ALL API Calls") { RowButtonView("Reset ALL API Calls") {
// dataStore.courts.resetApiCalls() dataStore.courts.resetApiCalls()
// dataStore.matches.resetApiCalls() dataStore.matches.resetApiCalls()
// dataStore.tournaments.resetApiCalls() dataStore.tournaments.resetApiCalls()
// dataStore.teamRegistrations.resetApiCalls() dataStore.teamRegistrations.resetApiCalls()
// dataStore.playerRegistrations.resetApiCalls() dataStore.playerRegistrations.resetApiCalls()
// dataStore.teamScores.resetApiCalls() dataStore.teamScores.resetApiCalls()
// dataStore.rounds.resetApiCalls() dataStore.rounds.resetApiCalls()
// dataStore.groupStages.resetApiCalls() dataStore.groupStages.resetApiCalls()
// dataStore.clubs.resetApiCalls() dataStore.clubs.resetApiCalls()
// dataStore.events.resetApiCalls() dataStore.events.resetApiCalls()
// dataStore.dateIntervals.resetApiCalls() dataStore.dateIntervals.resetApiCalls()
// } }
// } }
Section { Section {
RowButtonView("Fix Names") { RowButtonView("Fix Names") {
let playerRegistrations = dataStore.playerRegistrations let playerRegistrations = dataStore.playerRegistrations

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct CourtAvailabilitySettingsView: View { struct CourtAvailabilitySettingsView: View {
@Environment(Tournament.self) var tournament: Tournament @Environment(Tournament.self) var tournament: Tournament
@ -36,7 +37,11 @@ struct CourtAvailabilitySettingsView: View {
Menu { Menu {
Button("dupliquer") { Button("dupliquer") {
let duplicatedDateInterval = DateInterval(event: event.id, courtIndex: (courtIndex+1)%tournament.courtCount, startDate: dateInterval.startDate, endDate: dateInterval.endDate) let duplicatedDateInterval = DateInterval(event: event.id, courtIndex: (courtIndex+1)%tournament.courtCount, startDate: dateInterval.startDate, endDate: dateInterval.endDate)
try? dataStore.dateIntervals.addOrUpdate(instance: duplicatedDateInterval) do {
try dataStore.dateIntervals.addOrUpdate(instance: duplicatedDateInterval)
} catch {
Logger.error(error)
}
} }
Button("éditer") { Button("éditer") {
editingSlot = dateInterval editingSlot = dateInterval
@ -46,7 +51,11 @@ struct CourtAvailabilitySettingsView: View {
showingPopover = true showingPopover = true
} }
Button("effacer", role: .destructive) { Button("effacer", role: .destructive) {
try? dataStore.dateIntervals.delete(instance: dateInterval) do {
try dataStore.dateIntervals.delete(instance: dateInterval)
} catch {
Logger.error(error)
}
} }
} label: { } label: {
HStack { HStack {
@ -69,7 +78,11 @@ struct CourtAvailabilitySettingsView: View {
} }
.swipeActions { .swipeActions {
Button(role: .destructive) { Button(role: .destructive) {
try? dataStore.dateIntervals.delete(instance: dateInterval) do {
try dataStore.dateIntervals.delete(instance: dateInterval)
} catch {
Logger.error(error)
}
} label: { } label: {
LabelDelete() LabelDelete()
} }
@ -136,12 +149,20 @@ struct CourtAvailabilitySettingsView: View {
ButtonValidateView { ButtonValidateView {
if editingSlot == nil { if editingSlot == nil {
let dateInterval = DateInterval(event: event.id, courtIndex: courtIndex, startDate: startDate, endDate: endDate) let dateInterval = DateInterval(event: event.id, courtIndex: courtIndex, startDate: startDate, endDate: endDate)
try? dataStore.dateIntervals.addOrUpdate(instance: dateInterval) do {
try dataStore.dateIntervals.addOrUpdate(instance: dateInterval)
} catch {
Logger.error(error)
}
} else { } else {
editingSlot?.courtIndex = courtIndex editingSlot?.courtIndex = courtIndex
editingSlot?.endDate = endDate editingSlot?.endDate = endDate
editingSlot?.startDate = startDate editingSlot?.startDate = startDate
try? dataStore.dateIntervals.addOrUpdate(instance: editingSlot!) do {
try dataStore.dateIntervals.addOrUpdate(instance: editingSlot!)
} catch {
Logger.error(error)
}
} }
showingPopover = false showingPopover = false
} }

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct GroupStageScheduleEditorView: View { struct GroupStageScheduleEditorView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@ -27,7 +28,11 @@ struct GroupStageScheduleEditorView: View {
} }
private func _save() { private func _save() {
try? dataStore.groupStages.addOrUpdate(instance: groupStage) do {
try dataStore.groupStages.addOrUpdate(instance: groupStage)
} catch {
Logger.error(error)
}
} }
} }

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct LoserRoundScheduleEditorView: View { struct LoserRoundScheduleEditorView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@ -72,7 +73,11 @@ struct LoserRoundScheduleEditorView: View {
} }
private func _save() { private func _save() {
try? dataStore.rounds.addOrUpdate(contentOfs: upperRound.loserRounds()) do {
try dataStore.rounds.addOrUpdate(contentOfs: upperRound.loserRounds())
} catch {
Logger.error(error)
}
} }
} }

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct LoserRoundStepScheduleEditorView: View { struct LoserRoundStepScheduleEditorView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@ -67,6 +68,10 @@ struct LoserRoundStepScheduleEditorView: View {
} }
private func _save() { private func _save() {
try? dataStore.rounds.addOrUpdate(contentOfs: upperRound.loserRounds(forRoundIndex: round.index)) do {
try dataStore.rounds.addOrUpdate(contentOfs: upperRound.loserRounds(forRoundIndex: round.index))
} catch {
Logger.error(error)
}
} }
} }

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct RoundScheduleEditorView: View { struct RoundScheduleEditorView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@ -60,7 +61,11 @@ struct RoundScheduleEditorView: View {
} }
private func _save() { private func _save() {
try? dataStore.rounds.addOrUpdate(instance: round) do {
try dataStore.rounds.addOrUpdate(instance: round)
} catch {
Logger.error(error)
}
} }
} }

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct EditablePlayerView: View { struct EditablePlayerView: View {
@ -30,19 +31,31 @@ struct EditablePlayerView: View {
.onSubmit { .onSubmit {
player.licenceId = editedLicenceId player.licenceId = editedLicenceId
editedLicenceId = "" editedLicenceId = ""
try? dataStore.playerRegistrations.addOrUpdate(instance: player) do {
try dataStore.playerRegistrations.addOrUpdate(instance: player)
} catch {
Logger.error(error)
}
} }
} }
.alert("Prénom", isPresented: $presentFirstNameUpdate) { .alert("Prénom", isPresented: $presentFirstNameUpdate) {
TextField("Prénom", text: $player.firstName) TextField("Prénom", text: $player.firstName)
.onSubmit { .onSubmit {
try? dataStore.playerRegistrations.addOrUpdate(instance: player) do {
try dataStore.playerRegistrations.addOrUpdate(instance: player)
} catch {
Logger.error(error)
}
} }
} }
.alert("Nom", isPresented: $presentLastNameUpdate) { .alert("Nom", isPresented: $presentLastNameUpdate) {
TextField("Nom", text: $player.lastName) TextField("Nom", text: $player.lastName)
.onSubmit { .onSubmit {
try? dataStore.playerRegistrations.addOrUpdate(instance: player) do {
try dataStore.playerRegistrations.addOrUpdate(instance: player)
} catch {
Logger.error(error)
}
} }
} }
@ -61,7 +74,11 @@ struct EditablePlayerView: View {
Menu { Menu {
Button { Button {
player.hasArrived.toggle() player.hasArrived.toggle()
try? dataStore.playerRegistrations.addOrUpdate(instance: player) do {
try dataStore.playerRegistrations.addOrUpdate(instance: player)
} catch {
Logger.error(error)
}
} label: { } label: {
Label("Présent", systemImage: player.hasArrived ? "checkmark.circle" : "circle") Label("Présent", systemImage: player.hasArrived ? "checkmark.circle" : "circle")
} }

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct PlayerPayView: View { struct PlayerPayView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@ -27,6 +28,10 @@ struct PlayerPayView: View {
} }
private func _save() { private func _save() {
try? dataStore.playerRegistrations.addOrUpdate(instance: player) do {
try dataStore.playerRegistrations.addOrUpdate(instance: player)
} catch {
Logger.error(error)
}
} }
} }

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct PlayerDetailView: View { struct PlayerDetailView: View {
@Environment(Tournament.self) var tournament: Tournament @Environment(Tournament.self) var tournament: Tournament
@ -106,9 +107,17 @@ struct PlayerDetailView: View {
} }
private func _save() { private func _save() {
try? dataStore.playerRegistrations.addOrUpdate(instance: player) do {
try dataStore.playerRegistrations.addOrUpdate(instance: player)
} catch {
Logger.error(error)
}
if let team = player.team() { if let team = player.team() {
try? dataStore.teamRegistrations.addOrUpdate(instance: team) do {
try dataStore.teamRegistrations.addOrUpdate(instance: team)
} catch {
Logger.error(error)
}
} }
} }
} }

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct PlayerView: View { struct PlayerView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@ -15,7 +16,11 @@ struct PlayerView: View {
ImportedPlayerView(player: player) ImportedPlayerView(player: player)
.swipeActions(edge: .trailing, allowsFullSwipe: true) { .swipeActions(edge: .trailing, allowsFullSwipe: true) {
Button(role: .destructive) { Button(role: .destructive) {
try? dataStore.playerRegistrations.delete(instance: player) do {
try dataStore.playerRegistrations.delete(instance: player)
} catch {
Logger.error(error)
}
} label: { } label: {
LabelDelete() LabelDelete()
} }

@ -46,7 +46,11 @@ struct RoundSettingsView: View {
tournament.resetTeamScores(in: team.bracketPosition) tournament.resetTeamScores(in: team.bracketPosition)
team.bracketPosition = nil team.bracketPosition = nil
}) })
try? dataStore.teamRegistrations.addOrUpdate(contentOfs: tournament.unsortedTeams()) do {
try dataStore.teamRegistrations.addOrUpdate(contentOfs: tournament.unsortedTeams())
} catch {
Logger.error(error)
}
tournament.allRounds().forEach({ round in tournament.allRounds().forEach({ round in
round.enableRound() round.enableRound()
}) })
@ -63,8 +67,16 @@ struct RoundSettingsView: View {
let matches = (0..<matchCount).map { //0 is final match let matches = (0..<matchCount).map { //0 is final match
return Match(round: round.id, index: $0 + matchStartIndex, matchFormat: round.matchFormat, name: Match.setServerTitle(upperRound: round, matchIndex: $0)) return Match(round: round.id, index: $0 + matchStartIndex, matchFormat: round.matchFormat, name: Match.setServerTitle(upperRound: round, matchIndex: $0))
} }
try? dataStore.rounds.addOrUpdate(instance: round) do {
try? dataStore.matches.addOrUpdate(contentOfs: matches) try dataStore.rounds.addOrUpdate(instance: round)
} catch {
Logger.error(error)
}
do {
try dataStore.matches.addOrUpdate(contentOfs: matches)
} catch {
Logger.error(error)
}
round.buildLoserBracket() round.buildLoserBracket()
} }
} }
@ -72,7 +84,11 @@ struct RoundSettingsView: View {
Section { Section {
if let lastRound = tournament.rounds().first { // first is final, last round if let lastRound = tournament.rounds().first { // first is final, last round
RowButtonView("Supprimer " + lastRound.roundTitle(), role: .destructive) { RowButtonView("Supprimer " + lastRound.roundTitle(), role: .destructive) {
try? dataStore.rounds.delete(instance: lastRound) do {
try dataStore.rounds.delete(instance: lastRound)
} catch {
Logger.error(error)
}
} }
} }
} }

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct RoundView: View { struct RoundView: View {
@Environment(\.isEditingTournamentSeed) private var isEditingTournamentSeed @Environment(\.isEditingTournamentSeed) private var isEditingTournamentSeed
@ -132,7 +133,11 @@ struct RoundView: View {
} }
private func _save() { private func _save() {
try? dataStore.teamRegistrations.addOrUpdate(contentOfs: tournament.unsortedTeams()) do {
try dataStore.teamRegistrations.addOrUpdate(contentOfs: tournament.unsortedTeams())
} catch {
Logger.error(error)
}
//todo should be done server side //todo should be done server side
let rounds = tournament.rounds() let rounds = tournament.rounds()
@ -143,7 +148,11 @@ struct RoundView: View {
} }
} }
let allRoundMatches = tournament.allRoundMatches() let allRoundMatches = tournament.allRoundMatches()
try? DataStore.shared.matches.addOrUpdate(contentOfs: allRoundMatches) do {
try DataStore.shared.matches.addOrUpdate(contentOfs: allRoundMatches)
} catch {
Logger.error(error)
}
} }
} }

@ -6,6 +6,7 @@
// //
import SwiftUI import SwiftUI
import LeStorage
struct EditingTeamView: View { struct EditingTeamView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@ -36,7 +37,11 @@ struct EditingTeamView: View {
} }
private func _save() { private func _save() {
try? dataStore.teamRegistrations.addOrUpdate(instance: team) do {
try dataStore.teamRegistrations.addOrUpdate(instance: team)
} catch {
Logger.error(error)
}
} }
} }

@ -233,7 +233,11 @@ struct FileImportView: View {
team.walkOut = true team.walkOut = true
} }
try? dataStore.teamRegistrations.addOrUpdate(contentOfs: unfound) do {
try dataStore.teamRegistrations.addOrUpdate(contentOfs: unfound)
} catch {
Logger.error(error)
}
} }

@ -91,8 +91,16 @@ struct TournamentMatchFormatsSettingsView: View {
round.updateMatchFormatAndAllMatches(tournament.matchFormat) round.updateMatchFormatAndAllMatches(tournament.matchFormat)
} }
} }
try? dataStore.groupStages.addOrUpdate(contentOfs: groupStages) do {
try? dataStore.rounds.addOrUpdate(contentOfs: allRounds) try dataStore.groupStages.addOrUpdate(contentOfs: groupStages)
} catch {
Logger.error(error)
}
do {
try dataStore.rounds.addOrUpdate(contentOfs: allRounds)
} catch {
Logger.error(error)
}
confirmUpdate = false confirmUpdate = false
updateCompleted = true updateCompleted = true

@ -744,8 +744,16 @@ struct InscriptionManagerView: View {
private func _createTeam() { private func _createTeam() {
let players = _currentSelection() let players = _currentSelection()
let team = tournament.addTeam(players) let team = tournament.addTeam(players)
try? dataStore.teamRegistrations.addOrUpdate(instance: team) do {
try? dataStore.playerRegistrations.addOrUpdate(contentOfs: players) try dataStore.teamRegistrations.addOrUpdate(instance: team)
} catch {
Logger.error(error)
}
do {
try dataStore.playerRegistrations.addOrUpdate(contentOfs: players)
} catch {
Logger.error(error)
}
createdPlayers.removeAll() createdPlayers.removeAll()
createdPlayerIds.removeAll() createdPlayerIds.removeAll()
@ -756,8 +764,16 @@ struct InscriptionManagerView: View {
guard let editedTeam else { return } guard let editedTeam else { return }
let players = _currentSelection() let players = _currentSelection()
editedTeam.updatePlayers(players, inTournamentCategory: tournament.tournamentCategory) editedTeam.updatePlayers(players, inTournamentCategory: tournament.tournamentCategory)
try? dataStore.teamRegistrations.addOrUpdate(instance: editedTeam) do {
try? dataStore.playerRegistrations.addOrUpdate(contentOfs: players) try dataStore.teamRegistrations.addOrUpdate(instance: editedTeam)
} catch {
Logger.error(error)
}
do {
try dataStore.playerRegistrations.addOrUpdate(contentOfs: players)
} catch {
Logger.error(error)
}
createdPlayers.removeAll() createdPlayers.removeAll()
createdPlayerIds.removeAll() createdPlayerIds.removeAll()
pasteString = nil pasteString = nil
@ -968,7 +984,11 @@ struct InscriptionManagerView: View {
team.wildCardGroupStage = false team.wildCardGroupStage = false
team.walkOut = false team.walkOut = false
team.wildCardBracket = value team.wildCardBracket = value
try? dataStore.teamRegistrations.addOrUpdate(instance: team) do {
try dataStore.teamRegistrations.addOrUpdate(instance: team)
} catch {
Logger.error(error)
}
})) { })) {
Label("Wildcard Tableau", systemImage: team.wildCardBracket ? "circle.inset.filled" : "circle") Label("Wildcard Tableau", systemImage: team.wildCardBracket ? "circle.inset.filled" : "circle")
} }
@ -980,7 +1000,11 @@ struct InscriptionManagerView: View {
team.wildCardBracket = false team.wildCardBracket = false
team.walkOut = false team.walkOut = false
team.wildCardGroupStage = value team.wildCardGroupStage = value
try? dataStore.teamRegistrations.addOrUpdate(instance: team) do {
try dataStore.teamRegistrations.addOrUpdate(instance: team)
} catch {
Logger.error(error)
}
})) { })) {
Label("Wildcard Poule", systemImage: team.wildCardGroupStage ? "circle.inset.filled" : "circle") Label("Wildcard Poule", systemImage: team.wildCardGroupStage ? "circle.inset.filled" : "circle")
} }
@ -993,13 +1017,21 @@ struct InscriptionManagerView: View {
team.wildCardBracket = false team.wildCardBracket = false
team.wildCardGroupStage = false team.wildCardGroupStage = false
team.walkOut = value team.walkOut = value
try? dataStore.teamRegistrations.addOrUpdate(instance: team) do {
try dataStore.teamRegistrations.addOrUpdate(instance: team)
} catch {
Logger.error(error)
}
})) { })) {
Label("WO", systemImage: team.walkOut ? "circle.inset.filled" : "circle") Label("WO", systemImage: team.walkOut ? "circle.inset.filled" : "circle")
} }
Divider() Divider()
Button(role: .destructive) { Button(role: .destructive) {
try? dataStore.teamRegistrations.delete(instance: team) do {
try dataStore.teamRegistrations.delete(instance: team)
} catch {
Logger.error(error)
}
} label: { } label: {
LabelDelete() LabelDelete()
} }

Loading…
Cancel
Save