multistore
Razmig Sarkissian 1 year ago
parent d720c215f1
commit 90605c6112
  1. 10
      PadelClub/Data/Club.swift
  2. 23
      PadelClub/Views/Calling/Components/MenuWarningView.swift
  3. 26
      PadelClub/Views/Match/MatchDetailView.swift
  4. 7
      PadelClub/Views/Tournament/Screen/BroadcastView.swift
  5. 3
      PadelClubTests/ServerDataTests.swift

@ -177,7 +177,15 @@ extension Club {
guard let code else { return nil }
return URL(string: "https://tenup.fft.fr/club/\(code)")
}
func courtName(atIndex courtIndex: Int) -> String {
courtNameIfAvailable(atIndex: courtIndex) ?? Court.courtIndexedTitle(atIndex: courtIndex)
}
func courtNameIfAvailable(atIndex courtIndex: Int) -> String? {
customizedCourts.first(where: { $0.index == courtIndex })?.name
}
func update(fromClub club: Club) {
self.acronym = club.acronym
self.name = club.name

@ -26,17 +26,24 @@ struct MenuWarningView: View {
// TODO: Guard
@ViewBuilder
private func _actionView(players: [PlayerRegistration], privateMode: Bool = false) -> some View {
Menu {
ForEach(players) { player in
if let number = player.phoneNumber?.replacingOccurrences(of: " ", with: ""), let url = URL(string: "tel:\(number)") {
Link(destination: url) {
Text(player.playerLabel(.short))
Label(number, systemImage: "phone")
if players.count == 1, let player = players.first, let number = player.phoneNumber?.replacingOccurrences(of: " ", with: ""), let url = URL(string: "tel:\(number)") {
Link(destination: url) {
Label("Appeler", systemImage: "phone")
Text(number)
}
} else {
Menu {
ForEach(players) { player in
if let number = player.phoneNumber?.replacingOccurrences(of: " ", with: ""), let url = URL(string: "tel:\(number)") {
Link(destination: url) {
Label(player.playerLabel(.short), systemImage: "phone")
Text(number)
}
}
}
} label: {
Text("Appeler un joueur")
}
} label: {
Label("Appeler un joueur", systemImage: "phone")
}
Button("Message") {

@ -409,21 +409,22 @@ struct MatchDetailView: View {
Picker(selection: $fieldSetup) {
Text("Au hasard").tag(MatchFieldSetup.random)
//Text("Premier disponible").tag(MatchFieldSetup.firstAvailable)
if let tournament = match.currentTournament() {
if let club = match.currentTournament()?.club() {
ForEach(0..<club.courtCount, id: \.self) { courtIndex in
Text(club.courtName(atIndex: courtIndex)) .tag(MatchFieldSetup.field(courtIndex))
}
} else if let tournament = match.currentTournament() {
ForEach(0..<tournament.courtCount, id: \.self) { courtIndex in
Text(tournament.courtName(atIndex: courtIndex)) .tag(MatchFieldSetup.field(courtIndex))
}
} else {
ForEach(0..<20, id: \.self) { courtIndex in
Text(Court.courtIndexedTitle(atIndex: courtIndex)) .tag(MatchFieldSetup.field(courtIndex))
}
}
} label: {
Text("Choix du terrain")
}
.contextMenu {
NavigationLink {
//FieldDrawView(match: match)
} label: {
Text("Tirage au sort visuel")
}
}
RowButtonView("Valider") {
match.validateMatch(fromStartDate: startDateSetup == .now ? Date() : startDate, toEndDate: endDate, fieldSetup: fieldSetup)
@ -438,15 +439,6 @@ struct MatchDetailView: View {
}
}
var shareView: some View {
NavigationLink {
//EditSharingView(match: match)
} label: {
Text("Partage sur les réseaux sociaux")
}
}
private func save() {
do {
try dataStore.matches.addOrUpdate(instance: match)

@ -54,7 +54,10 @@ struct BroadcastView: View {
Text("Publication prévue")
}
}
Text("Les horaires de convocations ne seront pas publiés").foregroundStyle(.secondary)
Toggle(isOn: $tournament.hideTeamsWeight) {
Text("Masquer les poids des équipes")
}
} header: {
Text("Liste des équipes")
} footer: {
@ -228,7 +231,7 @@ struct BroadcastView: View {
UIPasteboard.general.string = urlToShow
}
}
.onChange(of: [tournament.isPrivate, tournament.publishTeams, tournament.publishSummons, tournament.publishBrackets, tournament.publishGroupStages]) {
.onChange(of: [tournament.hideTeamsWeight, tournament.isPrivate, tournament.publishTeams, tournament.publishSummons, tournament.publishBrackets, tournament.publishGroupStages]) {
_save()
}
}

@ -96,7 +96,7 @@ final class ServerDataTests: XCTestCase {
return
}
let tournament = Tournament(event: eventId, name: "RG Homme", startDate: Date(), endDate: nil, creationDate: Date(), isPrivate: false, groupStageFormat: MatchFormat.megaTie, roundFormat: MatchFormat.nineGames, loserRoundFormat: MatchFormat.nineGamesDecisivePoint, groupStageSortMode: GroupStageOrderingMode.snake, groupStageCount: 2, rankSourceDate: Date(), dayDuration: 5, teamCount: 3, teamSorting: TeamSortingType.rank, federalCategory: TournamentCategory.mix, federalLevelCategory: TournamentLevel.p1000, federalAgeCategory: FederalTournamentAge.a45, closedRegistrationDate: Date(), groupStageAdditionalQualified: 4, courtCount: 9, prioritizeClubMembers: true, qualifiedPerGroupStage: 1, teamsPerGroupStage: 2, entryFee: 30.0, additionalEstimationDuration: 5, isDeleted: true, publishTeams: true, publishSummons: true, publishGroupStages: true, publishBrackets: true, shouldVerifyBracket: true, shouldVerifyGroupStage: true)
let tournament = Tournament(event: eventId, name: "RG Homme", startDate: Date(), endDate: nil, creationDate: Date(), isPrivate: false, groupStageFormat: MatchFormat.megaTie, roundFormat: MatchFormat.nineGames, loserRoundFormat: MatchFormat.nineGamesDecisivePoint, groupStageSortMode: GroupStageOrderingMode.snake, groupStageCount: 2, rankSourceDate: Date(), dayDuration: 5, teamCount: 3, teamSorting: TeamSortingType.rank, federalCategory: TournamentCategory.mix, federalLevelCategory: TournamentLevel.p1000, federalAgeCategory: FederalTournamentAge.a45, closedRegistrationDate: Date(), groupStageAdditionalQualified: 4, courtCount: 9, prioritizeClubMembers: true, qualifiedPerGroupStage: 1, teamsPerGroupStage: 2, entryFee: 30.0, additionalEstimationDuration: 5, isDeleted: true, publishTeams: true, publishSummons: true, publishGroupStages: true, publishBrackets: true, shouldVerifyBracket: true, shouldVerifyGroupStage: true, hideTeamsWeight: false)
let t = try await Store.main.service().post(tournament)
assert(t.event == tournament.event)
@ -132,6 +132,7 @@ final class ServerDataTests: XCTestCase {
assert(t.publishBrackets == tournament.publishBrackets)
assert(t.shouldVerifyBracket == tournament.shouldVerifyBracket)
assert(t.shouldVerifyGroupStage == tournament.shouldVerifyGroupStage)
assert(t.hideTeamsWeight == tournament.hideTeamsWeight)
}
func testGroupStage() async throws {

Loading…
Cancel
Save