From 06dd0fc3cca5121306246f10976b47bef3d07e13 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 30 Sep 2025 17:04:55 +0200 Subject: [PATCH] fix stuff --- .../RankingGroupStageSetupView.swift | 18 ++++++ .../Match/Components/MatchDateView.swift | 10 ++++ .../Screen/RegistrationSetupView.swift | 1 - .../Screen/TableStructureView.swift | 60 ++++++++++++------- .../Views/Tournament/TournamentView.swift | 24 ++++---- 5 files changed, 81 insertions(+), 32 deletions(-) create mode 100644 PadelClub/Views/GroupStage/RankingGroupStageSetupView.swift diff --git a/PadelClub/Views/GroupStage/RankingGroupStageSetupView.swift b/PadelClub/Views/GroupStage/RankingGroupStageSetupView.swift new file mode 100644 index 0000000..bcf88d2 --- /dev/null +++ b/PadelClub/Views/GroupStage/RankingGroupStageSetupView.swift @@ -0,0 +1,18 @@ +// +// RankingGroupStageSetupView.swift +// PadelClub +// +// Created by Razmig Sarkissian on 30/09/2025. +// + +import SwiftUI + +struct RankingGroupStageSetupView: View { + var body: some View { + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + } +} + +#Preview { + RankingGroupStageSetupView() +} diff --git a/PadelClub/Views/Match/Components/MatchDateView.swift b/PadelClub/Views/Match/Components/MatchDateView.swift index df0e586..202faf3 100644 --- a/PadelClub/Views/Match/Components/MatchDateView.swift +++ b/PadelClub/Views/Match/Components/MatchDateView.swift @@ -42,6 +42,16 @@ struct MatchDateView: View { let estimatedDuration = match.getDuration() if isReady { Section { + Button("Démarrer il y a 5 minutes") { + if let updatedField { + match.setCourt(updatedField) + } + match.updateStartDate(Calendar.current.date(byAdding: .minute, value: -5, to: currentDate), keepPlannedStartDate: true) + match.endDate = nil + match.confirmed = true + _save() + } + Button("Démarrer maintenant") { if let updatedField { match.setCourt(updatedField) diff --git a/PadelClub/Views/Tournament/Screen/RegistrationSetupView.swift b/PadelClub/Views/Tournament/Screen/RegistrationSetupView.swift index 53ef012..4eec9a2 100644 --- a/PadelClub/Views/Tournament/Screen/RegistrationSetupView.swift +++ b/PadelClub/Views/Tournament/Screen/RegistrationSetupView.swift @@ -355,7 +355,6 @@ struct RegistrationSetupView: View { }, message: { Text(ValidationError.onlinePaymentNotEnabled.localizedDescription) }) - .toolbarRole(.editor) .headerProminence(.increased) .navigationTitle("Inscription en ligne") .ifAvailableiOS26 { diff --git a/PadelClub/Views/Tournament/Screen/TableStructureView.swift b/PadelClub/Views/Tournament/Screen/TableStructureView.swift index 1867d8f..2033927 100644 --- a/PadelClub/Views/Tournament/Screen/TableStructureView.swift +++ b/PadelClub/Views/Tournament/Screen/TableStructureView.swift @@ -23,6 +23,7 @@ struct TableStructureView: View { @State private var structurePreset: PadelTournamentStructurePreset = .manual @State private var buildWildcards: Bool = true @FocusState private var stepperFieldIsFocused: Bool + @State private var confirmReset: Bool = false func displayWarning() -> Bool { let unsortedTeamsCount = tournament.unsortedTeamsCount() @@ -297,27 +298,7 @@ struct TableStructureView: View { Section { RowButtonView("Remise-à-zéro", role: .destructive) { - tournament.removeWildCards() - tournament.deleteGroupStages() - tournament.deleteStructure() - - if structurePreset != .manual { - structurePreset = PadelTournamentStructurePreset.manual - } else { - _updatePreset() - } - - tournament.teamCount = teamCount - tournament.groupStageCount = groupStageCount - tournament.teamsPerGroupStage = teamsPerGroupStage - tournament.qualifiedPerGroupStage = qualifiedPerGroupStage - tournament.groupStageAdditionalQualified = groupStageAdditionalQualified - - do { - try dataStore.tournaments.addOrUpdate(instance: tournament) - } catch { - Logger.error(error) - } + _reset() } } } @@ -376,6 +357,24 @@ struct TableStructureView: View { } } .toolbar { + if tournament.state() != .initial { + ToolbarItem(placement: .topBarTrailing) { + Button("Remise-à-zéro", systemImage: "trash", role: .destructive) { + confirmReset.toggle() + } + .confirmationDialog("Remise-à-zéro", isPresented: $confirmReset, titleVisibility: .visible, actions: { + Button("Tout effacer") { + _reset() + } + + Button("Annuler") { + + } + }, message: { + Text("Vous êtes sur le point d'effacer le tableau et les poules déjà créés et perdre les matchs et scores correspondant.") + }) + } + } ToolbarItem(placement: .confirmationAction) { if tournament.state() == .initial { ButtonValidateView { @@ -420,6 +419,25 @@ struct TableStructureView: View { } + private func _reset() { + tournament.removeWildCards() + tournament.deleteGroupStages() + tournament.deleteStructure() + + if structurePreset != .manual { + structurePreset = PadelTournamentStructurePreset.manual + } else { + _updatePreset() + } + + tournament.teamCount = teamCount + tournament.groupStageCount = groupStageCount + tournament.teamsPerGroupStage = teamsPerGroupStage + tournament.qualifiedPerGroupStage = qualifiedPerGroupStage + tournament.groupStageAdditionalQualified = groupStageAdditionalQualified + + dataStore.tournaments.addOrUpdate(instance: tournament) + } private func _saveWithoutRebuild() { tournament.teamCount = teamCount diff --git a/PadelClub/Views/Tournament/TournamentView.swift b/PadelClub/Views/Tournament/TournamentView.swift index 8539028..148a7ce 100644 --- a/PadelClub/Views/Tournament/TournamentView.swift +++ b/PadelClub/Views/Tournament/TournamentView.swift @@ -172,7 +172,8 @@ struct TournamentView: View { TeamRestingView() case .stateSettings: TournamentStatusView(tournament: tournament) - + case .rankingGroupStageSetup: + RankingGroupStageSetupView() } } .environment(tournament) @@ -265,17 +266,9 @@ struct TournamentView: View { .foregroundStyle(.secondary) } - Divider() - - Button { - navigation.path.append(Screen.stateSettings) - } label: { - Label("Gestion", systemImage: "trash") - Text("Annuler, supprimer ou terminer le tournoi") - } - } label: { Label("Réglages", systemImage: "wrench.and.screwdriver") + Text("Événement, tournoi, structure") } @@ -333,6 +326,17 @@ struct TournamentView: View { // Label("Partager", systemImage: "square.and.arrow.up") // } + + Divider() + + Button { + navigation.path.append(Screen.stateSettings) + } label: { + Label("Clôture du tournoi", systemImage: "stop.fill") + Text("Annuler, supprimer ou terminer le tournoi") + } + + } label: { LabelOptions() .popoverTip(tournamentRunningTip)