You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
278 lines
11 KiB
278 lines
11 KiB
//
|
|
// InscriptionInfoView.swift
|
|
// PadelClub
|
|
//
|
|
// Created by Razmig Sarkissian on 27/03/2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct InscriptionInfoView: View {
|
|
@EnvironmentObject var dataStore: DataStore
|
|
let tournament: Tournament
|
|
|
|
@State private var players : [PlayerRegistration] = []
|
|
@State private var selectedTeams : [TeamRegistration] = []
|
|
@State private var callDateIssue : [TeamRegistration] = []
|
|
@State private var waitingList : [TeamRegistration] = []
|
|
@State private var duplicates : [PlayerRegistration] = []
|
|
@State private var problematicPlayers : [PlayerRegistration] = []
|
|
@State private var inadequatePlayers : [PlayerRegistration] = []
|
|
@State private var ageInadequatePlayers : [PlayerRegistration] = []
|
|
@State private var playersWithoutValidLicense : [PlayerRegistration] = []
|
|
@State private var entriesFromBeachPadel : [TeamRegistration] = []
|
|
@State private var playersMissing : [TeamRegistration] = []
|
|
@State private var homonyms : [PlayerRegistration] = []
|
|
|
|
var body: some View {
|
|
List {
|
|
Section {
|
|
LabeledContent {
|
|
Text(selectedTeams.filter { $0.called() }.count.formatted())
|
|
} label: {
|
|
Text("Paires convoquées")
|
|
}
|
|
.listRowView(color: .cyan)
|
|
|
|
LabeledContent {
|
|
Text(selectedTeams.filter { $0.confirmed() }.count.formatted())
|
|
} label: {
|
|
Text("Paires ayant confirmées")
|
|
}
|
|
.listRowView(color: .green)
|
|
}
|
|
|
|
if tournament.isAnimation() == false, entriesFromBeachPadel.count > 0 {
|
|
let notFromBeach = selectedTeams.filter({ $0.isImported() == false })
|
|
|
|
Section {
|
|
let subtitle = "via [beach-padel.app.fft.fr](\(URLs.beachPadel.rawValue))"
|
|
|
|
LabeledContent {
|
|
Text(entriesFromBeachPadel.count.formatted())
|
|
} label: {
|
|
Text("Paires importées")
|
|
Text(.init(subtitle))
|
|
}
|
|
.listRowView(color: .indigo)
|
|
|
|
DisclosureGroup {
|
|
ForEach(notFromBeach) { team in
|
|
TeamDetailView(team: team)
|
|
}
|
|
} label: {
|
|
LabeledContent {
|
|
Text(notFromBeach.count.formatted())
|
|
} label: {
|
|
Text("Paires non importées")
|
|
}
|
|
}
|
|
.listRowView(color: .brown)
|
|
} footer: {
|
|
if notFromBeach.isEmpty == false {
|
|
let footerString = "Au moins un joueur ne provient pas du fichier. Il est possible que vous ayez à mettre à jour les équipes sur [beach-padel.app.fft.fr](\(URLs.beachPadel.rawValue))"
|
|
|
|
Text(.init(footerString))
|
|
}
|
|
}
|
|
}
|
|
|
|
Section {
|
|
DisclosureGroup {
|
|
ForEach(callDateIssue) { team in
|
|
TeamCallView(team: team)
|
|
.environment(tournament)
|
|
}
|
|
} label: {
|
|
LabeledContent {
|
|
Text(callDateIssue.count.formatted())
|
|
} label: {
|
|
Text("Erreur de convocation")
|
|
}
|
|
}
|
|
.listRowView(color: .brown)
|
|
} footer: {
|
|
Text("L'horaire de la convocation est différente du match initial")
|
|
}
|
|
|
|
let waitingListInBracket = waitingList.filter({ $0.bracketPosition != nil })
|
|
let waitingListInGroupStage = waitingList.filter({ $0.groupStage != nil })
|
|
|
|
Section {
|
|
DisclosureGroup {
|
|
ForEach(waitingListInBracket) { team in
|
|
TeamDetailView(team: team)
|
|
}
|
|
} label: {
|
|
LabeledContent {
|
|
Text(waitingListInBracket.count.formatted())
|
|
} label: {
|
|
Text("Dans le tableau")
|
|
}
|
|
}
|
|
.listRowView(color: .logoRed)
|
|
|
|
DisclosureGroup {
|
|
ForEach(waitingListInGroupStage) { team in
|
|
TeamDetailView(team: team)
|
|
}
|
|
} label: {
|
|
LabeledContent {
|
|
Text(waitingListInGroupStage.count.formatted())
|
|
} label: {
|
|
Text("En poule")
|
|
}
|
|
}
|
|
.listRowView(color: .logoRed)
|
|
} header: {
|
|
Text("Équipes ne devant plus être sélectionnées")
|
|
} footer: {
|
|
Text("Il s'agit des équipes précédement placées en poule ou tableau mais qui sont finalement maintenant en attente suite à l'arrivée d'une nouvelle équipe plus forte ou une modification de classement.")
|
|
}
|
|
|
|
Section {
|
|
DisclosureGroup {
|
|
ForEach(duplicates) { player in
|
|
ImportedPlayerView(player: player)
|
|
}
|
|
} label: {
|
|
LabeledContent {
|
|
Text(duplicates.count.formatted())
|
|
} label: {
|
|
Text("Doublons")
|
|
}
|
|
}
|
|
.listRowView(color: .logoRed)
|
|
|
|
DisclosureGroup {
|
|
ForEach(homonyms) { player in
|
|
ImportedPlayerView(player: player)
|
|
}
|
|
} label: {
|
|
LabeledContent {
|
|
Text(homonyms.count.formatted())
|
|
} label: {
|
|
Text("Homonymes")
|
|
}
|
|
}
|
|
.listRowView(color: .logoRed)
|
|
|
|
DisclosureGroup {
|
|
ForEach(playersMissing) {
|
|
TeamDetailView(team: $0)
|
|
}
|
|
} label: {
|
|
LabeledContent {
|
|
Text(playersMissing.count.formatted())
|
|
} label: {
|
|
Text("Paires incomplètes")
|
|
}
|
|
}
|
|
.listRowView(color: .pink)
|
|
}
|
|
|
|
Section {
|
|
DisclosureGroup {
|
|
ForEach(problematicPlayers) { player in
|
|
PlayerSexPickerView(player: player)
|
|
}
|
|
} label: {
|
|
LabeledContent {
|
|
Text(problematicPlayers.count.formatted())
|
|
} label: {
|
|
Text("Joueurs problématiques")
|
|
}
|
|
}
|
|
.listRowView(color: .purple)
|
|
} footer: {
|
|
Text("Il s'agit des joueurs ou joueuses dont le sexe n'a pas pu être déterminé")
|
|
}
|
|
|
|
Section {
|
|
DisclosureGroup {
|
|
ForEach(inadequatePlayers) { player in
|
|
ImportedPlayerView(player: player)
|
|
}
|
|
} label: {
|
|
LabeledContent {
|
|
Text(inadequatePlayers.count.formatted())
|
|
} label: {
|
|
Text("Joueurs trop bien classés")
|
|
}
|
|
}
|
|
.listRowView(color: .logoRed)
|
|
} footer: {
|
|
Text("Il s'agit des joueurs ou joueuses dont le rang est inférieur à la limite fédérale.")
|
|
}
|
|
|
|
Section {
|
|
DisclosureGroup {
|
|
ForEach(ageInadequatePlayers) { player in
|
|
ImportedPlayerView(player: player)
|
|
}
|
|
} label: {
|
|
LabeledContent {
|
|
Text(ageInadequatePlayers.count.formatted())
|
|
} label: {
|
|
Text("Joueurs trop jeunes ou trop âgés")
|
|
}
|
|
}
|
|
.listRowView(color: .logoRed)
|
|
} footer: {
|
|
Text("Il s'agit des joueurs ou joueuses dont l'âge sportif est inférieur ou supérieur à la limite fédérale.")
|
|
}
|
|
|
|
Section {
|
|
DisclosureGroup {
|
|
ForEach(playersWithoutValidLicense) {
|
|
EditablePlayerView(player: $0, editingOptions: [.licenceId])
|
|
.environmentObject(tournament.tournamentStore)
|
|
.onChange(of: $0.licenceId) {
|
|
players = tournament.unsortedPlayers()
|
|
let isImported = players.anySatisfy({ $0.isImported() })
|
|
playersWithoutValidLicense = tournament.playersWithoutValidLicense(in: players, isImported: isImported)
|
|
}
|
|
}
|
|
} label: {
|
|
LabeledContent {
|
|
Text(playersWithoutValidLicense.count.formatted())
|
|
} label: {
|
|
Text("Joueurs sans licence valide")
|
|
}
|
|
}
|
|
.listRowView(color: .orange)
|
|
} footer: {
|
|
Text("importé du fichier beach-padel sans licence valide ou créé sans licence")
|
|
}
|
|
}
|
|
.onAppear {
|
|
DispatchQueue.main.async {
|
|
_getIssues()
|
|
}
|
|
}
|
|
.navigationTitle("Synthèse")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbarBackground(.visible, for: .navigationBar)
|
|
}
|
|
|
|
private func _getIssues() {
|
|
players = tournament.unsortedPlayers()
|
|
selectedTeams = tournament.selectedSortedTeams()
|
|
callDateIssue = selectedTeams.filter { $0.callDate != nil && tournament.isStartDateIsDifferentThanCallDate($0) }
|
|
waitingList = tournament.waitingListTeams(in: selectedTeams, includingWalkOuts: true)
|
|
duplicates = tournament.duplicates(in: players)
|
|
homonyms = tournament.homonyms(in: players)
|
|
problematicPlayers = players.filter({ $0.sex == nil })
|
|
inadequatePlayers = tournament.inadequatePlayers(in: players)
|
|
ageInadequatePlayers = tournament.ageInadequatePlayers(in: players)
|
|
let isImported = players.anySatisfy({ $0.isImported() })
|
|
playersWithoutValidLicense = tournament.playersWithoutValidLicense(in: players, isImported: isImported)
|
|
entriesFromBeachPadel = tournament.unsortedTeams().filter({ $0.isImported() })
|
|
playersMissing = selectedTeams.filter({ $0.unsortedPlayers().count < 2 })
|
|
}
|
|
}
|
|
|
|
//#Preview {
|
|
// InscriptionInfoView()
|
|
// .environment(Tournament.mock())
|
|
//}
|
|
|