fix issue with field setup

add a way to set price on all tournaments of a month
fix the tournament creation not using the most used price
fix issue in team detail view regarding registratoin date modification
sync3
Razmig Sarkissian 2 months ago
parent 29636ac374
commit 463a7af43b
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 30
      PadelClub/Extensions/Tournament+Extensions.swift
  3. 15
      PadelClub/Views/Club/Shared/ClubCourtSetupView.swift
  4. 24
      PadelClub/Views/Navigation/Agenda/EventListView.swift
  5. 5
      PadelClub/Views/Team/EditingTeamView.swift

@ -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 = "";

@ -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<PlayerRegistration>, registrationDate: Date? = nil, name: String? = nil) -> TeamRegistration {
let team = TeamRegistration(tournament: id, registrationDate: registrationDate ?? Date(), name: name)

@ -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)
}
}
}

@ -158,6 +158,29 @@ struct EventListView: View {
}
Divider()
}
Menu {
Picker("Choix du montant", selection: Binding<Double>(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)
//}

@ -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")

Loading…
Cancel
Save