possiblité de lancer l'horaire intelligent sur tous les tournois d'un evenement en une fois

newoffer2025
Razmig Sarkissian 3 months ago
parent aee7b85c66
commit 7a08bda544
  1. 16
      PadelClub/Views/Cashier/Event/EventSettingsView.swift
  2. 3
      PadelClub/Views/Cashier/Event/EventView.swift
  3. 43
      PadelClub/Views/Planning/PlanningView.swift

@ -18,6 +18,13 @@ struct EventSettingsView: View {
@State private var eventStartDate: Date
@FocusState private var focusedField: Tournament.CodingKeys?
var visibleOnPadelClub: Binding<Bool> {
Binding {
event.confirmedTournaments().allSatisfy({ $0.isPrivate == false })
} set: { _ in
}
}
func eventLinksPasteData() -> String {
let tournaments = event.tournaments
var link = [String]()
@ -105,6 +112,15 @@ struct EventSettingsView: View {
}
_saveAllTournaments()
}
}
}
Section {
Toggle(isOn: visibleOnPadelClub) {
Text("Visible sur Padel Club")
}
.onChange(of: visibleOnPadelClub.wrappedValue) { oldValue, newValue in
_saveAllTournaments()
}
}

@ -99,8 +99,7 @@ struct EventView: View {
case .club(let event):
EventClubSettingsView(event: event)
case .eventPlanning:
let allMatches = event.tournaments.flatMap { $0.allMatches() }
PlanningView(matches: allMatches, selectedScheduleDestination: .constant(nil))
PlanningView(matches: [], selectedScheduleDestination: .constant(nil), event: event)
.environment(\.matchViewStyle, .feedStyle)
case .links:
EventLinksView(event: event)

@ -22,9 +22,15 @@ struct PlanningView: View {
let updatePlannedDatesTip = UpdatePlannedDatesTip()
let allMatches: [Match]
let timeSlotMoveOptionTip = TimeSlotMoveOptionTip()
let event: Event?
init(matches: [Match], selectedScheduleDestination: Binding<ScheduleDestination?>) {
self.allMatches = matches
init(matches: [Match], selectedScheduleDestination: Binding<ScheduleDestination?>, event: Event? = nil) {
self.event = event
if let event {
self.allMatches = event.confirmedTournaments().flatMap { $0.allMatches() }
} else {
self.allMatches = matches
}
_selectedScheduleDestination = selectedScheduleDestination
}
@ -132,6 +138,24 @@ struct PlanningView: View {
} else {
ToolbarItemGroup(placement: .topBarTrailing) {
Menu {
if let event {
Menu {
Button {
event.confirmedTournaments().forEach { tournament in
tournament.removeAllDates()
}
} label: {
Text("Effacer tous les horaires")
}
Button {
_planEvent(event: event)
} label: {
Text("Planifier")
}
} label: {
Text("Planifier l'événement")
}
}
if notSlots == false {
CourtOptionsView(timeSlots: timeSlots, underlined: false)
Toggle(isOn: $enableMove) {
@ -226,11 +250,26 @@ struct PlanningView: View {
RowButtonView("Horaire intelligent") {
selectedScheduleDestination = nil
}
} else if let event {
RowButtonView("Planifier automatiquement") {
_planEvent(event: event)
}
}
}
}
}
}
private func _planEvent(event: Event) {
event.confirmedTournaments().forEach { tournament in
if let matchScheduler = tournament.matchScheduler() {
_ = matchScheduler.updateSchedule(tournament: tournament)
} else {
let matchScheduler = MatchScheduler(tournament: tournament.id, courtsAvailable: Set(tournament.courtsAvailable()))
_ = matchScheduler.updateSchedule(tournament: tournament)
}
}
}
struct BySlotView: View {
@Environment(\.filterOption) private var filterOption

Loading…
Cancel
Save