Merge branch 'main'

release
Raz 1 year ago
commit de19ce4384
  1. 17
      PadelClub/Views/Club/ClubDetailView.swift
  2. 35
      PadelClub/Views/Club/ClubSearchView.swift
  3. 2
      PadelClub/Views/User/LoginView.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

@ -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[..<colonIndex].trimmingCharacters(in: .whitespacesAndNewlines)
let courtsString = trimmedComponent[trimmedComponent.index(after: colonIndex)...].trimmingCharacters(in: .whitespacesAndNewlines)
// If the sport matches the requested sport, return the number of courts
if sportName.lowercased() == sport.lowercased() {
if let courtsNumber = courtsString.split(separator: " ").first,
let courts = Int(courtsNumber) {
return courts
}
}
} else if pratiques.count == 1 && pratiques.first?.rawValue.lowercased() == sport.lowercased() {
// Handle cases where only the number of courts is provided (e.g., "2 terrains")
if let courtsNumber = trimmedComponent.split(separator: " ").first,
let courts = Int(courtsNumber) {
return courts
}
}
}
// Return nil if the sport or number of courts is not found
return nil
}
var location: CLLocation {
CLLocation(latitude: lat, longitude: lng)
}

@ -103,7 +103,7 @@ struct LoginView: View {
}
Section {
TextField("Nom d'utilisateur", text: self.$username)
TextField("Nom d'utilisateur ou email", text: self.$username)
.autocorrectionDisabled(true)
.keyboardType(.asciiCapable)
.textContentType(.init(rawValue: ""))

Loading…
Cancel
Save