diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 158468e..4e02304 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -3145,7 +3145,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.2.49; + 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.49; + MARKETING_VERSION = 1.2.50; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; 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/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/Team/EditingTeamView.swift b/PadelClub/Views/Team/EditingTeamView.swift index 6136e36..5acbadb 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")