rename debug options

club_update
Razmig Sarkissian 1 year ago
parent 03069d9505
commit 035e1ac7cf
  1. 4
      PadelClub/Data/DataStore.swift
  2. 8
      PadelClub/Data/GroupStage.swift
  3. 8
      PadelClub/Data/Match.swift
  4. 24
      PadelClub/Data/Round.swift
  5. 16
      PadelClub/Data/Tournament.swift
  6. 2
      PadelClub/Data/TournamentStore.swift
  7. 2
      PadelClub/Views/Calling/CallSettingsView.swift
  8. 28
      PadelClub/Views/Calling/CallView.swift
  9. 22
      PadelClub/Views/Calling/SendToAllView.swift
  10. 2
      PadelClub/Views/Club/ClubsView.swift
  11. 24
      PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift
  12. 2
      PadelClub/Views/GroupStage/GroupStagesSettingsView.swift
  13. 22
      PadelClub/Views/Match/MatchDetailView.swift
  14. 2
      PadelClub/Views/Navigation/Agenda/EventListView.swift
  15. 2
      PadelClub/Views/Navigation/Ongoing/OngoingView.swift
  16. 2
      PadelClub/Views/Navigation/Toolbox/ToolboxView.swift
  17. 2
      PadelClub/Views/Navigation/Umpire/UmpireView.swift
  18. 2
      PadelClub/Views/Round/LoserRoundView.swift
  19. 10
      PadelClub/Views/Round/LoserRoundsView.swift
  20. 2
      PadelClub/Views/Round/RoundView.swift
  21. 22
      PadelClub/Views/Shared/SupportButtonView.swift
  22. 31
      PadelClub/Views/Team/EditingTeamView.swift
  23. 2
      PadelClub/Views/Tournament/Screen/Components/TournamentStatusView.swift
  24. 33
      PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift
  25. 2
      PadelClub/Views/Tournament/Subscription/Guard.swift
  26. 2
      PadelClub/Views/Tournament/Subscription/StoreItem.swift
  27. 2
      PadelClub/Views/Tournament/TournamentBuildView.swift
  28. 2
      PadelClub/Views/Tournament/TournamentView.swift
  29. 2
      PadelClub/Views/User/LoginView.swift

@ -54,7 +54,7 @@ class DataStore: ObservableObject {
let serverURL: String = URLs.api.rawValue let serverURL: String = URLs.api.rawValue
StoreCenter.main.blackListUserName("apple-test") StoreCenter.main.blackListUserName("apple-test")
#if DEBUG #if _DEBUG_OPTIONS
if let server = PListReader.readString(plist: "local", key: "server") { if let server = PListReader.readString(plist: "local", key: "server") {
StoreCenter.main.synchronizationApiURL = server StoreCenter.main.synchronizationApiURL = server
} else { } else {
@ -70,7 +70,7 @@ class DataStore: ObservableObject {
_ = Guard.main // init _ = Guard.main // init
#if DEBUG #if _DEBUG_OPTIONS
if let sync = PListReader.readBool(plist: "local", key: "synchronized") { if let sync = PListReader.readBool(plist: "local", key: "synchronized") {
synchronized = sync synchronized = sync
} }

@ -201,7 +201,7 @@ final class GroupStage: ModelObject, Storable {
} }
func availableToStart(playedMatches: [Match], in runningMatches: [Match]) -> [Match] { func availableToStart(playedMatches: [Match], in runningMatches: [Match]) -> [Match] {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -212,7 +212,7 @@ final class GroupStage: ModelObject, Storable {
} }
func runningMatches(playedMatches: [Match]) -> [Match] { func runningMatches(playedMatches: [Match]) -> [Match] {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -223,7 +223,7 @@ final class GroupStage: ModelObject, Storable {
} }
func readyMatches(playedMatches: [Match]) -> [Match] { func readyMatches(playedMatches: [Match]) -> [Match] {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -234,7 +234,7 @@ final class GroupStage: ModelObject, Storable {
} }
func finishedMatches(playedMatches: [Match]) -> [Match] { func finishedMatches(playedMatches: [Match]) -> [Match] {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)

@ -90,7 +90,7 @@ final class Match: ModelObject, Storable {
} }
func indexInRound(in matches: [Match]? = nil) -> Int { func indexInRound(in matches: [Match]? = nil) -> Int {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -114,7 +114,7 @@ defer {
} }
func matchTitle(_ displayStyle: DisplayStyle = .wide, inMatches matches: [Match]? = nil) -> String { func matchTitle(_ displayStyle: DisplayStyle = .wide, inMatches matches: [Match]? = nil) -> String {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -687,7 +687,7 @@ defer {
} }
func teams() -> [TeamRegistration] { func teams() -> [TeamRegistration] {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -746,7 +746,7 @@ defer {
} }
func team(_ team: TeamPosition) -> TeamRegistration? { func team(_ team: TeamPosition) -> TeamRegistration? {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)

@ -157,7 +157,7 @@ final class Round: ModelObject, Storable {
} }
func roundProjectedTeam(_ team: TeamPosition, inMatch match: Match, previousRound: Round?) -> TeamRegistration? { func roundProjectedTeam(_ team: TeamPosition, inMatch match: Match, previousRound: Round?) -> TeamRegistration? {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -199,7 +199,7 @@ defer {
} }
func upperBracketTopMatch(ofMatchIndex matchIndex: Int, previousRound: Round?) -> Match? { func upperBracketTopMatch(ofMatchIndex matchIndex: Int, previousRound: Round?) -> Match? {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -214,7 +214,7 @@ defer {
} }
func upperBracketBottomMatch(ofMatchIndex matchIndex: Int, previousRound: Round?) -> Match? { func upperBracketBottomMatch(ofMatchIndex matchIndex: Int, previousRound: Round?) -> Match? {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -231,7 +231,7 @@ defer {
func topPreviousRoundMatch(ofMatch match: Match, previousRound: Round?) -> Match? { func topPreviousRoundMatch(ofMatch match: Match, previousRound: Round?) -> Match? {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -247,7 +247,7 @@ defer {
} }
func bottomPreviousRoundMatch(ofMatch match: Match, previousRound: Round?) -> Match? { func bottomPreviousRoundMatch(ofMatch match: Match, previousRound: Round?) -> Match? {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -274,7 +274,7 @@ defer {
} }
// func displayableMatches() -> [Match] { // func displayableMatches() -> [Match] {
//#if DEBUG_TIME //DEBUGING TIME //#if _DEBUG_TIME //DEBUGING TIME
// let start = Date() // let start = Date()
// defer { // defer {
// let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) // let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -300,7 +300,7 @@ defer {
} }
func previousRound() -> Round? { func previousRound() -> Round? {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -428,7 +428,7 @@ defer {
func correspondingLoserRoundTitle(_ displayStyle: DisplayStyle = .wide) -> String { func correspondingLoserRoundTitle(_ displayStyle: DisplayStyle = .wide) -> String {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -469,7 +469,7 @@ defer {
} }
func seedInterval(initialMode: Bool = false) -> SeedInterval? { func seedInterval(initialMode: Bool = false) -> SeedInterval? {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -540,7 +540,7 @@ defer {
func loserRounds() -> [Round] { func loserRounds() -> [Round] {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -722,7 +722,7 @@ extension Round: Selectable, Equatable {
} }
func badgeValue() -> Int? { func badgeValue() -> Int? {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -743,7 +743,7 @@ extension Round: Selectable, Equatable {
} }
func badgeImage() -> Badge? { func badgeImage() -> Badge? {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)

@ -508,7 +508,7 @@ final class Tournament : ModelObject, Storable {
} }
func courtUsed() -> [Int] { func courtUsed() -> [Int] {
#if DEBUG //DEBUGING TIME #if _DEBUG_OPTIONS //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -592,7 +592,7 @@ defer {
} }
func availableSeeds() -> [TeamRegistration] { func availableSeeds() -> [TeamRegistration] {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -815,7 +815,7 @@ defer {
func selectedSortedTeams() -> [TeamRegistration] { func selectedSortedTeams() -> [TeamRegistration] {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -1105,7 +1105,7 @@ defer {
} }
func availableToStart(_ allMatches: [Match], in runningMatches: [Match]) -> [Match] { func availableToStart(_ allMatches: [Match], in runningMatches: [Match]) -> [Match] {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -1116,7 +1116,7 @@ defer {
} }
func runningMatches(_ allMatches: [Match]) -> [Match] { func runningMatches(_ allMatches: [Match]) -> [Match] {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -1127,7 +1127,7 @@ defer {
} }
func readyMatches(_ allMatches: [Match]) -> [Match] { func readyMatches(_ allMatches: [Match]) -> [Match] {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -1138,7 +1138,7 @@ defer {
} }
func finishedMatches(_ allMatches: [Match], limit: Int? = nil) -> [Match] { func finishedMatches(_ allMatches: [Match], limit: Int? = nil) -> [Match] {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -1397,7 +1397,7 @@ defer {
func availableQualifiedTeams() -> [TeamRegistration] { func availableQualifiedTeams() -> [TeamRegistration] {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)

@ -38,7 +38,7 @@ class TournamentStore: Store, ObservableObject {
var synchronized: Bool = true var synchronized: Bool = true
let indexed: Bool = true let indexed: Bool = true
#if DEBUG #if _DEBUG_OPTIONS
if let sync = PListReader.readBool(plist: "local", key: "synchronized") { if let sync = PListReader.readBool(plist: "local", key: "synchronized") {
synchronized = sync synchronized = sync
} }

@ -56,7 +56,7 @@ struct CallSettingsView: View {
} }
} }
// #if DEBUG // #if _DEBUG_OPTIONS
Section { Section {
RowButtonView("Retirer toutes les convocations", role: .destructive) { RowButtonView("Retirer toutes les convocations", role: .destructive) {
let teams = tournament.unsortedTeams() let teams = tournament.unsortedTeams()

@ -125,7 +125,7 @@ struct CallView: View {
Button("OK") { Button("OK") {
} }
} message: { } message: {
Text(self._failureMessage()) Text(_networkErrorMessage)
} }
.sheet(item: $contactType) { contactType in .sheet(item: $contactType) { contactType in
Group { Group {
@ -189,14 +189,6 @@ struct CallView: View {
}) })
} }
fileprivate func _failureMessage() -> String {
return [networkMonitor.connected == false ? "L'appareil n'est pas connecté à internet." as String? : nil,
sentError == .mailNotSent ? "Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer." as String? : nil,
(sentError == .messageFailed || sentError == .messageNotSent) ? "Le SMS n'a pas été envoyé" as String? : nil,
sentError == .mailFailed ? "Le mail n'a pas été envoyé" as String? : nil]
.compacted().joined(separator: "\n")
}
@ViewBuilder @ViewBuilder
private func _summonMenu(byMessage: Bool) -> some View { private func _summonMenu(byMessage: Bool) -> some View {
if self.reSummon { if self.reSummon {
@ -267,4 +259,22 @@ struct CallView: View {
tournamentBuild: nil) tournamentBuild: nil)
} }
private var _networkErrorMessage: String {
var errors: [String] = []
if networkMonitor.connected == false {
errors.append("L'appareil n'est pas connecté à internet.")
}
if sentError == .mailNotSent {
errors.append("Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer.")
}
if (sentError == .messageFailed || sentError == .messageNotSent) {
errors.append("Le SMS n'a pas été envoyé")
}
if sentError == .mailFailed {
errors.append("Le mail n'a pas été envoyé")
}
return errors.joined(separator: "\n")
}
} }

@ -122,8 +122,7 @@ struct SendToAllView: View {
Button("OK") { Button("OK") {
} }
} message: { } message: {
let message = [networkMonitor.connected == false ? "L'appareil n'est pas connecté à internet." as String? : nil, sentError == .mailNotSent ? "Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer." as String? : nil, (sentError == .messageFailed || sentError == .messageNotSent) ? "Le SMS n'a pas été envoyé" as String? : nil, sentError == .mailFailed ? "Le mail n'a pas été envoyé" as String? : nil].compacted().joined(separator: "\n") Text(_networkErrorMessage)
Text(message)
} }
.sheet(item: $contactType) { contactType in .sheet(item: $contactType) { contactType in
Group { Group {
@ -253,6 +252,25 @@ struct SendToAllView: View {
self.showSubscriptionView = true self.showSubscriptionView = true
} }
} }
private var _networkErrorMessage: String {
var errors: [String] = []
if networkMonitor.connected == false {
errors.append("L'appareil n'est pas connecté à internet.")
}
if sentError == .mailNotSent {
errors.append("Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer.")
}
if (sentError == .messageFailed || sentError == .messageNotSent) {
errors.append("Le SMS n'a pas été envoyé")
}
if sentError == .mailFailed {
errors.append("Le mail n'a pas été envoyé")
}
return errors.joined(separator: "\n")
}
} }
//#Preview { //#Preview {

@ -27,7 +27,7 @@ struct ClubsView: View {
var body: some View { var body: some View {
List { List {
#if DEBUG #if _DEBUG_OPTIONS
Section { Section {
RowButtonView("Delete unexisted clubs", action: { RowButtonView("Delete unexisted clubs", action: {
let ids = dataStore.user.clubs let ids = dataStore.user.clubs

@ -95,7 +95,7 @@ struct GroupStageTeamView: View {
Button("OK") { Button("OK") {
} }
} message: { } message: {
Text(_getErrorMessage()) Text(_networkErrorMessage)
} }
.sheet(item: $contactType) { contactType in .sheet(item: $contactType) { contactType in
Group { Group {
@ -152,14 +152,22 @@ struct GroupStageTeamView: View {
.navigationTitle("Détail de l'équipe") .navigationTitle("Détail de l'équipe")
} }
private func _getErrorMessage() -> String { private var _networkErrorMessage: String {
let m1 : String? = (networkMonitor.connected == false ? "L'appareil n'est pas connecté à internet." : nil) var errors: [String] = []
let m2 : String? = (sentError == .mailNotSent ? "Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer." : nil)
let m3 : String? = ((sentError == .messageFailed || sentError == .messageNotSent) ? "Le SMS n'a pas été envoyé" : nil)
let m4 : String? = (sentError == .mailFailed ? "Le mail n'a pas été envoyé" : nil)
let message : String = [m1, m2, m3, m4].compacted().joined(separator: "\n") if networkMonitor.connected == false {
return message errors.append("L'appareil n'est pas connecté à internet.")
}
if sentError == .mailNotSent {
errors.append("Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer.")
}
if (sentError == .messageFailed || sentError == .messageNotSent) {
errors.append("Le SMS n'a pas été envoyé")
}
if sentError == .mailFailed {
errors.append("Le mail n'a pas été envoyé")
}
return errors.joined(separator: "\n")
} }
private func _save() { private func _save() {

@ -73,7 +73,7 @@ struct GroupStagesSettingsView: View {
} }
} }
#if DEBUG #if _DEBUG_OPTIONS
Section { Section {
RowButtonView("delete all group stages") { RowButtonView("delete all group stages") {
tournament.deleteGroupStages() tournament.deleteGroupStages()

@ -197,8 +197,7 @@ struct MatchDetailView: View {
Button("OK") { Button("OK") {
} }
} message: { } message: {
let message = [networkMonitor.connected == false ? "L'appareil n'est pas connecté à internet." as String? : nil, sentError == .mailNotSent ? "Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer." as String? : nil, (sentError == .messageFailed || sentError == .messageNotSent) ? "Le SMS n'a pas été envoyé" as String? : nil, sentError == .mailFailed ? "Le mail n'a pas été envoyé" as String? : nil].compacted().joined(separator: "\n") Text(_networkErrorMessage)
Text(message)
} }
.sheet(item: $contactType) { contactType in .sheet(item: $contactType) { contactType in
Group { Group {
@ -508,6 +507,25 @@ struct MatchDetailView: View {
Logger.error(error) Logger.error(error)
} }
} }
private var _networkErrorMessage: String {
var errors: [String] = []
if networkMonitor.connected == false {
errors.append("L'appareil n'est pas connecté à internet.")
}
if sentError == .mailNotSent {
errors.append("Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer.")
}
if (sentError == .messageFailed || sentError == .messageNotSent) {
errors.append("Le SMS n'a pas été envoyé")
}
if sentError == .mailFailed {
errors.append("Le mail n'a pas été envoyé")
}
return errors.joined(separator: "\n")
}
} }
//#Preview { //#Preview {

@ -112,7 +112,7 @@ struct EventListView: View {
} }
} }
} }
#if DEBUG #if _DEBUG_OPTIONS
.swipeActions(edge: .trailing, allowsFullSwipe: true) { .swipeActions(edge: .trailing, allowsFullSwipe: true) {
Button(role: .destructive) { Button(role: .destructive) {
do { do {

@ -44,7 +44,7 @@ struct OngoingView: View {
} footer: { } footer: {
HStack { HStack {
Text(tournament.eventLabel()) Text(tournament.eventLabel())
#if DEBUG #if _DEBUG_OPTIONS
Spacer() Spacer()
FooterButtonView("copier l'id") { FooterButtonView("copier l'id") {
let pasteboard = UIPasteboard.general let pasteboard = UIPasteboard.general

@ -49,7 +49,7 @@ struct ToolboxView: View {
} }
#if DEBUG #if _DEBUG_OPTIONS
Section { Section {
NavigationLink("Settings") { NavigationLink("Settings") {

@ -145,7 +145,7 @@ struct UmpireView: View {
} }
.navigationTitle("Juge-Arbitre") .navigationTitle("Juge-Arbitre")
.toolbar { .toolbar {
#if DEBUG #if _DEBUG_OPTIONS
ToolbarItem(placement: .topBarTrailing) { ToolbarItem(placement: .topBarTrailing) {
if StoreCenter.main.collectionsCanSynchronize { if StoreCenter.main.collectionsCanSynchronize {
Image(systemName: "checkmark.icloud") Image(systemName: "checkmark.icloud")

@ -15,7 +15,7 @@ struct LoserRoundView: View {
let loserBracket: LoserRound let loserBracket: LoserRound
private func _roundDisabled() -> Bool { private func _roundDisabled() -> Bool {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)

@ -42,7 +42,7 @@ extension UpperRound: Equatable {
} }
func badgeValue() -> Int? { func badgeValue() -> Int? {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -57,7 +57,7 @@ extension UpperRound: Equatable {
} }
func badgeImage() -> Badge? { func badgeImage() -> Badge? {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -85,7 +85,7 @@ struct LoserRound: Identifiable, Selectable {
} }
var shouldBeDisplayed: Bool { var shouldBeDisplayed: Bool {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -97,7 +97,7 @@ struct LoserRound: Identifiable, Selectable {
} }
static func updateDestinations(fromLoserRounds loserRounds: [Round], inUpperBracketRound upperBracketRound: Round) -> [LoserRound] { static func updateDestinations(fromLoserRounds loserRounds: [Round], inUpperBracketRound upperBracketRound: Round) -> [LoserRound] {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -146,7 +146,7 @@ extension LoserRound: Equatable {
} }
func badgeImage() -> Badge? { func badgeImage() -> Badge? {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)

@ -254,7 +254,7 @@ struct RoundView: View {
} }
} }
#if DEBUG #if _DEBUG_OPTIONS
Spacer() Spacer()
Text(match.teamScores.count.formatted()) Text(match.teamScores.count.formatted())

@ -47,8 +47,7 @@ struct SupportButtonView: View {
Button("OK") { Button("OK") {
} }
} message: { } message: {
let message = [networkMonitor.connected == false ? "L'appareil n'est pas connecté à internet." as String? : nil, sentError == .mailNotSent ? "Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer." as String? : nil, (sentError == .messageFailed || sentError == .messageNotSent) ? "Le SMS n'a pas été envoyé" as String? : nil, sentError == .mailFailed ? "Le mail n'a pas été envoyé" as String? : nil].compacted().joined(separator: "\n") Text(_networkErrorMessage)
Text(message)
} }
.sheet(item: $zipFilePath) { zipFilePath in .sheet(item: $zipFilePath) { zipFilePath in
MailComposeView(recipients: ["support@padelclub.app"], bccRecipients: nil, body: _getBody(), subject: _getSubject(), attachmentURL: zipFilePath) { result in MailComposeView(recipients: ["support@padelclub.app"], bccRecipients: nil, body: _getBody(), subject: _getSubject(), attachmentURL: zipFilePath) { result in
@ -102,4 +101,23 @@ struct SupportButtonView: View {
Logger.error(error) Logger.error(error)
} }
} }
private var _networkErrorMessage: String {
var errors: [String] = []
if networkMonitor.connected == false {
errors.append("L'appareil n'est pas connecté à internet.")
}
if sentError == .mailNotSent {
errors.append("Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer.")
}
if (sentError == .messageFailed || sentError == .messageNotSent) {
errors.append("Le SMS n'a pas été envoyé")
}
if sentError == .mailFailed {
errors.append("Le mail n'a pas été envoyé")
}
return errors.joined(separator: "\n")
}
} }

@ -186,7 +186,7 @@ struct EditingTeamView: View {
Button("OK") { Button("OK") {
} }
} message: { } message: {
Text(_getErrorMessage()) Text(_networkErrorMessage)
} }
.sheet(item: $contactType) { contactType in .sheet(item: $contactType) { contactType in
Group { Group {
@ -257,16 +257,6 @@ struct EditingTeamView: View {
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
} }
private func _getErrorMessage() -> String {
let m1 : String? = (networkMonitor.connected == false ? "L'appareil n'est pas connecté à internet." : nil)
let m2 : String? = (sentError == .mailNotSent ? "Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer." : nil)
let m3 : String? = ((sentError == .messageFailed || sentError == .messageNotSent) ? "Le SMS n'a pas été envoyé" : nil)
let m4 : String? = (sentError == .mailFailed ? "Le mail n'a pas été envoyé" : nil)
let message : String = [m1, m2, m3, m4].compacted().joined(separator: "\n")
return message
}
private var hasArrived: Binding<Bool> { private var hasArrived: Binding<Bool> {
Binding { Binding {
team.unsortedPlayers().allSatisfy({ $0.hasArrived }) team.unsortedPlayers().allSatisfy({ $0.hasArrived })
@ -289,6 +279,25 @@ struct EditingTeamView: View {
Logger.error(error) Logger.error(error)
} }
} }
private var _networkErrorMessage: String {
var errors: [String] = []
if networkMonitor.connected == false {
errors.append("L'appareil n'est pas connecté à internet.")
}
if sentError == .mailNotSent {
errors.append("Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer.")
}
if (sentError == .messageFailed || sentError == .messageNotSent) {
errors.append("Le SMS n'a pas été envoyé")
}
if sentError == .mailFailed {
errors.append("Le mail n'a pas été envoyé")
}
return errors.joined(separator: "\n")
}
} }
//#Preview { //#Preview {

@ -17,7 +17,7 @@ struct TournamentStatusView: View {
var body: some View { var body: some View {
Form { Form {
#if DEBUG #if _DEBUG_OPTIONS
RowButtonView("debug: Un-delete le tournoi") { RowButtonView("debug: Un-delete le tournoi") {
tournament.endDate = nil tournament.endDate = nil
tournament.isDeleted.toggle() tournament.isDeleted.toggle()

@ -167,7 +167,7 @@ struct InscriptionManagerView: View {
} }
private func _setHash() { private func _setHash() {
#if DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
@ -242,7 +242,7 @@ struct InscriptionManagerView: View {
Button("OK") { Button("OK") {
} }
} message: { } message: {
Text(_getErrorMessage()) Text(_networkErrorMessage)
} }
.sheet(item: $contactType) { contactType in .sheet(item: $contactType) { contactType in
Group { Group {
@ -960,16 +960,6 @@ struct InscriptionManagerView: View {
} }
} }
private func _getErrorMessage() -> String {
let m1 : String? = (networkMonitor.connected == false ? "L'appareil n'est pas connecté à internet." : nil)
let m2 : String? = (sentError == .mailNotSent ? "Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer." : nil)
let m3 : String? = ((sentError == .messageFailed || sentError == .messageNotSent) ? "Le SMS n'a pas été envoyé" : nil)
let m4 : String? = (sentError == .mailFailed ? "Le mail n'a pas été envoyé" : nil)
let message : String = [m1, m2, m3, m4].compacted().joined(separator: "\n")
return message
}
private func _save() { private func _save() {
do { do {
try dataStore.tournaments.addOrUpdate(instance: tournament) try dataStore.tournaments.addOrUpdate(instance: tournament)
@ -977,6 +967,25 @@ struct InscriptionManagerView: View {
Logger.error(error) Logger.error(error)
} }
} }
private var _networkErrorMessage: String {
var errors: [String] = []
if networkMonitor.connected == false {
errors.append("L'appareil n'est pas connecté à internet.")
}
if sentError == .mailNotSent {
errors.append("Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer.")
}
if (sentError == .messageFailed || sentError == .messageNotSent) {
errors.append("Le SMS n'a pas été envoyé")
}
if sentError == .mailFailed {
errors.append("Le mail n'a pas été envoyé")
}
return errors.joined(separator: "\n")
}
} }
//#Preview { //#Preview {

@ -141,7 +141,7 @@ import LeStorage
var currentPlan: StoreItem? { var currentPlan: StoreItem? {
return .monthlyUnlimited return .monthlyUnlimited
// #if DEBUG // #if _DEBUG_OPTIONS
// return .monthlyUnlimited // return .monthlyUnlimited
// #else // #else
if let currentBestPlan = self.currentBestPlan, let plan = StoreItem(rawValue: currentBestPlan.productID) { if let currentBestPlan = self.currentBestPlan, let plan = StoreItem(rawValue: currentBestPlan.productID) {

@ -12,7 +12,7 @@ enum StoreItem: String, Identifiable, CaseIterable {
case fivePerMonth = "app.padelclub.tournament.subscription.five.per.month" case fivePerMonth = "app.padelclub.tournament.subscription.five.per.month"
case unit = "app.padelclub.tournament.unit" case unit = "app.padelclub.tournament.unit"
#if DEBUG #if _DEBUG_OPTIONS
static let five: Int = 2 static let five: Int = 2
#else #else
static let five: Int = 5 static let five: Int = 5

@ -92,7 +92,7 @@ struct TournamentBuildView: View {
Section { Section {
#if DEBUG #if _DEBUG_OPTIONS
NavigationLink(value: Screen.rankings) { NavigationLink(value: Screen.rankings) {
LabeledContent { LabeledContent {
if tournament.publishRankings == false { if tournament.publishRankings == false {

@ -154,7 +154,7 @@ struct TournamentView: View {
ToolbarItem(placement: .topBarTrailing) { ToolbarItem(placement: .topBarTrailing) {
Menu { Menu {
#if DEBUG #if _DEBUG_OPTIONS
Button { Button {
do { do {
try self.tournament.payIfNecessary() try self.tournament.payIfNecessary()

@ -182,7 +182,7 @@ struct LoginView: View {
} }
.navigationTitle("Connexion") .navigationTitle("Connexion")
.onAppear { .onAppear {
#if DEBUG #if _DEBUG_OPTIONS
if let username = PListReader.readString(plist: "local", key: "username") { if let username = PListReader.readString(plist: "local", key: "username") {
self.username = username self.username = username
} }

Loading…
Cancel
Save