diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index e2a615c..4e02304 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -3145,7 +3145,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.2.48; + MARKETING_VERSION = 1.2.50; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -3191,7 +3191,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.2.48; + MARKETING_VERSION = 1.2.50; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -3376,7 +3376,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; @@ -3419,7 +3419,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; diff --git a/PadelClub/AppDelegate.swift b/PadelClub/AppDelegate.swift index 1b38c5b..2c80b46 100644 --- a/PadelClub/AppDelegate.swift +++ b/PadelClub/AppDelegate.swift @@ -55,9 +55,10 @@ class AppDelegate : NSObject, UIApplicationDelegate, UNUserNotificationCenterDel StoreCenter.main.forceNoSynchronization = !synchronized } + func applicationWillEnterForeground(_ application: UIApplication) { Task { - try await Guard.main.refreshPurchasedAppleProducts() + await Guard.main.refreshPurchases() } } diff --git a/PadelClub/Data/Federal/FederalPlayer.swift b/PadelClub/Data/Federal/FederalPlayer.swift index 3573a3e..141c613 100644 --- a/PadelClub/Data/Federal/FederalPlayer.swift +++ b/PadelClub/Data/Federal/FederalPlayer.swift @@ -80,7 +80,12 @@ class FederalPlayer: Decodable { let ageSportif = try container.decodeIfPresent(Int.self, forKey: .ageSportif) if let ageSportif { - birthYear = Calendar.current.component(.year, from: Date()) - ageSportif + let month = Calendar.current.component(.month, from: Date()) + if month > 8 { + birthYear = Calendar.current.component(.year, from: Date()) + 1 - ageSportif + } else { + birthYear = Calendar.current.component(.year, from: Date()) - ageSportif + } } clubCode = try container.decodeIfPresent(String.self, forKey: .codeClub) ?? "" club = try container.decodeIfPresent(String.self, forKey: .nomClub) ?? "" diff --git a/PadelClub/Extensions/Tournament+Extensions.swift b/PadelClub/Extensions/Tournament+Extensions.swift index 65408aa..099a9f7 100644 --- a/PadelClub/Extensions/Tournament+Extensions.swift +++ b/PadelClub/Extensions/Tournament+Extensions.swift @@ -11,36 +11,6 @@ import PadelClubData import LeStorage extension Tournament { - - func setupFederalSettings() { - teamSorting = tournamentLevel.defaultTeamSortingType - groupStageMatchFormat = groupStageSmartMatchFormat() - loserBracketMatchFormat = loserBracketSmartMatchFormat(5) - matchFormat = roundSmartMatchFormat(5) - entryFee = tournamentLevel.entryFee - registrationDateLimit = deadline(for: .inscription) - if enableOnlineRegistration, isAnimation() == false { - accountIsRequired = true - licenseIsRequired = true - } - } - - func customizeUsingPreferences() { - guard let lastTournamentWithSameBuild = DataStore.shared.tournaments.filter({ tournament in - tournament.tournamentLevel == self.tournamentLevel - && tournament.tournamentCategory == self.tournamentCategory - && tournament.federalTournamentAge == self.federalTournamentAge - && tournament.hasEnded() == true - && tournament.isCanceled == false - && tournament.isDeleted == false - }).sorted(by: \.endDate!, order: .descending).first else { - return - } - - self.dayDuration = lastTournamentWithSameBuild.dayDuration - self.teamCount = (lastTournamentWithSameBuild.teamCount / 2) * 2 - self.enableOnlineRegistration = lastTournamentWithSameBuild.enableOnlineRegistration - } func addTeam(_ players: Set, registrationDate: Date? = nil, name: String? = nil) -> TeamRegistration { let team = TeamRegistration(tournament: id, registrationDate: registrationDate ?? Date(), name: name) diff --git a/PadelClub/Views/Club/Shared/ClubCourtSetupView.swift b/PadelClub/Views/Club/Shared/ClubCourtSetupView.swift index bbb6ef9..6e08537 100644 --- a/PadelClub/Views/Club/Shared/ClubCourtSetupView.swift +++ b/PadelClub/Views/Club/Shared/ClubCourtSetupView.swift @@ -23,10 +23,17 @@ struct ClubCourtSetupView: View { .disabled(displayContext == .lockedForEditing) .onChange(of: club.courtCount) { if displayContext != .addition { - do { - try dataStore.clubs.addOrUpdate(instance: club) - } catch { - Logger.error(error) + dataStore.clubs.addOrUpdate(instance: club) + dataStore.events.filter { event in + event.club?.id == club.id + }.forEach { event in + let tournaments = event.tournaments.filter({ tournament in + tournament.startDate > Date() + }) + tournaments.forEach { tournament in + tournament.courtCount = club.courtCount + } + dataStore.tournaments.addOrUpdate(contentOfs: tournaments) } } } diff --git a/PadelClub/Views/Match/Components/PlayerBlockView.swift b/PadelClub/Views/Match/Components/PlayerBlockView.swift index c1a6a5c..56d88c9 100644 --- a/PadelClub/Views/Match/Components/PlayerBlockView.swift +++ b/PadelClub/Views/Match/Components/PlayerBlockView.swift @@ -77,7 +77,7 @@ struct PlayerBlockView: View { VStack(alignment: .leading) { ZStack(alignment: .leading) { VStack { - if let teamName = team?.name { + if let teamName = team?.name, teamName.isEmpty == false { Text(teamName).foregroundStyle(.secondary).font(.footnote) } Text("longLabelPlayerOne").lineLimit(1) @@ -91,7 +91,7 @@ struct PlayerBlockView: View { Text("Repêchée").italic().font(.caption) } - if let teamName = team.name { + if let teamName = team.name, teamName.isEmpty == false { Text(teamName).foregroundStyle(.secondary).font(.footnote) } else if team.players().isEmpty { if team.isWildCard() { diff --git a/PadelClub/Views/Match/MatchDetailView.swift b/PadelClub/Views/Match/MatchDetailView.swift index c03425d..5e59ccb 100644 --- a/PadelClub/Views/Match/MatchDetailView.swift +++ b/PadelClub/Views/Match/MatchDetailView.swift @@ -354,6 +354,33 @@ struct MatchDetailView: View { Text("Remise-à-zéro") } + Menu { + Button("Effacer le nom") { + match.name = nil + tournamentStore?.matches.addOrUpdate(instance: match) + } + + if let tournament = match.currentTournament() { + Menu { + ForEach(tournament.generateSeedGroups(base: 16, teamCount: 8), id: \.self) { seedGroup in + Button { + match.name = seedGroup.localizedInterval() + tournamentStore?.matches.addOrUpdate(instance: match) + } label: { + Text(seedGroup.localizedInterval()) + } + } + } label: { + Text("Choisir un nom") + } + } + } label: { + Text("[Site] Nom du match") + if let name = match.name { + Text("(\(name))") + } + } + if match.teamScores.isEmpty == false { Divider() Menu { diff --git a/PadelClub/Views/Navigation/Agenda/EventListView.swift b/PadelClub/Views/Navigation/Agenda/EventListView.swift index de9c649..ae9ff46 100644 --- a/PadelClub/Views/Navigation/Agenda/EventListView.swift +++ b/PadelClub/Views/Navigation/Agenda/EventListView.swift @@ -158,6 +158,29 @@ struct EventListView: View { } Divider() } + + Menu { + Picker("Choix du montant", selection: Binding(get: { + // If all tournaments share the same price, show it; otherwise default to 0 + let prices = Set(pcTournaments.compactMap { $0.entryFee }) + return prices.count == 1 ? prices.first ?? 0.0 : 0.0 + }, set: { (newValue: Double) in + // Apply the chosen price to every tournament + pcTournaments.forEach { tournament in + tournament.entryFee = newValue + } + dataStore.tournaments.addOrUpdate(contentOfs: pcTournaments) + })) { + ForEach([Double](stride(from: 0.0, through: 50.0, by: 5.0)), id: \.self) { (price: Double) in + Text(price.formatted(.currency(code: Locale.current.currency?.identifier ?? "EUR"))).tag(price as Double) + } + } + } label: { + Text("Montant de l'inscription") + } + + Divider() + Menu { Button { pcTournaments.forEach { tournament in @@ -534,3 +557,4 @@ struct EventListView: View { //#Preview { // EventListView(tournaments: [], viewStyle: .calendar, sortAscending: true) //} + diff --git a/PadelClub/Views/Navigation/Umpire/UmpireView.swift b/PadelClub/Views/Navigation/Umpire/UmpireView.swift index cd129fd..0a6fb23 100644 --- a/PadelClub/Views/Navigation/Umpire/UmpireView.swift +++ b/PadelClub/Views/Navigation/Umpire/UmpireView.swift @@ -317,18 +317,6 @@ struct UmpireView: View { licenseMessage = nil } .navigationTitle("Juge-Arbitre") - .toolbar { -#if DEBUG - ToolbarItem(placement: .topBarTrailing) { - NetworkStatusView() -// if StoreCenter.main.collectionsCanSynchronize { -// Image(systemName: "checkmark.icloud") -// } else { -// Image(systemName: "icloud.slash") -// } - } -#endif - } .navigationBarBackButtonHidden(focusedField != nil) .toolbar(content: { if focusedField != nil { diff --git a/PadelClub/Views/Team/EditingTeamView.swift b/PadelClub/Views/Team/EditingTeamView.swift index 10a58ac..5b81bf2 100644 --- a/PadelClub/Views/Team/EditingTeamView.swift +++ b/PadelClub/Views/Team/EditingTeamView.swift @@ -209,11 +209,6 @@ struct EditingTeamView: View { Text(registrationDateModified.localizedWeekDay().capitalized) } } - #if DEBUG - .disabled(false) - #else - .disabled(team.hasPaidOnline() || team.hasRegisteredOnline()) - #endif Toggle(isOn: $wildCardBracket) { Text("Wildcard Tableau") diff --git a/PadelClub/Views/Tournament/ConsolationTournamentImportView.swift b/PadelClub/Views/Tournament/ConsolationTournamentImportView.swift index d26cddc..1dd587e 100644 --- a/PadelClub/Views/Tournament/ConsolationTournamentImportView.swift +++ b/PadelClub/Views/Tournament/ConsolationTournamentImportView.swift @@ -218,8 +218,8 @@ struct ConsolationTournamentImportView: View { case .losers: if selectedGroupStagePosition.isEmpty { return $0.qualified == false - } else if let position = $0.groupStagePosition { - return $0.qualified == false && selectedGroupStagePosition.contains(position) + } else if let position = $0.groupStageObject()?.finalPosition(ofTeam: $0) { + return $0.qualified == false && selectedGroupStagePosition.contains(position + 1) } else { return $0.qualified == false } diff --git a/PadelClub/Views/Tournament/Subscription/SubscriptionView.swift b/PadelClub/Views/Tournament/Subscription/SubscriptionView.swift index 8673763..fa861a1 100644 --- a/PadelClub/Views/Tournament/Subscription/SubscriptionView.swift +++ b/PadelClub/Views/Tournament/Subscription/SubscriptionView.swift @@ -238,14 +238,9 @@ struct SubscriptionView: View { fileprivate func _restore() { Task { - do { - self.isRestoring = true - try await Guard.main.refreshPurchasedAppleProducts() - self.isRestoring = false - } catch { - self.isRestoring = false - Logger.error(error) - } + self.isRestoring = true + await Guard.main.refreshPurchases() + self.isRestoring = false } }