From 025e22b47a10e4665f2000a7af686661dbbe6f3e Mon Sep 17 00:00:00 2001 From: Raz Date: Fri, 28 Feb 2025 11:25:56 +0100 Subject: [PATCH] fix tournament cell sttuf --- PadelClub/OnlineRegistrationWarningView.swift | 60 +++++++++++++++++++ .../Screen/InscriptionManagerView.swift | 34 ++++------- .../Shared/TournamentCellView.swift | 11 +--- 3 files changed, 74 insertions(+), 31 deletions(-) create mode 100644 PadelClub/OnlineRegistrationWarningView.swift diff --git a/PadelClub/OnlineRegistrationWarningView.swift b/PadelClub/OnlineRegistrationWarningView.swift new file mode 100644 index 0000000..ad68e6a --- /dev/null +++ b/PadelClub/OnlineRegistrationWarningView.swift @@ -0,0 +1,60 @@ +// +// WaitingListView.swift +// PadelClub +// +// Created by razmig on 26/02/2025. +// + +import SwiftUI + +struct WaitingListView: View { + @Environment(Tournament.self) var tournament: Tournament + let teamCount: Int + + @ViewBuilder + var body: some View { + Text("Attention, l'inscription en ligne est activée et vous avez des équipes inscrites en ligne, en modifiant la structure ces équipes seront intégrées ou retirées de votre sélection d'équipes. Pour l'instant Padel Club ne saura pas les prévenir automatiquement, vous devrez les contacter via l'écran de gestion des inscriptions.") + .foregroundStyle(.logoRed) + let selection = tournament.selectedSortedTeams() + if teamCount > tournament.teamCount { + Section { + let teams = tournament.waitingListSortedTeams(selectedSortedTeams: selection) + .prefix(teamCount - tournament.teamCount) + .filter { $0.hasRegisteredOnline() } + + ForEach(teams) { team in + NavigationLink { + EditingTeamView(team: team) + .environment(tournament) + } label: { + TeamRowView(team: team) + } + } + } header: { + Text("Équipes entrantes dans la sélection") + } footer: { + Text("Équipes inscrites en ligne à prévenir rentrant dans votre liste") + } + } + + if teamCount < tournament.teamCount { + Section { + let teams = selection.suffix(tournament.teamCount - teamCount) + .filter { $0.hasRegisteredOnline() } + + ForEach(teams) { team in + NavigationLink { + EditingTeamView(team: team) + .environment(tournament) + } label: { + TeamRowView(team: team) + } + } + } header: { + Text("Équipes sortantes de la sélection") + } footer: { + Text("Équipes inscrites en ligne à prévenir retirées de votre liste") + } + } + } +} diff --git a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift index 53f2001..9ffefae 100644 --- a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift +++ b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift @@ -840,31 +840,21 @@ struct InscriptionManagerView: View { // } if tournament.enableOnlineRegistration { - Button { - Task { - await _refreshList() - } + LabeledContent { + Text(tournament.unsortedTeams().filter({ $0.hasRegisteredOnline() }).count.formatted()) + .font(.largeTitle) } label: { - LabeledContent { - if tournament.refreshInProgress { - ProgressView() - } else { - Text(tournament.unsortedTeams().filter({ $0.hasRegisteredOnline() }).count.formatted()) - .fontWeight(.bold) - } - } label: { - if let refreshStatus { - Text("Inscriptions en ligne") - } else if tournament.refreshInProgress { - Text("Récupération des inscrits en ligne") - } else { - Text("Récupérer des inscrits en ligne") - } - if let refreshResult { - Text(refreshResult).foregroundStyle(.secondary) - } + Text("Inscriptions en ligne") + if let refreshResult { + Text(refreshResult).foregroundStyle(.secondary) + } else { + Text(" ") } } + + RowButtonView("Rafraîchir les inscriptions en ligne") { + await _refreshList() + } } } header: { HStack { diff --git a/PadelClub/Views/Tournament/Shared/TournamentCellView.swift b/PadelClub/Views/Tournament/Shared/TournamentCellView.swift index 08cdae2..5914769 100644 --- a/PadelClub/Views/Tournament/Shared/TournamentCellView.swift +++ b/PadelClub/Views/Tournament/Shared/TournamentCellView.swift @@ -171,18 +171,11 @@ struct TournamentCellView: View { let value: Int = tournament.onlineTeams().count HStack { Spacer() - if value == 0 { - Text("(dont aucune équipe inscrite en ligne)").foregroundStyle(.secondary).font(.footnote) - } else { - Text("(dont " + value.formatted() + " équipe\(value.pluralSuffix) inscrite\(value.pluralSuffix) en ligne)").foregroundStyle(.secondary).font(.footnote) + if value > 0 { + Text("(dont " + value.formatted() + " équipe\(value.pluralSuffix) inscrite\(value.pluralSuffix) en ligne)") } } } - if tournament.refreshRanking { - Text("mise à jour des classements des joueurs").foregroundStyle(.secondary).font(.footnote) - } else if tournament.refreshInProgress { - Text("synchronisation des inscriptions en ligne").foregroundStyle(.secondary).font(.footnote) - } } } }