contact all

multistore
Raz 2 years ago
parent 16c750f950
commit 78ae6071ec
  1. 35
      PadelClub/Views/Calling/SendToAllView.swift

@ -19,30 +19,43 @@ struct SendToAllView: View {
List(selection: $contactRecipients) {
Section {
Picker(selection: $contactMethod) {
Text("par sms").tag(0)
Text("par mail").tag(1)
Text("Contacter par sms").tag(0)
Text("Contacter par mail").tag(1)
} label: {
Text("méthode")
}
.labelsHidden()
.pickerStyle(.inline)
}
Section {
ForEach(tournament.groupStages()) { groupStage in
let teams = groupStage.teams()
if teams.isEmpty == false {
LabeledContent {
Text(teams.count.formatted() + " équipe" + teams.count.pluralSuffix)
} label: {
Text(groupStage.groupStageTitle())
}
.tag(groupStage.id)
}
}
ForEach(tournament.rounds()) { round in
let teams = round.teams()
if teams.isEmpty == false {
LabeledContent {
let seeds = round.seeds()
Text(round.seeds().count + " tête" + seeds.count.pluralSuffix + " de série")
Text(teams.count.formatted() + " équipe" + teams.count.pluralSuffix)
} label: {
Text(round.roundTitle())
}
.tag(round.id)
}
}
}
Section {
RowButtonView("Contacter \(totalString)") {
RowButtonView("Contacter \(_totalString())") {
}
}
@ -56,15 +69,21 @@ struct SendToAllView: View {
}
func _teams() -> [TeamRegistration] {
let rounds : [Round] = contactRecipients.map { Store.main.findById($0) }
let rounds : [Round] = contactRecipients.compactMap { Store.main.findById($0) }
return rounds.flatMap({ $0.teams() })
}
func _groupStagesTeams() -> [TeamRegistration] {
let groupStages : [GroupStage] = contactRecipients.compactMap { Store.main.findById($0) }
return groupStages.flatMap({ $0.teams() })
}
func _totalString() -> String {
if contactRecipients.isEmpty {
return "toutes les équipes"
} else {
return
let teams = _teams() + _groupStagesTeams()
return teams.count.formatted() + " équipe" + teams.count.pluralSuffix
}
}
}

Loading…
Cancel
Save