|
|
|
|
@ -24,7 +24,6 @@ struct InscriptionManagerView: View { |
|
|
|
|
|
|
|
|
|
@EnvironmentObject var dataStore: DataStore |
|
|
|
|
|
|
|
|
|
@EnvironmentObject var networkMonitor: NetworkMonitor |
|
|
|
|
@Environment(\.dismiss) var dismiss |
|
|
|
|
|
|
|
|
|
var tournament: Tournament |
|
|
|
|
@ -45,9 +44,6 @@ struct InscriptionManagerView: View { |
|
|
|
|
@State private var filterMode: FilterMode = .all |
|
|
|
|
@State private var sortingMode: SortingMode = .teamWeight |
|
|
|
|
@State private var byDecreasingOrdering: Bool = false |
|
|
|
|
@State private var contactType: ContactType? = nil |
|
|
|
|
@State private var sentError: ContactManagerError? = nil |
|
|
|
|
@State private var showSubscriptionView: Bool = false |
|
|
|
|
@State private var confirmDuplicate: Bool = false |
|
|
|
|
@State private var presentAddTeamView: Bool = false |
|
|
|
|
@State private var compactMode: Bool = true |
|
|
|
|
@ -57,17 +53,6 @@ struct InscriptionManagerView: View { |
|
|
|
|
return self.tournament.tournamentStore |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var messageSentFailed: Binding<Bool> { |
|
|
|
|
Binding { |
|
|
|
|
sentError != nil |
|
|
|
|
} set: { newValue in |
|
|
|
|
if newValue == false { |
|
|
|
|
sentError = nil |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum SortingMode: Int, Identifiable, CaseIterable { |
|
|
|
|
var id: Int { self.rawValue } |
|
|
|
|
case registrationDate |
|
|
|
|
@ -238,61 +223,6 @@ struct InscriptionManagerView: View { |
|
|
|
|
.onDisappear { |
|
|
|
|
_handleHashDiff() |
|
|
|
|
} |
|
|
|
|
.alert("Un problème est survenu", isPresented: messageSentFailed) { |
|
|
|
|
Button("OK") { |
|
|
|
|
} |
|
|
|
|
} message: { |
|
|
|
|
Text(_networkErrorMessage) |
|
|
|
|
} |
|
|
|
|
.sheet(item: $contactType) { contactType in |
|
|
|
|
Group { |
|
|
|
|
switch contactType { |
|
|
|
|
case .message(_, let recipients, let body, _): |
|
|
|
|
if Guard.main.paymentForNewTournament() != nil { |
|
|
|
|
MessageComposeView(recipients: recipients, body: body) { result in |
|
|
|
|
switch result { |
|
|
|
|
case .cancelled: |
|
|
|
|
break |
|
|
|
|
case .failed: |
|
|
|
|
self.sentError = .messageFailed |
|
|
|
|
case .sent: |
|
|
|
|
if networkMonitor.connected == false { |
|
|
|
|
self.sentError = .messageNotSent |
|
|
|
|
} |
|
|
|
|
@unknown default: |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
SubscriptionView(isPresented: self.$showSubscriptionView, showLackOfPlanMessage: true) |
|
|
|
|
.environment(\.colorScheme, .light) |
|
|
|
|
} |
|
|
|
|
case .mail(_, let recipients, let bccRecipients, let body, let subject, _): |
|
|
|
|
if Guard.main.paymentForNewTournament() != nil { |
|
|
|
|
MailComposeView(recipients: recipients, bccRecipients: bccRecipients, body: body, subject: subject) { result in |
|
|
|
|
switch result { |
|
|
|
|
case .cancelled, .saved: |
|
|
|
|
self.contactType = nil |
|
|
|
|
case .failed: |
|
|
|
|
self.contactType = nil |
|
|
|
|
self.sentError = .mailFailed |
|
|
|
|
case .sent: |
|
|
|
|
if networkMonitor.connected == false { |
|
|
|
|
self.contactType = nil |
|
|
|
|
self.sentError = .mailNotSent |
|
|
|
|
} |
|
|
|
|
@unknown default: |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
SubscriptionView(isPresented: self.$showSubscriptionView, showLackOfPlanMessage: true) |
|
|
|
|
.environment(\.colorScheme, .light) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.tint(.master) |
|
|
|
|
} |
|
|
|
|
.sheet(isPresented: $isLearningMore) { |
|
|
|
|
LearnMoreSheetView(tournament: tournament) |
|
|
|
|
.tint(.master) |
|
|
|
|
@ -997,25 +927,6 @@ struct InscriptionManagerView: View { |
|
|
|
|
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 { |
|
|
|
|
|