fix player import stuff

sync2
Raz 10 months ago
parent 993f9193da
commit 2447930e60
  1. 24
      PadelClub/Data/TeamRegistration.swift
  2. 4
      PadelClub/Views/Team/TeamDetailView.swift

@ -433,6 +433,22 @@ final class TeamRegistration: ModelObject, Storable {
func updatePlayers(_ players: Set<PlayerRegistration>, inTournamentCategory tournamentCategory: TournamentCategory) {
let previousPlayers = Set(unsortedPlayers())
players.forEach { player in
previousPlayers.forEach { oldPlayer in
if player.licenceId?.strippedLicense == oldPlayer.licenceId?.strippedLicense, player.licenceId?.strippedLicense != nil {
player.registeredOnline = oldPlayer.registeredOnline
player.coach = oldPlayer.coach
player.tournamentPlayed = oldPlayer.tournamentPlayed
player.points = oldPlayer.points
player.captain = oldPlayer.captain
player.assimilation = oldPlayer.assimilation
player.ligueName = oldPlayer.ligueName
}
}
}
let playersToRemove = previousPlayers.subtracting(players)
do {
try self.tournamentStore.playerRegistrations.delete(contentOfs: playersToRemove)
@ -443,7 +459,13 @@ final class TeamRegistration: ModelObject, Storable {
players.forEach { player in
player.teamRegistration = id
}
}
// do {
// try self.tournamentStore.playerRegistrations.addOrUpdate(contentOfs: players)
// } catch {
// Logger.error(error)
// }
}
typealias TeamRange = (left: TeamRegistration?, right: TeamRegistration?)

@ -24,7 +24,9 @@ struct TeamDetailView: View {
} label: {
VStack(alignment: .leading, spacing: 0) {
HStack {
Text("inscrit en ligne")
if player.registeredOnline {
Text("inscrit en ligne")
}
Spacer()
Text(player.localizedSourceLabel())
}

Loading…
Cancel
Save