diff --git a/PadelClub/Views/Club/ClubDetailView.swift b/PadelClub/Views/Club/ClubDetailView.swift index f79769f..29fe8f7 100644 --- a/PadelClub/Views/Club/ClubDetailView.swift +++ b/PadelClub/Views/Club/ClubDetailView.swift @@ -47,7 +47,14 @@ struct ClubDetailView: View { } } footer: { if displayContext == .lockedForEditing { - Text("Édition impossible, vous n'êtes pas le créateur de ce club.").foregroundStyle(.logoRed) + VStack(alignment: .leading) { + Text("Édition impossible, vous n'êtes pas le créateur de ce club.") + FooterButtonView("Contactez-nous") { + _openMail() + } + } + .font(.footnote) + .foregroundStyle(.logoRed) } } } @@ -255,6 +262,14 @@ struct ClubDetailView: View { } } + private func _openMail() { + let emailTo: String = "support@padelclub.app" + let subject: String = "Édition de club impossible : \(club.name)" + if let url = URL(string: "mailto:\(emailTo)?subject=\(subject)"), UIApplication.shared.canOpenURL(url) { + UIApplication.shared.open(url, options: [:], completionHandler: nil) + } + } + private func _deleteClub() { do { clubDeleted = true diff --git a/PadelClub/Views/Club/ClubSearchView.swift b/PadelClub/Views/Club/ClubSearchView.swift index cc22c46..cda6c72 100644 --- a/PadelClub/Views/Club/ClubSearchView.swift +++ b/PadelClub/Views/Club/ClubSearchView.swift @@ -334,6 +334,7 @@ struct ClubSearchView: View { clubToEdit.latitude = clubMarker.lat clubToEdit.longitude = clubMarker.lng clubToEdit.city = clubMarker.ville + clubToEdit.courtCount = clubMarker.numberOfCourts(for: "Padel") ?? 2 } if displayContext == .addition && clubToEdit.hasBeenCreated(by: StoreCenter.main.userId) { @@ -420,6 +421,40 @@ struct ClubMarker: Codable, Hashable, Identifiable { let pratiques: [Pratique] let lat, lng: Double + // Method to get the number of courts for a specific sport + func numberOfCourts(for sport: String) -> Int? { + // Split the `terrainPratiqueLibelle` string into components + let components = terrainPratiqueLibelle.split(separator: ",") + + // Iterate through the components to find the relevant sport or general number of courts + for component in components { + let trimmedComponent = component.trimmingCharacters(in: .whitespacesAndNewlines) + + // Check if the component explicitly mentions the sport + if let colonIndex = trimmedComponent.firstIndex(of: ":") { + let sportName = trimmedComponent[..