fix event settings stuff

newoffer2025
Raz 6 months ago
parent c71f253837
commit 1b4a0204c1
  1. 25
      PadelClub/Views/Cashier/Event/EventCreationView.swift
  2. 15
      PadelClub/Views/Cashier/Event/EventSettingsView.swift
  3. 73
      PadelClub/Views/Cashier/Event/EventTournamentsView.swift
  4. 2
      PadelClub/Views/Cashier/Event/EventView.swift
  5. 6
      PadelClub/Views/Planning/PlanningView.swift

@ -71,6 +71,19 @@ struct EventCreationView: View {
.multilineTextAlignment(.leading)
.frame(maxWidth: .infinity)
.focused($textFieldIsFocus)
.toolbar {
if textFieldIsFocus {
ToolbarItem(placement: .keyboard) {
HStack {
Spacer()
Button("Valider") {
textFieldIsFocus = false
}
.buttonStyle(.bordered)
}
}
}
}
LabeledContent {
Text(tournaments.count.formatted())
} label: {
@ -93,18 +106,6 @@ struct EventCreationView: View {
}
}
.toolbar {
if textFieldIsFocus {
ToolbarItem(placement: .keyboard) {
HStack {
Spacer()
Button("Valider") {
textFieldIsFocus = false
}
.buttonStyle(.bordered)
}
}
}
ToolbarItem(placement: .cancellationAction) {
Button("Annuler", role: .cancel) {
dismiss()

@ -15,6 +15,7 @@ struct EventSettingsView: View {
@State private var eventName: String = ""
@State private var pageLink: PageLink = .teams
@State private var tournamentInformation: String = ""
@State private var eventStartDate: Date
@FocusState private var focusedField: Tournament.CodingKeys?
func eventLinksPasteData() -> String {
@ -43,6 +44,7 @@ struct EventSettingsView: View {
init(event: Event) {
self.event = event
_eventName = State(wrappedValue: event.name ?? "")
_eventStartDate = .init(wrappedValue: event.eventStartDate())
_tournamentInformation = State(wrappedValue: event.tournaments.first?.information ?? "")
}
@ -67,6 +69,19 @@ struct EventSettingsView: View {
}
}
Section {
DatePicker(selection: $eventStartDate) {
Text(eventStartDate.formatted(.dateTime.weekday(.wide)).capitalized).lineLimit(1)
}
.onChange(of: eventStartDate) {
event.tournaments.forEach { tournament in
tournament.startDate = eventStartDate
}
dataStore.tournaments.addOrUpdate(contentOfs: event.tournaments)
}
}
if event.tournaments.first?.dayDuration == 3, event.tournaments.count == 3 {
Section {
RowButtonView("Répartir les tournois") {

@ -44,19 +44,68 @@ struct EventTournamentsView: View {
}
} footer: {
if event.tournaments.count > 1 {
if mainTournament == nil {
FooterButtonView("c'est le tournoi principal") {
self.mainTournament = tournament
}
} else if mainTournament == tournament {
FooterButtonView("ce n'est pas le tournoi principal") {
self.mainTournament = tournament
if let mainTournament, mainTournament == tournament {
Menu {
Button("Formats") {
tournaments.forEach { tournament in
tournament.groupStageMatchFormat = mainTournament.groupStageMatchFormat
tournament.loserBracketMatchFormat = mainTournament.loserBracketMatchFormat
tournament.matchFormat = mainTournament.matchFormat
}
dataStore.tournaments.addOrUpdate(contentOfs: tournaments)
}
Button("Infos JAP") {
tournaments.forEach { tournament in
tournament.setupUmpireSettings(defaultTournament: mainTournament)
}
dataStore.tournaments.addOrUpdate(contentOfs: tournaments)
}
Button("Réglages Inscriptions") {
tournaments.forEach { tournament in
tournament.setupRegistrationSettings(templateTournament: mainTournament)
}
dataStore.tournaments.addOrUpdate(contentOfs: tournaments)
}
} label: {
Text("Copier des réglages sur les autres tournois")
.underline()
.multilineTextAlignment(.leading)
}
} else if let mainTournament {
FooterButtonView("coller les réglages du tournoi principal") {
tournament.setupUmpireSettings(defaultTournament: mainTournament)
tournament.setupRegistrationSettings(templateTournament: mainTournament)
dataStore.tournaments.addOrUpdate(instance: tournament)
} else {
Menu {
if tournament != self.mainTournament {
Button("Définir comme tournoi principal") {
self.mainTournament = tournament
}
}
if let mainTournament {
Divider()
Button("Copier les formats du tournoi principal") {
tournament.groupStageMatchFormat = mainTournament.groupStageMatchFormat
tournament.loserBracketMatchFormat = mainTournament.loserBracketMatchFormat
tournament.matchFormat = mainTournament.matchFormat
dataStore.tournaments.addOrUpdate(instance: tournament)
}
Button("Copier les infos JAP du tournoi principal") {
tournament.setupUmpireSettings(defaultTournament: mainTournament)
dataStore.tournaments.addOrUpdate(instance: tournament)
}
Button("Copier les réglages des inscriptions du tournoi principal") {
tournament.setupRegistrationSettings(templateTournament: mainTournament)
dataStore.tournaments.addOrUpdate(instance: tournament)
}
}
} label: {
Text("Options rapides pour certains réglages")
.underline()
}
}
}

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

@ -201,8 +201,10 @@ struct PlanningView: View {
"Vous n'avez pas encore défini d'horaire pour les différentes phases du tournoi"
)
} actions: {
RowButtonView("Horaire intelligent") {
selectedScheduleDestination = nil
if selectedScheduleDestination != nil {
RowButtonView("Horaire intelligent") {
selectedScheduleDestination = nil
}
}
}
}

Loading…
Cancel
Save