|
|
|
|
@ -52,7 +52,10 @@ struct InscriptionManagerView: View { |
|
|
|
|
@State private var refreshResult: String? = nil |
|
|
|
|
@State private var refreshInProgress: Bool = false |
|
|
|
|
@State private var refreshStatus: Bool? |
|
|
|
|
|
|
|
|
|
@State private var gatheringInProgress: Bool = false |
|
|
|
|
@State private var gathered: Double = 0 |
|
|
|
|
@State private var gatheringDone: Bool = false |
|
|
|
|
|
|
|
|
|
var tournamentStore: TournamentStore { |
|
|
|
|
return self.tournament.tournamentStore |
|
|
|
|
} |
|
|
|
|
@ -631,6 +634,10 @@ struct InscriptionManagerView: View { |
|
|
|
|
_teamDeleteButtonView(team) |
|
|
|
|
} |
|
|
|
|
.listRowView(isActive: true, color: team.initialRoundColor() ?? tournament.cutLabelColor(index: teamIndex, teamCount: filterMode == .waiting ? 0 : selectedSortedTeams.count), hideColorVariation: true) |
|
|
|
|
.onAppear { |
|
|
|
|
let w = team.players().prefix(6).map({ $0.computedRank }).reduce(0,+) |
|
|
|
|
print(team.teamLabel(), w, team.weight) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} header: { |
|
|
|
|
if filterMode == .all && walkoutTeams.isEmpty == false { |
|
|
|
|
@ -865,9 +872,13 @@ struct InscriptionManagerView: View { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Button("Récupérer les non-classés") { |
|
|
|
|
let unrankedUnsourced = tournament.players().filter({ $0.isUnranked() && $0.source == nil }) |
|
|
|
|
Button { |
|
|
|
|
Task { |
|
|
|
|
for player in tournament.players().filter({ $0.isUnranked() && $0.source == nil }) { |
|
|
|
|
gatheringInProgress = true |
|
|
|
|
gathered = 0 |
|
|
|
|
gatheringDone = false |
|
|
|
|
for player in unrankedUnsourced { |
|
|
|
|
do { |
|
|
|
|
if let playerData = try await player.fetchUnrankPlayerData() { |
|
|
|
|
player.lastName = playerData.nom |
|
|
|
|
@ -875,13 +886,33 @@ struct InscriptionManagerView: View { |
|
|
|
|
player.clubCode = playerData.codeClub |
|
|
|
|
player.source = .frenchFederation |
|
|
|
|
try tournamentStore.playerRegistrations.addOrUpdate(instance: player) |
|
|
|
|
await MainActor.run { |
|
|
|
|
gathered += 1 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch { |
|
|
|
|
print(error) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
gatheringDone = true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} label: { |
|
|
|
|
if gatheringInProgress { |
|
|
|
|
ProgressView("Récupérés", value: gathered, total: Double(unrankedUnsourced.count)) |
|
|
|
|
} else { |
|
|
|
|
LabeledContent { |
|
|
|
|
if gatheringDone { |
|
|
|
|
Image(systemName: "checkmark").foregroundStyle(.green) |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
Text("Récupérer les non-classés") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Button("Recalculer les poids") { |
|
|
|
|
tournament.updateWeights() |
|
|
|
|
_setHash() |
|
|
|
|
} |
|
|
|
|
} header: { |
|
|
|
|
HStack { |
|
|
|
|
|