|
|
|
@ -85,16 +85,16 @@ struct CallView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var finalMessage: String { |
|
|
|
func finalMessage(reSummon: Bool) -> String { |
|
|
|
ContactType.callingMessage(tournament: tournament, startDate: callDate, roundLabel: roundLabel, matchFormat: matchFormat, reSummon: reSummon) |
|
|
|
ContactType.callingMessage(tournament: tournament, startDate: callDate, roundLabel: roundLabel, matchFormat: matchFormat, reSummon: reSummon) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var reSummon: Bool { |
|
|
|
var reSummon: Bool { |
|
|
|
teams.allSatisfy({ $0.called() }) |
|
|
|
teams.allSatisfy({ $0.called() }) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
var body: some View { |
|
|
|
let callWord = reSummon ? "Reconvoquer" : "Convoquer" |
|
|
|
let callWord : String = (reSummon ? "Reconvoquer" : "Convoquer") |
|
|
|
HStack { |
|
|
|
HStack { |
|
|
|
if teams.count == 1 { |
|
|
|
if teams.count == 1 { |
|
|
|
if let previousCallDate = teams.first?.callDate, Calendar.current.compare(previousCallDate, to: callDate, toGranularity: .minute) != .orderedSame { |
|
|
|
if let previousCallDate = teams.first?.callDate, Calendar.current.compare(previousCallDate, to: callDate, toGranularity: .minute) != .orderedSame { |
|
|
|
@ -105,23 +105,10 @@ struct CallView: View { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Text(callWord + " ces \(teams.count) paires par") |
|
|
|
Text(callWord + " ces \(teams.count) paires par") |
|
|
|
} |
|
|
|
} |
|
|
|
Button { |
|
|
|
|
|
|
|
self._payTournamentAndExecute { |
|
|
|
_summonMenu(byMessage: true) |
|
|
|
self._contactByMessage() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
Text("sms") |
|
|
|
|
|
|
|
.underline() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Text("ou") |
|
|
|
Text("ou") |
|
|
|
Button { |
|
|
|
_summonMenu(byMessage: false) |
|
|
|
self._payTournamentAndExecute { |
|
|
|
|
|
|
|
self._contactByMail() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
Text("mail") |
|
|
|
|
|
|
|
.underline() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
.font(.subheadline) |
|
|
|
.font(.subheadline) |
|
|
|
.buttonStyle(.borderless) |
|
|
|
.buttonStyle(.borderless) |
|
|
|
@ -182,6 +169,39 @@ struct CallView: View { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ViewBuilder |
|
|
|
|
|
|
|
private func _summonMenu(byMessage: Bool) -> some View { |
|
|
|
|
|
|
|
if reSummon { |
|
|
|
|
|
|
|
Menu { |
|
|
|
|
|
|
|
Button("Convoquer") { |
|
|
|
|
|
|
|
_summon(byMessage: byMessage, reSummon: false) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Button("Re-convoquer") { |
|
|
|
|
|
|
|
_summon(byMessage: byMessage, reSummon: true) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
Text(byMessage ? "sms" : "mail") |
|
|
|
|
|
|
|
.underline() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Button(byMessage ? "sms" : "mail") { |
|
|
|
|
|
|
|
_summon(byMessage: byMessage, reSummon: false) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private func _summon(byMessage: Bool, reSummon: Bool) { |
|
|
|
|
|
|
|
self._payTournamentAndExecute { |
|
|
|
|
|
|
|
if byMessage { |
|
|
|
|
|
|
|
self._contactByMessage(reSummon: reSummon) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
self._contactByMail(reSummon: reSummon) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fileprivate func _payTournamentAndExecute(_ handler: () -> ()) { |
|
|
|
fileprivate func _payTournamentAndExecute(_ handler: () -> ()) { |
|
|
|
do { |
|
|
|
do { |
|
|
|
try tournament.payIfNecessary() |
|
|
|
try tournament.payIfNecessary() |
|
|
|
@ -191,12 +211,12 @@ struct CallView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fileprivate func _contactByMessage() { |
|
|
|
fileprivate func _contactByMessage(reSummon: Bool) { |
|
|
|
contactType = .message(date: callDate, recipients: teams.flatMap { $0.getPhoneNumbers() }, body: finalMessage, tournamentBuild: nil) |
|
|
|
contactType = .message(date: callDate, recipients: teams.flatMap { $0.getPhoneNumbers() }, body: finalMessage(reSummon: reSummon), tournamentBuild: nil) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fileprivate func _contactByMail() { |
|
|
|
fileprivate func _contactByMail(reSummon: Bool) { |
|
|
|
contactType = .mail(date: callDate, recipients: tournament.umpireMail(), bccRecipients: teams.flatMap { $0.getMail() }, body: finalMessage, subject: tournament.tournamentTitle(), tournamentBuild: nil) |
|
|
|
contactType = .mail(date: callDate, recipients: tournament.umpireMail(), bccRecipients: teams.flatMap { $0.getMail() }, body: finalMessage(reSummon: reSummon), subject: tournament.tournamentTitle(), tournamentBuild: nil) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|