diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index aea4381..19567ee 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -1890,7 +1890,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 79; + CURRENT_PROJECT_VERSION = 80; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; @@ -1933,7 +1933,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 79; + CURRENT_PROJECT_VERSION = 80; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; diff --git a/PadelClub/Views/Match/MatchSetupView.swift b/PadelClub/Views/Match/MatchSetupView.swift index 66a9bdf..52e1418 100644 --- a/PadelClub/Views/Match/MatchSetupView.swift +++ b/PadelClub/Views/Match/MatchSetupView.swift @@ -102,6 +102,7 @@ struct MatchSetupView: View { } }) if let tournament = match.currentTournament() { + let availableQualifiedTeams = tournament.availableQualifiedTeams() let availableSeedGroups = tournament.availableSeedGroups() Text("ou") Menu { @@ -119,6 +120,27 @@ struct MatchSetupView: View { Label("Repêchage", systemImage: "dice") } } + + if availableQualifiedTeams.isEmpty == false { + Button { + if let randomTeam = availableQualifiedTeams.randomElement() { + randomTeam.setSeedPosition(inSpot: match, slot: teamPosition, opposingSeeding: false) + do { + try tournamentStore.matches.addOrUpdate(instance: match) + } catch { + Logger.error(error) + } + do { + try tournamentStore.teamRegistrations.addOrUpdate(instance: randomTeam) + } catch { + Logger.error(error) + } + } + } label: { + Label("Qualifié sortant", systemImage: "dice") + } + } + ForEach(availableSeedGroups, id: \.self) { seedGroup in Button { if let randomTeam = tournament.randomSeed(fromSeedGroup: seedGroup) { @@ -142,7 +164,7 @@ struct MatchSetupView: View { Text("Tirer au sort").tag(nil as SeedInterval?) .underline() } - .disabled(availableSeedGroups.isEmpty && walkOutSpot == false) + .disabled(availableSeedGroups.isEmpty && walkOutSpot == false && availableQualifiedTeams.isEmpty) Spacer() if match.isSeedLocked(atTeamPosition: teamPosition) { Button { diff --git a/PadelClub/Views/Tournament/Screen/Components/TournamentMatchFormatsSettingsView.swift b/PadelClub/Views/Tournament/Screen/Components/TournamentMatchFormatsSettingsView.swift index d530b9b..ebf4bde 100644 --- a/PadelClub/Views/Tournament/Screen/Components/TournamentMatchFormatsSettingsView.swift +++ b/PadelClub/Views/Tournament/Screen/Components/TournamentMatchFormatsSettingsView.swift @@ -76,10 +76,10 @@ struct TournamentMatchFormatsSettingsView: View { private func _confirmOrSave() { switch tournament.state() { - case .build: - confirmUpdate = true + case .initial: + confirmUpdate = false default: - break + confirmUpdate = true } }