fix shared tournament umpire stuff

sync3
Razmig Sarkissian 1 month ago
parent 09d5da914c
commit 2d40e5b816
  1. 6
      PadelClub/Views/Navigation/Agenda/EventListView.swift
  2. 42
      PadelClub/Views/Tournament/Screen/Components/TournamentGeneralSettingsView.swift

@ -532,11 +532,15 @@ struct EventListView: View {
if federalTournament.umpireLabel().isEmpty == false {
newTournament.umpireCustomContact = federalTournament.umpireLabel()
} else {
newTournament.umpireCustomContact = DataStore.shared.user.fullName()
}
if federalTournament.mailLabel().isEmpty == false {
newTournament.umpireCustomMail = federalTournament.mailLabel()
} else {
newTournament.umpireCustomMail = DataStore.shared.user.email
}
newTournament.umpireCustomPhone = DataStore.shared.user.phone
do {
let umpireData = try await NetworkFederalService.shared.getUmpireData(idTournament: federalTournament.id)
if let email = umpireData.email {

@ -479,10 +479,34 @@ struct TournamentGeneralSettingsView: View {
dataStore.tournaments.addOrUpdate(instance: tournament)
}
private func _email() -> String {
if tournament.sharing == nil {
return dataStore.user.email
} else {
return "Mail"
}
}
private func _phone() -> String {
if tournament.sharing == nil {
return dataStore.user.phone ?? "Téléphone"
} else {
return "Téléphone"
}
}
private func _contact() -> String {
if tournament.sharing == nil {
return dataStore.user.fullName()
} else {
return "Contact"
}
}
private func _customUmpireView() -> some View {
Section {
VStack(alignment: .leading) {
TextField(dataStore.user.email, text: $umpireCustomMail)
TextField(_email(), text: $umpireCustomMail)
.frame(maxWidth: .infinity)
.keyboardType(.emailAddress)
.autocapitalization(.none)
@ -496,7 +520,7 @@ struct TournamentGeneralSettingsView: View {
}
VStack(alignment: .leading) {
TextField(dataStore.user.phone ?? "Téléphone", text: $umpireCustomPhone)
TextField(_phone(), text: $umpireCustomPhone)
.frame(maxWidth: .infinity)
.keyboardType(.phonePad)
.focused($focusedField, equals: ._umpireCustomPhone)
@ -510,26 +534,30 @@ struct TournamentGeneralSettingsView: View {
VStack(alignment: .leading) {
TextField(dataStore.user.fullName(), text: $umpireCustomContact)
TextField(_contact(), text: $umpireCustomContact)
.frame(maxWidth: .infinity)
.keyboardType(.default)
.focused($focusedField, equals: ._umpireCustomContact)
.onSubmit {
_confirmUmpireContact()
}
if dataStore.user.getSummonsMessageSignature() != nil, umpireCustomContact != dataStore.user.fullName() {
if tournament.sharing == nil, dataStore.user.getSummonsMessageSignature() != nil, umpireCustomContact != dataStore.user.fullName() {
Text("Attention vous avez une signature personnalisée contenant un contact différent.").foregroundStyle(.logoRed)
FooterButtonView("retirer la personnalisation ?") {
dataStore.user.summonsMessageSignature = nil
self.dataStore.saveUser()
}
} }
}
}
} header: {
Text("Juge-arbitre")
} footer: {
Text("Par défaut, les informations de Tenup sont récupérés, et si ce n'est pas le cas, ces informations seront utilisées pour vous contacter. Vous pouvez les modifier si vous souhaitez utiliser les informations de contact différentes de votre compte Padel Club.")
if tournament.sharing == nil {
Text("Par défaut, les informations de Tenup sont récupérés, et si ce n'est pas le cas, ces informations seront utilisées pour vous contacter. Vous pouvez les modifier si vous souhaitez utiliser les informations de contact différentes de votre compte Padel Club.")
} else {
Text("Ce tournoi vous avez été partagé par un autre utilisateur. Par défaut ses informations seront utilisés pour ces champs si jamais ils restent vides.")
}
}
}
}

Loading…
Cancel
Save