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

import SwiftUI
import LeStorage

struct PlayerView: View {
    @EnvironmentObject var dataStore: DataStore
    let player: PlayerRegistration
    
    var body: some View {
        ImportedPlayerView(player: player)
            .swipeActions(edge: .trailing, allowsFullSwipe: true) {
                Button(role: .destructive) {
                    do {
                        try dataStore.playerRegistrations.delete(instance: player)
                    } catch {
                        Logger.error(error)
                    }
                } label: {
                    LabelDelete()
                }
            }
    }
}

//#Preview {
//    PlayerView(player: PlayerRegistration.mock())
//}
