club_update
Razmig Sarkissian 1 year ago
parent 8373509a14
commit c24835052b
  1. 2
      PadelClub/Data/Match.swift
  2. 3
      PadelClub/Data/TeamRegistration.swift
  3. 2
      PadelClub/Views/Cashier/Event/EventTournamentsView.swift
  4. 1
      PadelClub/Views/GroupStage/GroupStageView.swift
  5. 74
      PadelClub/Views/Match/Components/MatchDateView.swift
  6. 11
      PadelClub/Views/Navigation/Ongoing/OngoingView.swift
  7. 8
      PadelClub/Views/Tournament/Screen/Components/TournamentStatusView.swift
  8. 2
      PadelClub/Views/Tournament/TournamentView.swift

@ -488,6 +488,8 @@ defer {
winningTeamId = teamOne?.id
losingTeamId = teamTwo?.id
confirmed = true
groupStageObject?.updateGroupStageState()
roundObject?.updateTournamentState()
updateFollowingMatchTeamScore()

@ -119,6 +119,9 @@ final class TeamRegistration: ModelObject, Storable {
let seedPosition: Int = match.lockAndGetSeedPosition(atTeamPosition: slot, opposingSeeding: opposingSeeding)
tournamentObject()?.resetTeamScores(in: bracketPosition)
self.bracketPosition = seedPosition
if groupStagePosition != nil && qualified == false {
qualified = true
}
tournamentObject()?.updateTeamScores(in: bracketPosition)
}

@ -28,7 +28,7 @@ struct EventTournamentsView: View {
List {
ForEach(tournaments) { tournament in
NavigationLink {
TournamentStatusView(tournament: tournament)
TournamentStatusView(tournament: tournament, eventDismiss: true)
} label: {
TournamentCellView(tournament: tournament)
.contextMenu {

@ -46,6 +46,7 @@ struct GroupStageView: View {
}
.pickerStyle(.segmented)
.fixedSize()
Spacer()
}
}

@ -27,50 +27,54 @@ struct MatchDateView: View {
}
var body: some View {
Menu {
let estimatedDuration = match.getDuration()
if match.startDate == nil && isReady {
Button("Démarrer") {
match.startDate = Date()
match.confirmed = true
_save()
}
Button("Démarrer dans 5 minutes") {
match.startDate = Calendar.current.date(byAdding: .minute, value: 5, to: Date())
match.confirmed = true
_save()
}
Button("Démarrer dans 15 minutes") {
match.startDate = Calendar.current.date(byAdding: .minute, value: 15, to: Date())
match.confirmed = true
_save()
}
Button("Démarrer dans \(estimatedDuration.formatted()) minutes") {
match.startDate = Calendar.current.date(byAdding: .minute, value: estimatedDuration, to: Date())
match.confirmed = true
_save()
}
} else {
if isReady {
Button("Démarrer maintenant") {
if match.endDate != nil {
label
} else {
Menu {
let estimatedDuration = match.getDuration()
if match.startDate == nil && isReady {
Button("Démarrer") {
match.startDate = Date()
match.endDate = nil
match.confirmed = true
_save()
}
Button("Démarrer dans 5 minutes") {
match.startDate = Calendar.current.date(byAdding: .minute, value: 5, to: Date())
match.confirmed = true
_save()
}
Button("Démarrer dans 15 minutes") {
match.startDate = Calendar.current.date(byAdding: .minute, value: 15, to: Date())
match.confirmed = true
_save()
}
Button("Démarrer dans \(estimatedDuration.formatted()) minutes") {
match.startDate = Calendar.current.date(byAdding: .minute, value: estimatedDuration, to: Date())
match.confirmed = true
_save()
}
} else {
Button("Décaler de \(estimatedDuration) minutes") {
match.cleanScheduleAndSave(match.startDate?.addingTimeInterval(Double(estimatedDuration) * 60.0))
if isReady {
Button("Démarrer maintenant") {
match.startDate = Date()
match.endDate = nil
match.confirmed = true
_save()
}
} else {
Button("Décaler de \(estimatedDuration) minutes") {
match.cleanScheduleAndSave(match.startDate?.addingTimeInterval(Double(estimatedDuration) * 60.0))
}
}
Button("Retirer l'horaire") {
match.cleanScheduleAndSave()
}
}
Button("Retirer l'horaire") {
match.cleanScheduleAndSave()
}
} label: {
label
}
} label: {
label
.buttonStyle(.plain)
}
.buttonStyle(.plain)
}
@ViewBuilder

@ -65,10 +65,10 @@ struct OngoingView: View {
}
}
.navigationTitle("En cours")
.navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .bottomBar)
.toolbar(matches.isEmpty ? .hidden : .visible, for: .navigationBar)
.toolbar {
ToolbarItem(placement: .principal) {
ToolbarItem(placement: .status) {
Picker(selection: $sortByField) {
Text("tri par date").tag(true)
Text("tri par terrain").tag(false)
@ -76,11 +76,8 @@ struct OngoingView: View {
}
.pickerStyle(.segmented)
}
ToolbarItem(placement: .status) {
if matches.isEmpty == false {
Text("\(matches.count) match" + matches.count.pluralSuffix)
}
.fixedSize()
.offset(y: -4)
}
}
}

@ -13,7 +13,8 @@ struct TournamentStatusView: View {
@Environment(NavigationViewModel.self) private var navigation: NavigationViewModel
@EnvironmentObject var dataStore: DataStore
@Bindable var tournament: Tournament
var eventDismiss: Bool = false
var body: some View {
Form {
#if DEBUG
@ -64,7 +65,10 @@ struct TournamentStatusView: View {
Logger.error(error)
}
}
navigation.path = NavigationPath()
if eventDismiss {
navigation.path = NavigationPath()
}
}
}

@ -199,7 +199,9 @@ struct TournamentView: View {
TournamentStatusView(tournament: tournament)
} label: {
Text("Gestion du tournoi")
.foregroundStyle(.logoRed)
Text("Annuler, supprimer ou terminer le tournoi")
.foregroundStyle(.logoRed)
}
} label: {
LabelOptions()

Loading…
Cancel
Save