diff --git a/PadelClub/Views/Calling/CallView.swift b/PadelClub/Views/Calling/CallView.swift index d29510a..58f953c 100644 --- a/PadelClub/Views/Calling/CallView.swift +++ b/PadelClub/Views/Calling/CallView.swift @@ -124,6 +124,14 @@ struct CallView: View { .alert("Un problème est survenu", isPresented: messageSentFailed) { Button("OK") { } + + if case .uncalledTeams(let uncalledTeams) = sentError { + NavigationLink("Voir les équipes non contactées") { + TeamsCallingView(teams: uncalledTeams) + .environment(tournament) + } + } + } message: { Text(_networkErrorMessage) } diff --git a/PadelClub/Views/Calling/GroupStageCallingView.swift b/PadelClub/Views/Calling/GroupStageCallingView.swift index 0b95b62..357df0f 100644 --- a/PadelClub/Views/Calling/GroupStageCallingView.swift +++ b/PadelClub/Views/Calling/GroupStageCallingView.swift @@ -14,6 +14,14 @@ struct GroupStageCallingView: View { var body: some View { let groupStages = tournament.groupStages() List { + + NavigationLink { + TeamsCallingView(teams: groupStages.flatMap({ $0.unsortedTeams() }).filter({ $0.callDate == nil })) + .environment(tournament) + } label: { + LabeledContent("Équipes non contactées", value: groupStages.flatMap({ $0.unsortedTeams() }).filter({ $0.callDate == nil }).count.formatted()) + } + PlayersWithoutContactView(players: groupStages.flatMap({ $0.unsortedTeams() }).flatMap({ $0.unsortedPlayers() }).sorted(by: \.computedRank)) _sameTimeGroupStageView(groupStages: groupStages) diff --git a/PadelClub/Views/Calling/SeedsCallingView.swift b/PadelClub/Views/Calling/SeedsCallingView.swift index d4716dd..abfcec7 100644 --- a/PadelClub/Views/Calling/SeedsCallingView.swift +++ b/PadelClub/Views/Calling/SeedsCallingView.swift @@ -14,6 +14,14 @@ struct SeedsCallingView: View { var body: some View { List { let tournamentRounds = tournament.rounds() + + NavigationLink { + TeamsCallingView(teams: tournament.seededTeams().filter({ $0.callDate == nil })) + .environment(tournament) + } label: { + LabeledContent("Équipes non contactées", value: tournament.seededTeams().filter({ $0.callDate == nil }).count.formatted()) + } + PlayersWithoutContactView(players: tournament.seededTeams().flatMap({ $0.unsortedPlayers() }).sorted(by: \.computedRank)) ForEach(tournamentRounds) { round in @@ -55,6 +63,10 @@ struct SeedsCallingView: View { } } + NavigationLink("Équipes non contactées") { + TeamsCallingView(teams: round.teams().filter({ $0.callDate == nil })) + } + if displayByMatch == false { ForEach(keys, id: \.self) { time in diff --git a/PadelClub/Views/Calling/SendToAllView.swift b/PadelClub/Views/Calling/SendToAllView.swift index e1f2504..2dfa04f 100644 --- a/PadelClub/Views/Calling/SendToAllView.swift +++ b/PadelClub/Views/Calling/SendToAllView.swift @@ -121,6 +121,13 @@ struct SendToAllView: View { .alert("Un problème est survenu", isPresented: messageSentFailed) { Button("OK") { } + + if case .uncalledTeams(let uncalledTeams) = sentError { + NavigationLink("Voir les équipes non contactées") { + TeamsCallingView(teams: uncalledTeams) + .environment(tournament) + } + } } message: { Text(_networkErrorMessage) } diff --git a/PadelClub/Views/Calling/TeamsCallingView.swift b/PadelClub/Views/Calling/TeamsCallingView.swift index 86e4d23..986322d 100644 --- a/PadelClub/Views/Calling/TeamsCallingView.swift +++ b/PadelClub/Views/Calling/TeamsCallingView.swift @@ -10,10 +10,10 @@ import LeStorage struct TeamsCallingView: View { @Environment(Tournament.self) var tournament: Tournament - + let teams : [TeamRegistration] + var body: some View { List { - let teams = tournament.selectedSortedTeams() Section { ForEach(teams) { team in Menu { @@ -21,13 +21,11 @@ struct TeamsCallingView: View { } label: { HStack { TeamRowView(team: team, displayCallDate: true) - if team.called() { - Spacer() - Menu { - _menuOptions(team: team) - } label: { - LabelOptions().labelStyle(.iconOnly) - } + Spacer() + Menu { + _menuOptions(team: team) + } label: { + LabelOptions().labelStyle(.iconOnly) } } } @@ -70,6 +68,21 @@ struct TeamsCallingView: View { } label: { Text("Effacer la date de convocation") } + + + Divider() + + Button(role: .destructive) { + team.callDate = team.initialMatch()?.startDate ?? tournament.startDate + do { + try self.tournament.tournamentStore.teamRegistrations.addOrUpdate(instance: team) + } catch { + Logger.error(error) + } + } label: { + Text("Indiquer comme convoquée") + } + } } diff --git a/PadelClub/Views/Tournament/Screen/TournamentCallView.swift b/PadelClub/Views/Tournament/Screen/TournamentCallView.swift index 94cc2dd..8b93bda 100644 --- a/PadelClub/Views/Tournament/Screen/TournamentCallView.swift +++ b/PadelClub/Views/Tournament/Screen/TournamentCallView.swift @@ -106,7 +106,7 @@ struct TournamentCallView: View { case .some(let selectedCall): switch selectedCall { case .teams: - TeamsCallingView() + TeamsCallingView(teams: tournament.selectedSortedTeams()) case .groupStages: GroupStageCallingView() case .seeds: