From d11af504b55b261251bcd68eeef2f3047d24d9f2 Mon Sep 17 00:00:00 2001 From: Raz Date: Wed, 15 Jan 2025 15:19:31 +0100 Subject: [PATCH] fixes and add legend / inscription guide --- PadelClub/Data/TeamRegistration.swift | 11 +++++++++-- PadelClub/Views/Team/EditingTeamView.swift | 2 +- .../Screen/InscriptionManagerView.swift | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/PadelClub/Data/TeamRegistration.swift b/PadelClub/Data/TeamRegistration.swift index a24e355..cb14169 100644 --- a/PadelClub/Data/TeamRegistration.swift +++ b/PadelClub/Data/TeamRegistration.swift @@ -122,6 +122,7 @@ final class TeamRegistration: ModelObject, Storable { func isHere() -> Bool { let unsortedPlayers = unsortedPlayers() + if unsortedPlayers.isEmpty { return false } return unsortedPlayers.allSatisfy({ $0.hasArrived }) } @@ -197,7 +198,10 @@ final class TeamRegistration: ModelObject, Storable { } func isImported() -> Bool { - return unsortedPlayers().allSatisfy({ $0.isImported() }) + let unsortedPlayers = unsortedPlayers() + if unsortedPlayers.isEmpty { return false } + + return unsortedPlayers.allSatisfy({ $0.isImported() }) } func isWildCard() -> Bool { @@ -304,7 +308,10 @@ final class TeamRegistration: ModelObject, Storable { } func canPlay() -> Bool { - return matches().isEmpty == false || players().allSatisfy({ $0.hasPaid() || $0.hasArrived }) + let unsortedPlayers = unsortedPlayers() + if unsortedPlayers.isEmpty { return false } + + return matches().isEmpty == false || unsortedPlayers.allSatisfy({ $0.hasPaid() || $0.hasArrived }) } func availableForSeedPick() -> Bool { diff --git a/PadelClub/Views/Team/EditingTeamView.swift b/PadelClub/Views/Team/EditingTeamView.swift index 9c89875..60279e4 100644 --- a/PadelClub/Views/Team/EditingTeamView.swift +++ b/PadelClub/Views/Team/EditingTeamView.swift @@ -347,7 +347,7 @@ struct EditingTeamView: View { private var hasArrived: Binding { Binding { - team.unsortedPlayers().allSatisfy({ $0.hasArrived }) + team.isHere() } set: { hasArrived in team.unsortedPlayers().forEach { $0.hasArrived = hasArrived diff --git a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift index 6942db4..f4117ea 100644 --- a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift +++ b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift @@ -533,6 +533,19 @@ struct InscriptionManagerView: View { } } + private func _fixModel() { + let players = tournament.players() + + players.forEach { player in + if player.source == .onlineRegistration { + player.source = .frenchFederation + player.registeredOnline = true + } + } + + try? tournamentStore.playerRegistrations.addOrUpdate(contentOfs: players) + } + private func _refreshList() async { if refreshInProgress { return } @@ -823,6 +836,11 @@ struct InscriptionManagerView: View { if let closedRegistrationDate = tournament.closedRegistrationDate { CloseDatePicker(closedRegistrationDate: closedRegistrationDate) } + + Button("bug fix") { + _fixModel() + } + if tournament.enableOnlineRegistration { Button { Task {