You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
2.0 KiB
55 lines
2.0 KiB
//
|
|
// TournamentOrganizerView.swift
|
|
// PadelClub
|
|
//
|
|
// Created by Razmig Sarkissian on 29/02/2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
import LeStorage
|
|
|
|
struct TournamentOrganizerView: View {
|
|
@EnvironmentObject var dataStore: DataStore
|
|
@Environment(NavigationViewModel.self) private var navigation
|
|
|
|
var body: some View {
|
|
VStack(spacing: 0) {
|
|
if let tournament = navigation.organizerTournament {
|
|
OrganizedTournamentView(tournament: tournament)
|
|
} else {
|
|
NavigationStack {
|
|
let userClubsEmpty = dataStore.user.clubs.isEmpty
|
|
ContentUnavailableView(
|
|
"Aucun tournoi sélectionné",
|
|
systemImage: "rectangle.slash",
|
|
description:
|
|
Text(userClubsEmpty ? "Cet écran vous permettra de gérer plusieurs tournois se déroulant en même temps." : "Utilisez l'accès rapide ci-dessous pour éditer un tournoi et passer rapidement d'un tournoi à l'autre.")
|
|
)
|
|
.navigationTitle("Gestionnaire de tournois")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbarBackground(.visible, for: .navigationBar)
|
|
}
|
|
}
|
|
Divider()
|
|
HStack {
|
|
ScrollView(.horizontal) {
|
|
HStack {
|
|
let tournaments = dataStore.tournaments.filter({ $0.hasEnded() == false && $0.isDeleted == false && $0.isCanceled == false }).sorted(by: \.startDate).reversed()
|
|
ForEach(tournaments) { tournament in
|
|
TournamentButtonView(tournament: tournament)
|
|
}
|
|
}
|
|
.padding()
|
|
.buttonStyle(.plain)
|
|
}
|
|
}
|
|
}
|
|
.onChange(of: Store.main.userId) {
|
|
navigation.organizerTournament = nil
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
TournamentOrganizerView()
|
|
}
|
|
|