|
|
|
@ -12,6 +12,7 @@ import PadelClubData |
|
|
|
|
|
|
|
|
|
|
|
struct TournamentView: View { |
|
|
|
struct TournamentView: View { |
|
|
|
@EnvironmentObject var dataStore: DataStore |
|
|
|
@EnvironmentObject var dataStore: DataStore |
|
|
|
|
|
|
|
@Environment(\.dismiss) private var dismiss |
|
|
|
|
|
|
|
|
|
|
|
@Environment(NavigationViewModel.self) var navigation: NavigationViewModel |
|
|
|
@Environment(NavigationViewModel.self) var navigation: NavigationViewModel |
|
|
|
@State var tournament: Tournament |
|
|
|
@State var tournament: Tournament |
|
|
|
@ -337,7 +338,12 @@ struct TournamentView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Button { |
|
|
|
Button { |
|
|
|
DataStore.shared.deleteTournament(self.tournament, noSync: true) |
|
|
|
self._removeUserFromSharing() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// StoreCenter.main.setAuthorizedUsers(for: <#T##T#>, users: T##[String]) |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// DataStore.shared.deleteTournament(self.tournament, noSync: true) |
|
|
|
} label: { |
|
|
|
} label: { |
|
|
|
Label("Quitter la supervision", systemImage: "person.crop.circle.badge.minus") |
|
|
|
Label("Quitter la supervision", systemImage: "person.crop.circle.badge.minus") |
|
|
|
} |
|
|
|
} |
|
|
|
@ -354,6 +360,19 @@ struct TournamentView: View { |
|
|
|
Logger.log("Tournament Id = \(self.tournament.id), Payment = \(String(describing: self.tournament.payment))") |
|
|
|
Logger.log("Tournament Id = \(self.tournament.id), Payment = \(String(describing: self.tournament.payment))") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fileprivate func _removeUserFromSharing() { |
|
|
|
|
|
|
|
guard let userId = StoreCenter.main.userId else { return } |
|
|
|
|
|
|
|
var users = StoreCenter.main.authorizedUsers(for: self.tournament.id) |
|
|
|
|
|
|
|
users.removeAll(where: { $0 == userId }) |
|
|
|
|
|
|
|
do { |
|
|
|
|
|
|
|
try StoreCenter.main.setAuthorizedUsers(for: self.tournament, users: users) |
|
|
|
|
|
|
|
DataStore.shared.deleteTournament(self.tournament, noSync: true) |
|
|
|
|
|
|
|
dismiss() |
|
|
|
|
|
|
|
} catch { |
|
|
|
|
|
|
|
Logger.error(error) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func _save() { |
|
|
|
private func _save() { |
|
|
|
dataStore.tournaments.addOrUpdate(instance: tournament) |
|
|
|
dataStore.tournaments.addOrUpdate(instance: tournament) |
|
|
|
|