fix finishing tournament when only groupstages

sync2
Raz 1 year ago
parent b335aebcae
commit 46032d767b
  1. 9
      PadelClub/Data/GroupStage.swift
  2. 7
      PadelClub/Data/Tournament.swift
  3. 2
      PadelClub/Views/Club/ClubSearchView.swift
  4. 27
      PadelClub/Views/Navigation/Toolbox/ToolboxView.swift

@ -145,6 +145,15 @@ final class GroupStage: ModelObject, Storable {
} catch {
Logger.error(error)
}
if tournament.groupStagesAreOver(), tournament.groupStageLoserBracketAreOver(), tournament.rounds().isEmpty {
tournament.endDate = Date()
do {
try DataStore.shared.tournaments.addOrUpdate(instance: tournament)
} catch {
Logger.error(error)
}
}
}
}

@ -1484,6 +1484,13 @@ defer {
//return qualifiedTeams().count == qualifiedFromGroupStage() + groupStageAdditionalQualified
}
func groupStageLoserBracketAreOver() -> Bool {
guard let groupStageLoserBracket = groupStageLoserBracket() else {
return true
}
return groupStageLoserBracket.hasEnded()
}
fileprivate func _paymentMethodMessage() -> String? {
return DataStore.shared.user.summonsAvailablePaymentMethods ?? ContactType.defaultAvailablePaymentMethods
}

@ -385,7 +385,7 @@ struct ClubSearchView: View {
LabeledContent {
Text(club.distance(from: locationManager.location))
} label: {
Text(club.nom)
Text(club.nom).lineLimit(1)
Text(club.ville).font(.caption)
}
}

@ -7,6 +7,7 @@
import SwiftUI
import LeStorage
import Zip
struct ToolboxView: View {
@EnvironmentObject var dataStore: DataStore
@ -210,14 +211,38 @@ struct ToolboxView: View {
}
.navigationTitle(TabDestination.toolbox.title)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
ToolbarItem(placement: .topBarLeading) {
Link(destination: URLs.appStore.url) {
Text("v\(PadelClubApp.appVersion)")
}
}
ToolbarItem(placement: .topBarTrailing) {
Menu {
ShareLink(item: URLs.appStore.url) {
Label("Lien AppStore", systemImage: "link")
}
if let zip = _getZip() {
ShareLink(item: zip) {
Label("Mes données", systemImage: "server.rack")
}
}
} label: {
Label("Partagez", systemImage: "square.and.arrow.up").labelStyle(.iconOnly)
}
}
}
}
}
private func _getZip() -> URL? {
do {
let filePath = try Club.storageDirectoryPath()
return try Zip.quickZipFiles([filePath], fileName: "backup") // Zip
} catch {
Logger.error(error)
return nil
}
}
}
//#Preview {

Loading…
Cancel
Save