diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index f7a6da1..54cac3d 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -1067,6 +1067,11 @@ defer { registrationDate = previousTeamRegistrationDate } let newTeam = addTeam(team.players, registrationDate: registrationDate, name: team.name) + if isAnimation() { + if newTeam.weight == 0 { + newTeam.weight = team.index(in: teams) ?? 0 + } + } teamsToImport.append(newTeam) } } @@ -1795,6 +1800,11 @@ defer { players.forEach { player in player.teamRegistration = team.id } + if isAnimation() { + if team.weight == 0 { + team.weight = unsortedTeams().count + } + } return team } @@ -1910,9 +1920,9 @@ defer { private func _defaultSorting() -> [MySortDescriptor] { switch teamSorting { case .rank: - [.keyPath(\TeamRegistration.initialWeight), .keyPath(\TeamRegistration.registrationDate!)] + [.keyPath(\TeamRegistration.initialWeight), .keyPath(\TeamRegistration.registrationDate!), .keyPath(\TeamRegistration.id)] case .inscriptionDate: - [.keyPath(\TeamRegistration.registrationDate!), .keyPath(\TeamRegistration.initialWeight)] + [.keyPath(\TeamRegistration.registrationDate!), .keyPath(\TeamRegistration.initialWeight), .keyPath(\TeamRegistration.id)] } } @@ -1922,7 +1932,7 @@ defer { && federalTournamentAge == build.age } - private let _currentSelectionSorting : [MySortDescriptor] = [.keyPath(\.weight), .keyPath(\.registrationDate!)] + private let _currentSelectionSorting : [MySortDescriptor] = [.keyPath(\.weight), .keyPath(\.registrationDate!), .keyPath(\.id)] private func _matchSchedulers() -> [MatchScheduler] { return self.tournamentStore.matchSchedulers.filter { $0.tournament == self.id } diff --git a/PadelClub/Utils/FileImportManager.swift b/PadelClub/Utils/FileImportManager.swift index 6e553ef..f61f0dd 100644 --- a/PadelClub/Utils/FileImportManager.swift +++ b/PadelClub/Utils/FileImportManager.swift @@ -462,6 +462,8 @@ class FileImportManager { let player = PlayerRegistration(firstName: firstName, lastName: lastName, licenceId: licenceId, rank: rank, sex: sex, clubName: club, phoneNumber: phoneNumber, email: email) if rank == nil, autoSearch { player.setComputedRank(in: tournament) + } else { + player.computedRank = rank ?? 0 } return player } diff --git a/PadelClub/Views/Tournament/Screen/AddTeamView.swift b/PadelClub/Views/Tournament/Screen/AddTeamView.swift index 005d7e1..ca7ad1e 100644 --- a/PadelClub/Views/Tournament/Screen/AddTeamView.swift +++ b/PadelClub/Views/Tournament/Screen/AddTeamView.swift @@ -149,7 +149,7 @@ struct AddTeamView: View { } .toolbar { ToolbarItem(placement: .cancellationAction) { - Button("Terminer", role: .cancel) { + Button("Annuler", role: .cancel) { dismiss() } } @@ -392,8 +392,8 @@ struct AddTeamView: View { ForEach(createdPlayerIds.sorted(), id: \.self) { id in if let p = createdPlayers.first(where: { $0.id == id }) { VStack(alignment: .leading, spacing: 0) { - if let player = unsortedPlayers.first(where: { ($0.licenceId == p.licenceId && $0.licenceId != nil) }), editedTeam?.includes(player: player) == true { - Text("Déjà inscrit !").foregroundStyle(.logoRed).bold() + if let player = unsortedPlayers.first(where: { ($0.licenceId == p.licenceId && $0.licenceId != nil) }), editedTeam?.includes(player: player) == false { + Text("Déjà inscrit !!").foregroundStyle(.logoRed).bold() } PlayerView(player: p).tag(p.id) .environment(tournament) @@ -421,7 +421,7 @@ struct AddTeamView: View { } else { RowButtonView("Confirmer") { _updateTeam(checkDuplicates: false) - editedTeam = nil + dismiss() } } } header: {