|
|
|
|
@ -184,6 +184,34 @@ final public class Event: BaseEvent { |
|
|
|
|
return link.compactMap({ $0 }).joined(separator: "\n\n") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public func selectedTeams() -> [TeamRegistration] { |
|
|
|
|
confirmedTournaments().flatMap({ $0.selectedSortedTeams() }) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public func umpireMail() -> [String]? { |
|
|
|
|
confirmedTournaments().first?.umpireMail() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public func mailSubject() -> String { |
|
|
|
|
let tournaments = confirmedTournaments() |
|
|
|
|
|
|
|
|
|
guard !tournaments.isEmpty else { |
|
|
|
|
return eventTitle() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Get the date range from all confirmed tournaments |
|
|
|
|
let dates = tournaments.compactMap { $0.startDate } |
|
|
|
|
guard let firstDate = dates.min(), let lastDate = dates.max() else { |
|
|
|
|
return eventTitle() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let dateRange = firstDate == lastDate |
|
|
|
|
? firstDate.formattedDate(.short) |
|
|
|
|
: "\(firstDate.formattedDate(.short)) - \(lastDate.formattedDate(.short))" |
|
|
|
|
|
|
|
|
|
let subject = [eventTitle(), dateRange, clubObject()?.name].compactMap({ $0 }).joined(separator: " | ") |
|
|
|
|
return subject |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func insertOnServer() throws { |
|
|
|
|
DataStore.shared.events.writeChangeAndInsertOnServer(instance: self) |
|
|
|
|
|