From 6b9fb6ef4cf6fe0dd4b12076ae0df675a2356d1d Mon Sep 17 00:00:00 2001 From: Raz Date: Sat, 10 May 2025 10:37:09 +0200 Subject: [PATCH] add planned start date and prog setup options --- PadelClub/PadelClubApp.swift | 1 + .../Tournament/Screen/BroadcastView.swift | 36 ++++++++++++++++++- PadelClubTests/ServerDataTests.swift | 18 ++++++++-- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/PadelClub/PadelClubApp.swift b/PadelClub/PadelClubApp.swift index f63d8b4..7dc7531 100644 --- a/PadelClub/PadelClubApp.swift +++ b/PadelClub/PadelClubApp.swift @@ -106,6 +106,7 @@ struct PadelClubApp: App { #else print("Running in Release mode") #endif + print(URLs.main) networkMonitor.checkConnection() self._onAppear() print(PersistenceController.getModelVersion()) diff --git a/PadelClub/Views/Tournament/Screen/BroadcastView.swift b/PadelClub/Views/Tournament/Screen/BroadcastView.swift index fce7e44..54eb097 100644 --- a/PadelClub/Views/Tournament/Screen/BroadcastView.swift +++ b/PadelClub/Views/Tournament/Screen/BroadcastView.swift @@ -143,6 +143,40 @@ struct BroadcastView: View { } } + Section { + LabeledContent { + if tournament.isProgPublished() { + Image(systemName:"checkmark").foregroundStyle(.green) + } else { + Text(tournament.publishedProgDate().formatted()) + } + } label: { + if tournament.isProgPublished() { + Text("Publiée") + } else { + Text("Publication prévue") + } + } + + Toggle(isOn: $tournament.showTeamsInProg) { + Text("Afficher les équipes sur la prog") + } + + } header: { + Text("Programmation tournoi") + } footer: { + if Date() < tournament.publishedProgDate() || tournament.isProgPublished() == false { + HStack { + Spacer() + FooterButtonView(tournament.publishProg ? "masquer sur le site" : "publier maintenant") { + tournament.publishProg.toggle() + _save() + } + } + } + } + + Section { LabeledContent { if tournament.areTeamsPublished() { @@ -311,7 +345,7 @@ struct BroadcastView: View { UIPasteboard.general.string = urlToShow } } - .onChange(of: [tournament.hideTeamsWeight, tournament.isPrivate]) { + .onChange(of: [tournament.hideTeamsWeight, tournament.isPrivate, tournament.showTeamsInProg]) { _save() } } diff --git a/PadelClubTests/ServerDataTests.swift b/PadelClubTests/ServerDataTests.swift index 62c1628..9a18b02 100644 --- a/PadelClubTests/ServerDataTests.swift +++ b/PadelClubTests/ServerDataTests.swift @@ -113,7 +113,10 @@ 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, shouldVerifyGroupStage: true, shouldVerifyBracket: true, hideTeamsWeight: true, publishTournament: true, hidePointsEarned: true, publishRankings: true, loserBracketMode: .manual, initialSeedRound: 8, initialSeedCount: 4, accountIsRequired: false, licenseIsRequired: false, minimumPlayerPerTeam: 3, maximumPlayerPerTeam: 5, information: "Super", umpireCustomMail: "razmig@padelclub.app", umpireCustomContact: "Raz", umpireCustomPhone: "+33681598193", hideUmpireMail: true, hideUmpirePhone: true, disableRankingFederalRuling: true, teamCountLimit: false, enableOnlinePayment: false, onlinePaymentIsMandatory: false, enableOnlinePaymentRefund: false, refundDateLimit: nil, stripeAccountId: nil, enableTimeToConfirm: false, isCorporateTournament: false, isTemplate: false + 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, shouldVerifyGroupStage: true, shouldVerifyBracket: true, hideTeamsWeight: true, publishTournament: true, hidePointsEarned: true, publishRankings: true, loserBracketMode: .manual, initialSeedRound: 8, initialSeedCount: 4, accountIsRequired: false, licenseIsRequired: false, minimumPlayerPerTeam: 3, maximumPlayerPerTeam: 5, information: "Super", umpireCustomMail: "razmig@padelclub.app", umpireCustomContact: "Raz", umpireCustomPhone: "+33681598193", hideUmpireMail: true, hideUmpirePhone: true, disableRankingFederalRuling: true, teamCountLimit: false, enableOnlinePayment: false, onlinePaymentIsMandatory: false, enableOnlinePaymentRefund: false, refundDateLimit: nil, stripeAccountId: nil, enableTimeToConfirm: false, isCorporateTournament: false, isTemplate: false, + publishProg: true, + showTeamsInProg: true + ) tournament.isCanceled = true @@ -185,6 +188,8 @@ final class ServerDataTests: XCTestCase { assert(t.enableTimeToConfirm == tournament.enableTimeToConfirm) assert(t.isCorporateTournament == tournament.isCorporateTournament) assert(t.isTemplate == tournament.isTemplate) + assert(t.publishProg == tournament.publishProg) + assert(t.showTeamsInProg == tournament.showTeamsInProg) } else { XCTFail("missing data") } @@ -198,7 +203,9 @@ final class ServerDataTests: XCTestCase { return } - let groupStage = GroupStage(tournament: tournamentId, index: 2, size: 3, format: MatchFormat.nineGames, startDate: Date(), name: "Yeah!", step: 1) + let groupStage = GroupStage(tournament: tournamentId, index: 2, size: 3, format: MatchFormat.nineGames, startDate: Date(), name: "Yeah!", step: 1, + plannedStartDate: Date() +) groupStage.storeId = "123" if let gs: GroupStage = try await StoreCenter.main.service().post(groupStage) { @@ -211,6 +218,8 @@ final class ServerDataTests: XCTestCase { assert(gs.matchFormat == groupStage.matchFormat) assert(gs.startDate != nil) assert(gs.step == groupStage.step) + assert(r.plannedStartDate != nil) + } else { XCTFail("missing data") } @@ -227,7 +236,9 @@ final class ServerDataTests: XCTestCase { let rounds: [Round] = try await StoreCenter.main.service().get() let parentRoundId = rounds.first?.id - let round = Round(tournament: tournamentId, index: 1, parent: parentRoundId, matchFormat: MatchFormat.nineGames, startDate: Date(), groupStageLoserBracket: false, loserBracketMode: .manual) + let round = Round(tournament: tournamentId, index: 1, parent: parentRoundId, matchFormat: MatchFormat.nineGames, startDate: Date(), groupStageLoserBracket: false, loserBracketMode: .manual, + plannedStartDate: Date() + ) round.storeId = "abc" if let r: Round = try await StoreCenter.main.service().post(round) { @@ -240,6 +251,7 @@ final class ServerDataTests: XCTestCase { assert(r.startDate != nil) assert(r.groupStageLoserBracket == round.groupStageLoserBracket) assert(r.loserBracketMode == round.loserBracketMode) + assert(r.plannedStartDate != nil) } else { XCTFail("missing data") }