//
//  TeamDetailView.swift
//  PadelClub
//
//  Created by Razmig Sarkissian on 23/03/2024.
//

import SwiftUI
import LeStorage

struct TeamDetailView: View {
    @Environment(Tournament.self) var tournament: Tournament
    @EnvironmentObject var dataStore: DataStore
    var team: TeamRegistration
    
    var body: some View {
        if team.unsortedPlayers().isEmpty {
            Text("Aucun joueur, espace réservé")
        } else {
            ForEach(team.players()) { player in
                NavigationLink {
                    PlayerDetailView(player: player)
                        .environment(tournament)
                } label: {
                    PlayerView(player: player)
                }
            }
        }
    }
}

//#Preview {
//    TeamDetailView(team: TeamRegistration.mock())
//}
