Merge branch 'main'

#Conflicts:
#	PadelClub.xcodeproj/project.pbxproj
#	PadelClub/Data/TeamRegistration.swift
#	PadelClub/ViewModel/SeedInterval.swift
#	PadelClub/Views/Calling/TeamsCallingView.swift
#	PadelClub/Views/Team/EditingTeamView.swift
#	PadelClub/Views/Tournament/Screen/BroadcastView.swift
xcode16
Raz 1 year ago
commit bf1f934704
  1. 1
      PadelClub.xcodeproj/project.pbxproj
  2. 45
      PadelClub/Utils/Patcher.swift
  3. 2
      PadelClub/ViewModel/SeedInterval.swift
  4. 4
      PadelClub/Views/Calling/TeamsCallingView.swift
  5. 29
      PadelClub/Views/Team/EditingTeamView.swift
  6. 13
      PadelClub/Views/Tournament/Screen/BroadcastView.swift

@ -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;

@ -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)
}
}
}
}
}

@ -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)"

@ -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)

@ -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<Bool> {
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<Bool> {
Binding {
team.unsortedPlayers().allSatisfy({ $0.hasArrived })

@ -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 }) {

Loading…
Cancel
Save