fix bracket calling view update

paca_championship
Raz 1 year ago
parent 93036ecdd5
commit 138551c32a
  1. 7
      PadelClub/Views/Calling/BracketCallingView.swift
  2. 6
      PadelClub/Views/Tournament/Screen/TournamentCallView.swift

@ -90,19 +90,20 @@ struct BracketCallingView: View {
ForEach(filteredRounds()) { round in ForEach(filteredRounds()) { round in
let seeds = seeds(forRoundIndex: round.index) 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 { if seeds.isEmpty == false {
Section { Section {
NavigationLink { NavigationLink {
_roundView(round: round, seeds: seeds) _roundView(round: round, seeds: seeds)
.environment(tournament) .environment(tournament)
} label: { } 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: { } header: {
Text(round.roundTitle()) Text(round.roundTitle())
} footer: { } footer: {
if let startDate = round.startDate ?? round.playedMatches().first?.startDate { if let startDate {
CallView(teams: seeds, callDate: startDate, matchFormat: round.matchFormat, roundLabel: round.roundTitle()) CallView(teams: seeds, callDate: startDate, matchFormat: round.matchFormat, roundLabel: round.roundTitle())
} }
} }

@ -53,7 +53,7 @@ enum CallDestination: Identifiable, Selectable, Equatable {
let allSeedCalled = tournament.seeds().filter({ tournament.isStartDateIsDifferentThanCallDate($0) || $0.callDate == nil }) let allSeedCalled = tournament.seeds().filter({ tournament.isStartDateIsDifferentThanCallDate($0) || $0.callDate == nil })
return allSeedCalled.count return allSeedCalled.count
case .brackets(let tournament): 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 return availableSeeds.count
case .groupStages(let tournament): case .groupStages(let tournament):
let allSeedCalled = tournament.groupStageTeams().filter({ tournament.isStartDateIsDifferentThanCallDate($0) || $0.callDate == nil }) 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 }) let allSeedCalled = tournament.seeds().allSatisfy({ tournament.isStartDateIsDifferentThanCallDate($0) == false })
return allSeedCalled ? .checkmark : nil return allSeedCalled ? .checkmark : nil
case .brackets(let tournament): case .brackets(let tournament):
let availableSeeds = tournament.availableSeeds().allSatisfy({ tournament.isStartDateIsDifferentThanCallDate($0) == false }) let availableSeeds = tournament.availableSeeds().allSatisfy({ $0.called() })
return availableSeeds ? .checkmark : nil return availableSeeds ? .checkmark : nil
case .groupStages(let tournament): case .groupStages(let tournament):
let allSeedCalled = tournament.groupStageTeams().allSatisfy({ tournament.isStartDateIsDifferentThanCallDate($0) == false }) let allSeedCalled = tournament.groupStageTeams().allSatisfy({ tournament.isStartDateIsDifferentThanCallDate($0) == false })
@ -95,7 +95,7 @@ struct TournamentCallView: View {
var destinations = [CallDestination]() var destinations = [CallDestination]()
let groupStageTeams = tournament.groupStageTeams() let groupStageTeams = tournament.groupStageTeams()
let seededTeams = tournament.seededTeams() let seededTeams = tournament.seededTeams()
if groupStageTeams.isEmpty == false { if groupStageTeams.isEmpty == false && tournament.groupStageCount > 0 {
destinations.append(.groupStages(tournament)) destinations.append(.groupStages(tournament))
self._selectedDestination = State(wrappedValue: .groupStages(tournament)) self._selectedDestination = State(wrappedValue: .groupStages(tournament))
} }

Loading…
Cancel
Save