From 44f353e24da4821832d5a69615dd84a915e0412a Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Wed, 26 Jun 2024 11:47:56 +0200 Subject: [PATCH] =?UTF-8?q?ajout=20de=20la=20visibilit=C3=A9=20des=20joueu?= =?UTF-8?q?rs=20qui=20n'ont=20pas=20de=20moyen=20d'=C3=AAtre=20contact?= =?UTF-8?q?=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PadelClub.xcodeproj/project.pbxproj | 8 ++- PadelClub/Extensions/String+Extensions.swift | 6 ++ PadelClub/Utils/FileImportManager.swift | 10 ++-- .../PlayersWithoutContactView.swift | 55 +++++++++++++++++++ .../Views/Calling/GroupStageCallingView.swift | 2 + .../Views/Calling/SeedsCallingView.swift | 5 +- PadelClub/Views/Club/ClubsView.swift | 2 +- PadelClub/Views/Round/RoundView.swift | 1 - .../Views/Tournament/FileImportView.swift | 6 ++ .../Components/InscriptionInfoView.swift | 14 ++--- 10 files changed, 93 insertions(+), 16 deletions(-) create mode 100644 PadelClub/Views/Calling/Components/PlayersWithoutContactView.swift diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 500ba92..4ed8b55 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -225,6 +225,7 @@ FFC91AF92BD6A09100B29808 /* FortuneWheelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFC91AF82BD6A09100B29808 /* FortuneWheelView.swift */; }; FFC91B012BD85C2F00B29808 /* Court.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFC91B002BD85C2F00B29808 /* Court.swift */; }; FFC91B032BD85E2400B29808 /* CourtView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFC91B022BD85E2400B29808 /* CourtView.swift */; }; + FFCEDA4C2C2C08EA00F8C0F2 /* PlayersWithoutContactView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFCEDA4B2C2C08EA00F8C0F2 /* PlayersWithoutContactView.swift */; }; FFCFBFFE2BBBE86600B82851 /* Algorithms in Frameworks */ = {isa = PBXBuildFile; productRef = FFCFBFFD2BBBE86600B82851 /* Algorithms */; }; FFCFC00C2BBC3D1E00B82851 /* EditScoreView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFCFC0012BBC39A600B82851 /* EditScoreView.swift */; }; FFCFC00E2BBC3D4600B82851 /* PointSelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFCFC00D2BBC3D4600B82851 /* PointSelectionView.swift */; }; @@ -553,6 +554,7 @@ FFC91AF82BD6A09100B29808 /* FortuneWheelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FortuneWheelView.swift; sourceTree = ""; }; FFC91B002BD85C2F00B29808 /* Court.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Court.swift; sourceTree = ""; }; FFC91B022BD85E2400B29808 /* CourtView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourtView.swift; sourceTree = ""; }; + FFCEDA4B2C2C08EA00F8C0F2 /* PlayersWithoutContactView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayersWithoutContactView.swift; sourceTree = ""; }; FFCFC0012BBC39A600B82851 /* EditScoreView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditScoreView.swift; sourceTree = ""; }; FFCFC00D2BBC3D4600B82851 /* PointSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PointSelectionView.swift; sourceTree = ""; }; FFCFC0112BBC3E1A00B82851 /* PointView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PointView.swift; sourceTree = ""; }; @@ -1251,6 +1253,7 @@ isa = PBXGroup; children = ( FFEF7F4D2BDE69130033D0F0 /* MenuWarningView.swift */, + FFCEDA4B2C2C08EA00F8C0F2 /* PlayersWithoutContactView.swift */, ); path = Components; sourceTree = ""; @@ -1512,6 +1515,7 @@ FF6EC9042B9479F500EA7F5A /* Sequence+Extensions.swift in Sources */, FF9267FA2BCE78EC0080F940 /* CashierDetailView.swift in Sources */, C4A47DB32B86387500ADC637 /* AccountView.swift in Sources */, + FFCEDA4C2C2C08EA00F8C0F2 /* PlayersWithoutContactView.swift in Sources */, FF1CBC1D2BB53DC10036DAAB /* Calendar+Extensions.swift in Sources */, FF967CF22BAECC0B00A9A3BD /* TeamScore.swift in Sources */, FF1162832BCFBE4E000C4809 /* EditablePlayerView.swift in Sources */, @@ -1878,7 +1882,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 71; + CURRENT_PROJECT_VERSION = 72; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; @@ -1918,7 +1922,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 71; + CURRENT_PROJECT_VERSION = 72; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; diff --git a/PadelClub/Extensions/String+Extensions.swift b/PadelClub/Extensions/String+Extensions.swift index 580830e..a0abca5 100644 --- a/PadelClub/Extensions/String+Extensions.swift +++ b/PadelClub/Extensions/String+Extensions.swift @@ -195,3 +195,9 @@ extension String { return url } } + +extension String { + func toInt() -> Int? { + Int(self) + } +} diff --git a/PadelClub/Utils/FileImportManager.swift b/PadelClub/Utils/FileImportManager.swift index 1fc4b7b..b27ee9c 100644 --- a/PadelClub/Utils/FileImportManager.swift +++ b/PadelClub/Utils/FileImportManager.swift @@ -390,16 +390,18 @@ class FileImportManager { var teamName: String? = nil let players = team.map { player in let data = player.components(separatedBy: separator) - let firstName : String = data[safe: 2]?.trimmed ?? "" - let lastName : String = data[safe: 3]?.trimmed ?? "" + let lastName : String = data[safe: 2]?.trimmed ?? "" + let firstName : String = data[safe: 3]?.trimmed ?? "" let sex: PlayerRegistration.PlayerSexType = data[safe: 0] == "f" ? PlayerRegistration.PlayerSexType.female : PlayerRegistration.PlayerSexType.male if data[safe: 1]?.trimmed != nil { teamName = data[safe: 1]?.trimmed } let phoneNumber : String? = data[safe: 4]?.trimmed let email : String? = data[safe: 5]?.trimmed - //let level : String? = data[safe: 6]?.trimmed - let player = PlayerRegistration(firstName: firstName, lastName: lastName, sex: sex, phoneNumber: phoneNumber, email: email) + let rank : Int? = data[safe: 6]?.trimmed.toInt() + let licenceId : String? = data[safe: 7]?.trimmed + let club : String? = data[safe: 8]?.trimmed + let player = PlayerRegistration(firstName: firstName, lastName: lastName, licenceId: licenceId, rank: rank, sex: sex, clubName: club, phoneNumber: phoneNumber, email: email) return player } diff --git a/PadelClub/Views/Calling/Components/PlayersWithoutContactView.swift b/PadelClub/Views/Calling/Components/PlayersWithoutContactView.swift new file mode 100644 index 0000000..6b75e8c --- /dev/null +++ b/PadelClub/Views/Calling/Components/PlayersWithoutContactView.swift @@ -0,0 +1,55 @@ +// +// PlayersWithoutContactView.swift +// PadelClub +// +// Created by Razmig Sarkissian on 26/06/2024. +// + +import SwiftUI + +struct PlayersWithoutContactView: View { + @Environment(Tournament.self) var tournament: Tournament + let players: [PlayerRegistration] + + var body: some View { + Section { + let withoutEmails = players.filter({ $0.email?.isEmpty == true }) + DisclosureGroup { + ForEach(withoutEmails) { player in + NavigationLink { + PlayerDetailView(player: player) + .environment(tournament) + } label: { + ImportedPlayerView(player: player) + } + } + } label: { + LabeledContent { + Text(withoutEmails.count.formatted()) + } label: { + Text("Joueurs sans email") + } + } + + let withoutPhones = players.filter({ $0.phoneNumber?.isEmpty == true }) + DisclosureGroup { + ForEach(withoutPhones) { player in + NavigationLink { + PlayerDetailView(player: player) + .environment(tournament) + } label: { + ImportedPlayerView(player: player) + } + } + } label: { + LabeledContent { + Text(withoutPhones.count.formatted()) + } label: { + Text("Joueurs sans téléphone") + } + } + } header: { + Text("Joueurs sans moyen de contact") + } + } +} diff --git a/PadelClub/Views/Calling/GroupStageCallingView.swift b/PadelClub/Views/Calling/GroupStageCallingView.swift index 396b586..03d333b 100644 --- a/PadelClub/Views/Calling/GroupStageCallingView.swift +++ b/PadelClub/Views/Calling/GroupStageCallingView.swift @@ -14,6 +14,8 @@ struct GroupStageCallingView: View { var body: some View { let groupStages = tournament.groupStages() List { + PlayersWithoutContactView(players: groupStages.flatMap({ $0.unsortedTeams() }).flatMap({ $0.unsortedPlayers() }).sorted(by: \.computedRank)) + _sameTimeGroupStageView(groupStages: groupStages) ForEach(groupStages) { groupStage in diff --git a/PadelClub/Views/Calling/SeedsCallingView.swift b/PadelClub/Views/Calling/SeedsCallingView.swift index 806bc30..8ab7110 100644 --- a/PadelClub/Views/Calling/SeedsCallingView.swift +++ b/PadelClub/Views/Calling/SeedsCallingView.swift @@ -13,7 +13,10 @@ struct SeedsCallingView: View { var body: some View { List { - ForEach(tournament.rounds()) { round in + let tournamentRounds = tournament.rounds() + PlayersWithoutContactView(players: tournament.seededTeams().flatMap({ $0.unsortedPlayers() }).sorted(by: \.computedRank)) + + ForEach(tournamentRounds) { round in let seeds = round.seeds() let callSeeds = seeds.filter({ tournament.isStartDateIsDifferentThanCallDate($0) == false }) if seeds.isEmpty == false { diff --git a/PadelClub/Views/Club/ClubsView.swift b/PadelClub/Views/Club/ClubsView.swift index 913d8f7..8cf0620 100644 --- a/PadelClub/Views/Club/ClubsView.swift +++ b/PadelClub/Views/Club/ClubsView.swift @@ -30,7 +30,7 @@ struct ClubsView: View { #if DEBUG Section { RowButtonView("Delete unexisted clubs", action: { - var ids = dataStore.user.clubs + let ids = dataStore.user.clubs ids.forEach { clubId in if dataStore.clubs.findById(clubId) == nil { dataStore.user.clubs.removeAll(where: { $0 == clubId }) diff --git a/PadelClub/Views/Round/RoundView.swift b/PadelClub/Views/Round/RoundView.swift index eaa84ba..e36dbc0 100644 --- a/PadelClub/Views/Round/RoundView.swift +++ b/PadelClub/Views/Round/RoundView.swift @@ -69,7 +69,6 @@ struct RoundView: View { var body: some View { List { let displayableMatches = upperRound.round.displayableMatches().sorted(by: \.index) - let loserRounds = upperRound.loserRounds if displayableMatches.isEmpty { Section { ContentUnavailableView("Aucun match dans cette manche", systemImage: "tennisball") diff --git a/PadelClub/Views/Tournament/FileImportView.swift b/PadelClub/Views/Tournament/FileImportView.swift index 1eae621..0641b19 100644 --- a/PadelClub/Views/Tournament/FileImportView.swift +++ b/PadelClub/Views/Tournament/FileImportView.swift @@ -16,6 +16,8 @@ enum FileImportCustomField: Int, Identifiable, CaseIterable { case teamName case lastName case firstName + case phoneNumber + case email case rank case licenceId case clubName @@ -44,6 +46,10 @@ enum FileImportCustomField: Int, Identifiable, CaseIterable { return "Nom" case .firstName: return "Prénom" + case .phoneNumber: + return "Téléphone" + case .email: + return "E-mail" case .rank: return "Rang" case .licenceId: diff --git a/PadelClub/Views/Tournament/Screen/Components/InscriptionInfoView.swift b/PadelClub/Views/Tournament/Screen/Components/InscriptionInfoView.swift index 80fc68b..aaf6d49 100644 --- a/PadelClub/Views/Tournament/Screen/Components/InscriptionInfoView.swift +++ b/PadelClub/Views/Tournament/Screen/Components/InscriptionInfoView.swift @@ -43,13 +43,13 @@ struct InscriptionInfoView: View { } .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) +// 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) } Section {