//
//  TeamRowView.swift
//  PadelClub
//
//  Created by Razmig Sarkissian on 24/03/2024.
//

import SwiftUI

struct TeamRowView: View {
    var team: TeamRegistration
    var teamPosition: TeamPosition? = nil
    var displayCallDate: Bool = false
    
    var body: some View {
        LabeledContent {
            TeamWeightView(team: team, teamPosition: teamPosition)
        } label: {
            VStack(alignment: .leading) {
                if let name = team.name {
                    Text(name).foregroundStyle(.secondary)
                }
                ForEach(team.players()) { player in
                    Text(player.playerLabel())
                }
            }
            if let callDate = team.callDate, displayCallDate {
                Text("Déjà convoquée \(callDate.localizedDate())")
                    .foregroundStyle(.red)
                    .italic()
                    .font(.caption)
            }
        }
    }
}

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