From da31523dedf276918daef9247b72ca257b998aed Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 10 Jun 2025 08:56:50 +0200 Subject: [PATCH] fix issue with planned date --- PadelClub.xcodeproj/project.pbxproj | 4 ++-- PadelClub/Utils/Tips.swift | 14 ++++++++++++++ PadelClub/Views/Planning/PlanningView.swift | 19 ++++++++++++++++++- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 5291060..fdd6498 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -3129,7 +3129,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.2.35; + MARKETING_VERSION = 1.2.36; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -3175,7 +3175,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.2.35; + MARKETING_VERSION = 1.2.36; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/PadelClub/Utils/Tips.swift b/PadelClub/Utils/Tips.swift index 6daf217..1b0cb6c 100644 --- a/PadelClub/Utils/Tips.swift +++ b/PadelClub/Utils/Tips.swift @@ -646,6 +646,20 @@ struct ShouldTournamentBeOverTip: Tip { } } +struct UpdatePlannedDatesTip: Tip { + var title: Text { + Text("Mettre à jour la programmation des matchs") + } + + var message: Text? { + Text("Tous les matchs dans le futur verront leur dates plannifiées mis à jour dans la section Programmation du site Padel Club.") + } + + var image: Image? { + Image(systemName: "arrow.trianglehead.2.clockwise.rotate.90.circle") + } +} + struct TipStyleModifier: ViewModifier { @Environment(\.colorScheme) var colorScheme var tint: Color? diff --git a/PadelClub/Views/Planning/PlanningView.swift b/PadelClub/Views/Planning/PlanningView.swift index 0aa4a35..f670f48 100644 --- a/PadelClub/Views/Planning/PlanningView.swift +++ b/PadelClub/Views/Planning/PlanningView.swift @@ -19,7 +19,7 @@ struct PlanningView: View { @State private var showFinishedMatches: Bool = false @State private var enableMove: Bool = false @Environment(\.editMode) private var editMode - + let updatePlannedDatesTip = UpdatePlannedDatesTip() let allMatches: [Match] let timeSlotMoveOptionTip = TimeSlotMoveOptionTip() @@ -189,6 +189,23 @@ struct PlanningView: View { filterOption == .byCourt || showFinishedMatches ? .fill : .none) } + + Button("Mettre à jour", systemImage: "arrow.trianglehead.2.clockwise.rotate.90.circle") { + let now = Date() + matches.forEach { + if let startDate = $0.startDate, startDate > now { + $0.plannedStartDate = $0.startDate + } + } + + let groupByTournaments = matches.grouped { match in + match.currentTournament() + } + groupByTournaments.forEach { tournament, matches in + tournament?.tournamentStore?.matches.addOrUpdate(contentOfs: matches) + } + } + .popoverTip(updatePlannedDatesTip) } } })