//
//  TournamentInitView.swift
//  PadelClub
//
//  Created by Razmig Sarkissian on 22/03/2024.
//

import SwiftUI
import LeStorage

struct TournamentInitView: View {
    @EnvironmentObject var dataStore: DataStore
    var tournament: Tournament

    @ViewBuilder
    var body: some View {
        Section {
            
            if let event = tournament.eventObject() {
                let tournaments = event.tournaments
                NavigationLink(value: Screen.event) {
                    LabeledContent {
                        Text(tournaments.count.formatted() + " tournoi" + tournaments.count.pluralSuffix)
                    } label: {
                        Text("Gestion de l'événement")
                    }
                }
            }
            
            NavigationLink(value: Screen.structure) {
                LabeledContent {
                    if tournament.state() == .initial {
                        Text("à valider")
                    } else {
                        Image(systemName: "checkmark").foregroundStyle(.green)
                    }
                } label: {
                    LabelStructure()
                    Text(tournament.structureDescriptionLocalizedLabel())
                }
            }
            
            NavigationLink(value: Screen.settings) {
                LabeledContent {
                    Text(tournament.localizedTournamentType())
                } label: {
                    LabelSettings()
                    Text("Formats, terrains, prix et plus")
                }
            }
            
            TournamentBroadcastRowView(tournament: tournament)
            
            NavigationLink(value: Screen.print) {
                Text("Imprimer")
            }
        }
    }
}

//#Preview {
//    TournamentInitView(tournament: Tournament.mock())
//}
