diff --git a/PadelClub/Views/Planning/PlanningSettingsView.swift b/PadelClub/Views/Planning/PlanningSettingsView.swift index 3528cc1..bf111ea 100644 --- a/PadelClub/Views/Planning/PlanningSettingsView.swift +++ b/PadelClub/Views/Planning/PlanningSettingsView.swift @@ -21,7 +21,9 @@ struct PlanningSettingsView: View { @State private var showOptions: Bool = false @State private var issueFound: Bool = false @State private var parallelType: Bool = false - + @State private var deletingDateMatchesDone: Bool = false + @State private var deletingDone: Bool = false + var tournamentStore: TournamentStore { return self.tournament.tournamentStore } @@ -121,11 +123,13 @@ struct PlanningSettingsView: View { Section { RowButtonView("Supprimer les horaires des matches", role: .destructive) { do { + deletingDateMatchesDone = false allMatches.forEach({ $0.startDate = nil $0.confirmed = false }) try self.tournamentStore.matches.addOrUpdate(contentOfs: allMatches) + deletingDateMatchesDone = true } catch { Logger.error(error) } @@ -137,7 +141,8 @@ struct PlanningSettingsView: View { Section { RowButtonView("Supprimer tous les horaires", role: .destructive) { do { - allMatches.forEach({ + deletingDone = false + allMatches.forEach({ $0.startDate = nil $0.confirmed = false }) @@ -148,6 +153,7 @@ struct PlanningSettingsView: View { allRounds.forEach({ $0.startDate = nil }) try self.tournamentStore.rounds.addOrUpdate(contentOfs: allRounds) + deletingDone = true } catch { Logger.error(error) } @@ -196,6 +202,14 @@ struct PlanningSettingsView: View { .toastFormatted() .deferredRendering(for: .seconds(2)) } + } else if deletingDone { + Label("Tous les horaires ont été supprimés", systemImage: "clock.badge.xmark.fill") + .toastFormatted() + .deferredRendering(for: .seconds(2)) + } else if deletingDateMatchesDone { + Label("Horaires des matchs supprimés", systemImage: "clock.badge.xmark.fill") + .toastFormatted() + .deferredRendering(for: .seconds(2)) } } .onChange(of: tournament.startDate) {