fix menu option

main
Razmig Sarkissian 2 weeks ago
parent dd54cfa9fd
commit ec5fc5b5e2
  1. 2
      PadelClub/Utils/FileImportManager.swift
  2. 2
      PadelClub/Views/Components/StepperView.swift
  3. 10
      PadelClub/Views/Navigation/Agenda/EventListView.swift
  4. 2
      PadelClub/Views/Navigation/Umpire/PadelClubView.swift
  5. 21
      PadelClub/Views/Player/PlayerDetailView.swift
  6. 16
      PadelClub/Views/Team/TeamMatchesView.swift

@ -154,7 +154,7 @@ class FileImportManager {
}
let significantPlayerCount = 2
let pl = players.prefix(significantPlayerCount).map { $0.computedRank }
let missingPl = (missing.map { tournament.unrankValue(for: $0 == 1 ? true : false ) ?? ($0 == 1 ? 90_415 : 10_000) }).prefix(significantPlayerCount)
let missingPl = (missing.map { tournament.unrankValue(for: $0 == 1 ? true : false ) ?? ($0 == 1 ? 92_327 : 10_000) }).prefix(significantPlayerCount)
self.weight = pl.reduce(0,+) + missingPl.reduce(0,+)
} else {
self.weight = players.map { $0.computedRank }.reduce(0,+)

@ -94,7 +94,7 @@ struct StepperView: View {
}
fileprivate func _plusIsDisabled() -> Bool {
count >= (maximum ?? 90_415)
count >= (maximum ?? 92_327)
}
fileprivate func _add() {

@ -448,17 +448,7 @@ struct EventListView: View {
Divider()
if tournament.hasEnded() == false {
Button {
navigation.openTournamentInOrganizer(tournament)
} label: {
Label("Afficher dans le gestionnaire", systemImage: "line.diagonal.arrow")
}
Divider()
_options([tournament])
}
}
#if DEBUG

@ -160,7 +160,7 @@ struct PadelClubView: View {
if let maleUnrankedValue = monthData.maleUnrankedValue {
Text(maleUnrankedValue.formatted())
} else {
Text(90_415.formatted())
Text(92_327.formatted())
}
} label: {
Text("Rang d'un non classé")

@ -30,6 +30,20 @@ struct PlayerDetailView: View {
return self.tournament.tournamentStore
}
var unranked: Binding<Bool> {
Binding {
player.isUnranked()
} set: { isUnranked in
player.rank = nil
player.setComputedRank(in: tournament)
if let team = player.team() {
team.setWeight(from: team.players(), inTournamentCategory: tournament.category)
}
_save()
}
}
init(player: PlayerRegistration) {
self.player = player
_licenceId = .init(wrappedValue: player.licenceId ?? "")
@ -130,6 +144,11 @@ struct PlayerDetailView: View {
}
Section {
Toggle(isOn: unranked) {
Text("Non classé\(player.sex == .female ? "e" : "")")
}
LabeledContent {
TextField("Rang", value: $player.rank, format: .number)
.keyboardType(.decimalPad)
@ -147,7 +166,7 @@ struct PlayerDetailView: View {
}
}
let maxMaleUnrankedValue: Int = tournament.maleUnrankedValue ?? 90_415
let maxMaleUnrankedValue: Int = tournament.maleUnrankedValue ?? 92_327
if player.isMalePlayer() == false && tournament.tournamentCategory == .men && (player.rank == maxMaleUnrankedValue || player.rank == nil) {
Section {

@ -14,15 +14,27 @@ struct TeamMatchesView: View {
var body: some View {
List {
Section {
TeamRowView(team: team)
}
let followingMatches = team.followingMatches()
if let currentMatch = team.currentMatch() {
Section {
MatchRowView(match: currentMatch)
} header: {
Text("Prochain match")
Text("Match en cours")
}
} else if let numbers = team.numberOfRotation(in: followingMatches) {
Section {
Text("Joue dans \(numbers.0) rotation\(numbers.0.pluralSuffix)")
Text("Joue dans \(numbers.1) terrain\(numbers.1.pluralSuffix) disponible\(numbers.1.pluralSuffix)")
} footer: {
Text("Indique dans combien de rotations ou terrains disponible cette équipe est sensée jouer.")
}
}
let followingMatches = team.followingMatches()
if followingMatches.isEmpty == false {
Section {
ForEach(followingMatches) { match in

Loading…
Cancel
Save