From cb89a322cae01fac97844a975e07b14a2777a862 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 16 Apr 2024 10:55:03 +0200 Subject: [PATCH] small fixes --- .../Components/PlayerSexPickerView.swift | 4 +- .../Views/Tournament/FileImportView.swift | 2 + .../Components/InscriptionInfoView.swift | 61 +++++++++---------- .../Screen/InscriptionManagerView.swift | 1 + 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/PadelClub/Views/Player/Components/PlayerSexPickerView.swift b/PadelClub/Views/Player/Components/PlayerSexPickerView.swift index a567bb1..9964bd2 100644 --- a/PadelClub/Views/Player/Components/PlayerSexPickerView.swift +++ b/PadelClub/Views/Player/Components/PlayerSexPickerView.swift @@ -17,8 +17,8 @@ struct PlayerSexPickerView: View { Text(player.playerLabel()) Spacer() Picker(selection: $player.sex) { - Text("Homme").tag(1 as Int64) - Text("Femme").tag(0 as Int64) + Text("Homme").tag(1 as Int) + Text("Femme").tag(0 as Int) } label: { } diff --git a/PadelClub/Views/Tournament/FileImportView.swift b/PadelClub/Views/Tournament/FileImportView.swift index b404cc2..0974f39 100644 --- a/PadelClub/Views/Tournament/FileImportView.swift +++ b/PadelClub/Views/Tournament/FileImportView.swift @@ -180,6 +180,7 @@ struct FileImportView: View { if let selectedFile = fileurls.first { if selectedFile.startAccessingSecurityScopedResource() { convertingFile = true + errorMessage = nil teams.removeAll() Task { do { @@ -262,6 +263,7 @@ struct FileImportView: View { func _startImport(fileContent: String) async { await MainActor.run { convertingFile = true + errorMessage = nil teams.removeAll() } self.teams = await FileImportManager.shared.createTeams(from: fileContent, tournament: tournament, fileProvider: fileProvider) diff --git a/PadelClub/Views/Tournament/Screen/Components/InscriptionInfoView.swift b/PadelClub/Views/Tournament/Screen/Components/InscriptionInfoView.swift index 663b9e8..4f7d8e9 100644 --- a/PadelClub/Views/Tournament/Screen/Components/InscriptionInfoView.swift +++ b/PadelClub/Views/Tournament/Screen/Components/InscriptionInfoView.swift @@ -8,18 +8,45 @@ import SwiftUI struct InscriptionInfoView: View { + @EnvironmentObject var dataStore: DataStore @Environment(Tournament.self) var tournament @State private var duplicates = [PlayerRegistration]() @State private var problematicPlayers = [PlayerRegistration]() @State private var inadequatePlayers = [PlayerRegistration]() @State private var playersWithoutValidLicense = [PlayerRegistration]() - @State private var entriesNotFromBeachPadel = [TeamRegistration]() + @State private var entriesFromBeachPadel = [TeamRegistration]() @State private var playersMissing = [TeamRegistration]() @State private var waitingList = [TeamRegistration]() @State private var selectedTeams = [TeamRegistration]() var body: some View { List { + Section { + LabeledContent { + Text(entriesFromBeachPadel.count.formatted()) + } label: { + Text("Paires importées") + Text(SourceFileManager.beachPadel.absoluteString) + } + .listRowView(color: .indigo) + + LabeledContent { + Text(selectedTeams.filter { $0.called() }.count.formatted()) + } label: { + Text("Paires convoquées") + Text("Vous avez envoyé une convocation par sms ou email") + } + .listRowView(color: .cyan) + + LabeledContent { + Text(selectedTeams.filter { $0.confirmed() }.count.formatted()) + } label: { + Text("Paires ayant confirmées") + Text("Vous avez noté la confirmation de l'équipe") + } + .listRowView(color: .green) + } + let waitingListInBracket = waitingList.filter({ $0.bracketPosition != nil }) let waitingListInGroupStage = waitingList.filter({ $0.groupStage != nil }) @@ -96,9 +123,7 @@ struct InscriptionInfoView: View { LabeledContent { Text(inadequatePlayers.count.formatted()) } label: { - let playerLabel : String = tournament.tournamentCategory == .women ? "joueuse" : "joueur" - let grammarSuffix : String = tournament.tournamentCategory == .women ? "e" + inadequatePlayers.count.pluralSuffix : inadequatePlayers.count.pluralSuffix - Text(playerLabel.capitalized + inadequatePlayers.count.pluralSuffix + " trop bien classé" + grammarSuffix) + Text("Joueurs trop bien classés") } } .listRowView(color: .red) @@ -137,32 +162,6 @@ struct InscriptionInfoView: View { } .listRowView(color: .pink) } - - Section { - LabeledContent { - Text(entriesNotFromBeachPadel.count.formatted()) - } label: { - Text("Paires importées") - Text(SourceFileManager.beachPadel.absoluteString) - } - .listRowView(color: .indigo) - - LabeledContent { - Text(selectedTeams.filter { $0.called() }.count.formatted()) - } label: { - Text("Paires convoquées") - Text("Vous avez envoyé une convocation par sms ou email") - } - .listRowView(color: .cyan) - - LabeledContent { - Text(selectedTeams.filter { $0.confirmed() }.count.formatted()) - } label: { - Text("Paires ayant confirmées") - Text("Vous avez noté la confirmation de l'équipe") - } - .listRowView(color: .green) - } } .navigationTitle("Synthèse") .navigationBarTitleDisplayMode(.inline) @@ -180,7 +179,7 @@ struct InscriptionInfoView: View { problematicPlayers = players.filter({ $0.sex == -1 }) inadequatePlayers = tournament.inadequatePlayers(in: players) playersWithoutValidLicense = tournament.playersWithoutValidLicense(in: players) - entriesNotFromBeachPadel = selectedTeams.filter({ $0.isImported() }) + entriesFromBeachPadel = tournament.unsortedTeams().filter({ $0.isImported() }) playersMissing = selectedTeams.filter({ $0.unsortedPlayers().count < 2 }) } } diff --git a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift index fd409dc..2394e49 100644 --- a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift +++ b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift @@ -123,6 +123,7 @@ struct InscriptionManagerView: View { ToolbarItem(placement: .cancellationAction) { Button("Annuler", role: .cancel) { pasteString = nil + editedTeam = nil createdPlayers.removeAll() createdPlayerIds.removeAll() }