From 138551c32a1262f5ddea9402c7c34dd587acc976 Mon Sep 17 00:00:00 2001 From: Raz Date: Tue, 15 Oct 2024 22:01:37 +0200 Subject: [PATCH] fix bracket calling view update --- PadelClub/Views/Calling/BracketCallingView.swift | 7 ++++--- PadelClub/Views/Tournament/Screen/TournamentCallView.swift | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/PadelClub/Views/Calling/BracketCallingView.swift b/PadelClub/Views/Calling/BracketCallingView.swift index 2650d8f..bede32f 100644 --- a/PadelClub/Views/Calling/BracketCallingView.swift +++ b/PadelClub/Views/Calling/BracketCallingView.swift @@ -90,19 +90,20 @@ struct BracketCallingView: View { ForEach(filteredRounds()) { round in let seeds = seeds(forRoundIndex: round.index) - let callSeeds = seeds.filter({ tournament.isStartDateIsDifferentThanCallDate($0) == false }) + let startDate = round.startDate ?? round.playedMatches().first?.startDate + let callSeeds = seeds.filter({ $0.callDate == startDate }) if seeds.isEmpty == false { Section { NavigationLink { _roundView(round: round, seeds: seeds) .environment(tournament) } label: { - CallView.CallStatusView(count: callSeeds.count, total: seeds.count, startDate: round.playedMatches().first?.startDate) + CallView.CallStatusView(count: callSeeds.count, total: seeds.count, startDate: startDate) } } header: { Text(round.roundTitle()) } footer: { - if let startDate = round.startDate ?? round.playedMatches().first?.startDate { + if let startDate { CallView(teams: seeds, callDate: startDate, matchFormat: round.matchFormat, roundLabel: round.roundTitle()) } } diff --git a/PadelClub/Views/Tournament/Screen/TournamentCallView.swift b/PadelClub/Views/Tournament/Screen/TournamentCallView.swift index 422d16e..57785fe 100644 --- a/PadelClub/Views/Tournament/Screen/TournamentCallView.swift +++ b/PadelClub/Views/Tournament/Screen/TournamentCallView.swift @@ -53,7 +53,7 @@ enum CallDestination: Identifiable, Selectable, Equatable { let allSeedCalled = tournament.seeds().filter({ tournament.isStartDateIsDifferentThanCallDate($0) || $0.callDate == nil }) return allSeedCalled.count case .brackets(let tournament): - let availableSeeds = tournament.availableSeeds().filter({ tournament.isStartDateIsDifferentThanCallDate($0) || $0.callDate == nil }) + let availableSeeds = tournament.availableSeeds().filter({ $0.callDate == nil }) return availableSeeds.count case .groupStages(let tournament): let allSeedCalled = tournament.groupStageTeams().filter({ tournament.isStartDateIsDifferentThanCallDate($0) || $0.callDate == nil }) @@ -74,7 +74,7 @@ enum CallDestination: Identifiable, Selectable, Equatable { let allSeedCalled = tournament.seeds().allSatisfy({ tournament.isStartDateIsDifferentThanCallDate($0) == false }) return allSeedCalled ? .checkmark : nil case .brackets(let tournament): - let availableSeeds = tournament.availableSeeds().allSatisfy({ tournament.isStartDateIsDifferentThanCallDate($0) == false }) + let availableSeeds = tournament.availableSeeds().allSatisfy({ $0.called() }) return availableSeeds ? .checkmark : nil case .groupStages(let tournament): let allSeedCalled = tournament.groupStageTeams().allSatisfy({ tournament.isStartDateIsDifferentThanCallDate($0) == false }) @@ -95,7 +95,7 @@ struct TournamentCallView: View { var destinations = [CallDestination]() let groupStageTeams = tournament.groupStageTeams() let seededTeams = tournament.seededTeams() - if groupStageTeams.isEmpty == false { + if groupStageTeams.isEmpty == false && tournament.groupStageCount > 0 { destinations.append(.groupStages(tournament)) self._selectedDestination = State(wrappedValue: .groupStages(tournament)) }