diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 42b5196..24c98c6 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -1959,6 +1959,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; diff --git a/PadelClub/Utils/Patcher.swift b/PadelClub/Utils/Patcher.swift index 0b6368c..66a71ee 100644 --- a/PadelClub/Utils/Patcher.swift +++ b/PadelClub/Utils/Patcher.swift @@ -15,6 +15,7 @@ enum PatchError: Error { enum Patch: String, CaseIterable { case alexisLeDu case importDataFromDevToProd + case fixMissingMatches var id: String { return "padelclub.app.patch.\(self.rawValue)" @@ -45,6 +46,7 @@ class Patcher { switch patch { case .alexisLeDu: self._patchAlexisLeDu() case .importDataFromDevToProd: try self._importDataFromDev() + case .fixMissingMatches: self._patchMissingMatches() } } @@ -115,5 +117,48 @@ class Patcher { } } + + fileprivate static func _patchMissingMatches() { + + guard let url = StoreCenter.main.synchronizationApiURL else { + return + } + guard url == "https://padelclub.app/roads/" else { + return + } + let services = Services(url: url) + + for tournament in DataStore.shared.tournaments { + + let store = tournament.tournamentStore + let identifier = StoreIdentifier(value: tournament.id, parameterName: "tournament") + + Task { + + do { + // if nothing is online we upload the data + let matches: [Match] = try await services.get(identifier: identifier) + if matches.isEmpty { + store.matches.insertAllIntoCurrentService() + } + + let playerRegistrations: [PlayerRegistration] = try await services.get(identifier: identifier) + if playerRegistrations.isEmpty { + store.playerRegistrations.insertAllIntoCurrentService() + } + + let teamScores: [TeamScore] = try await services.get(identifier: identifier) + if teamScores.isEmpty { + store.teamScores.insertAllIntoCurrentService() + } + + } catch { + Logger.error(error) + } + + } + } + + } } diff --git a/PadelClub/ViewModel/SeedInterval.swift b/PadelClub/ViewModel/SeedInterval.swift index 65641a3..01e7519 100644 --- a/PadelClub/ViewModel/SeedInterval.swift +++ b/PadelClub/ViewModel/SeedInterval.swift @@ -59,7 +59,7 @@ struct SeedInterval: Hashable, Comparable { } func localizedInterval(_ displayStyle: DisplayStyle = .wide) -> String { - if dimension < 2 { + if dimension < 3 { return "#\(first) / #\(last)" } else { return "#\(first) à #\(last)" diff --git a/PadelClub/Views/Calling/TeamsCallingView.swift b/PadelClub/Views/Calling/TeamsCallingView.swift index 4575acb..86e4d23 100644 --- a/PadelClub/Views/Calling/TeamsCallingView.swift +++ b/PadelClub/Views/Calling/TeamsCallingView.swift @@ -32,7 +32,7 @@ struct TeamsCallingView: View { } } .buttonStyle(.plain) - .listRowView(isActive: team.didConfirmSummon(), color: .green, hideColorVariation: true) + .listRowView(isActive: team.confirmed(), color: .green, hideColorVariation: true) } } } @@ -52,7 +52,7 @@ struct TeamsCallingView: View { Logger.error(error) } } label: { - if team.didConfirmSummon() { + if team.confirmed() { Label("Confirmation reçue", systemImage: "checkmark.circle.fill").foregroundStyle(.green) } else { Label("Confirmation reçue", systemImage: "circle").foregroundStyle(.logoRed) diff --git a/PadelClub/Views/Team/EditingTeamView.swift b/PadelClub/Views/Team/EditingTeamView.swift index d3ac838..e8b2450 100644 --- a/PadelClub/Views/Team/EditingTeamView.swift +++ b/PadelClub/Views/Team/EditingTeamView.swift @@ -77,19 +77,9 @@ struct EditingTeamView: View { Text("Convocation") } - Button { - team.toggleSummonConfirmation() - do { - try self.tournament.tournamentStore.teamRegistrations.addOrUpdate(instance: team) - } catch { - Logger.error(error) - } - } label: { - if team.didConfirmSummon() { - Label("Confirmation reçue", systemImage: "checkmark.circle.fill").foregroundStyle(.green) - } else { - Label("Confirmation reçue", systemImage: "circle").foregroundStyle(.logoRed) - } + Toggle(isOn: confirmationReceived) { + Text("Confirmation reçue") + Text("L'équipe vous a confirmé leur convocation") } } else { @@ -273,6 +263,19 @@ struct EditingTeamView: View { .navigationBarTitleDisplayMode(.inline) } + private var confirmationReceived: Binding { + Binding { + team.confirmed() + } set: { confirmed in + team.confirmationDate = confirmed ? Date() : nil + do { + try tournamentStore.teamRegistrations.addOrUpdate(instance: team) + } catch { + Logger.error(error) + } + } + } + private var hasArrived: Binding { Binding { team.unsortedPlayers().allSatisfy({ $0.hasArrived }) diff --git a/PadelClub/Views/Tournament/Screen/BroadcastView.swift b/PadelClub/Views/Tournament/Screen/BroadcastView.swift index 836197d..ba1d37b 100644 --- a/PadelClub/Views/Tournament/Screen/BroadcastView.swift +++ b/PadelClub/Views/Tournament/Screen/BroadcastView.swift @@ -113,10 +113,7 @@ struct BroadcastView: View { .foregroundStyle(.logoRed) } } - #if DEBUG - #else - .disabled((tournament.isPrivate && Guard.main.purchasedTransactions.isEmpty)) - #endif + .disabled(_disablePrivateToggle()) } footer: { let verb : String = tournament.isPrivate ? "est" : "sera" let footerString = " Le tournoi \(verb) masqué sur le site [Padel Club](\(URLs.main.rawValue))" @@ -326,6 +323,14 @@ struct BroadcastView: View { } } + private func _disablePrivateToggle() -> Bool { + #if DEBUG + return false + #else + return (tournament.isPrivate && Guard.main.purchasedTransactions.isEmpty) + #endif + } + private func _save() { do { if [tournament.publishTeams, tournament.publishSummons, tournament.publishBrackets, tournament.publishGroupStages].anySatisfy({ $0 == true }) {