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.
127 lines
4.7 KiB
127 lines
4.7 KiB
//
|
|
// UmpireView.swift
|
|
// PadelClub
|
|
//
|
|
// Created by Razmig Sarkissian on 01/03/2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
import CoreLocation
|
|
|
|
struct UmpireView: View {
|
|
@EnvironmentObject var dataStore: DataStore
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
List {
|
|
NavigationLink {
|
|
MainUserView()
|
|
} label: {
|
|
Label("Mon compte", systemImage: "person.circle.fill")
|
|
}
|
|
NavigationLink {
|
|
SubscriptionView()
|
|
} label: {
|
|
Label("Abonnement", systemImage: "tennisball.circle.fill")
|
|
}
|
|
|
|
if let user = dataStore.user {
|
|
let currentPlayerData = user.currentPlayerData()
|
|
Section {
|
|
if let currentPlayerData {
|
|
NavigationLink {
|
|
|
|
} label: {
|
|
ImportedPlayerView(player: currentPlayerData)
|
|
}
|
|
} else {
|
|
NavigationLink {
|
|
SelectablePlayerListView(allowSelection: 1, playerSelectionAction: { players in
|
|
if let player = players.first {
|
|
user.licenceId = player.license
|
|
let club = dataStore.clubs.first(where: { $0.code == player.clubCode }) ?? Club(name: player.clubName!, code: player.clubCode!)
|
|
try? dataStore.clubs.addOrUpdate(instance: club)
|
|
user.club = club.id
|
|
dataStore.setUser(user)
|
|
}
|
|
})
|
|
} label: {
|
|
Label("Ma fiche joueur", systemImage: "person.bust.circle.fill")
|
|
}
|
|
}
|
|
} header: {
|
|
if currentPlayerData != nil {
|
|
Text("Ma fiche joueur")
|
|
}
|
|
} footer: {
|
|
if user.licenceId == nil {
|
|
Text("Si vous avez participé à un tournoi dans les 12 derniers mois, Padel Club peut vous retrouver.")
|
|
} else {
|
|
Button("supprimer", role: .destructive) {
|
|
user.licenceId = nil
|
|
dataStore.setUser(user)
|
|
}
|
|
}
|
|
}
|
|
|
|
if let clubId = user.club {
|
|
if let club = dataStore.clubs.findById(clubId) {
|
|
Section {
|
|
NavigationLink {
|
|
ClubDetailView(club: club, displayContext: .edition)
|
|
} label: {
|
|
ClubRowView(club: club)
|
|
}
|
|
} header: {
|
|
Text("Mon club")
|
|
} footer: {
|
|
Button("supprimer", role: .destructive) {
|
|
user.club = nil
|
|
dataStore.setUser(user)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Section {
|
|
NavigationLink {
|
|
ClubsView()
|
|
} label: {
|
|
LabeledContent {
|
|
Text(dataStore.clubs.count.formatted())
|
|
} label: {
|
|
Label("Mes clubs favoris", systemImage: "house.and.flag.circle.fill")
|
|
}
|
|
}
|
|
}
|
|
|
|
// Section {
|
|
// Text("Tenup ID")
|
|
// }
|
|
//
|
|
// Section {
|
|
// Text("Tournois")
|
|
// }
|
|
//
|
|
// Section {
|
|
// NavigationLink {
|
|
//
|
|
// } label: {
|
|
// Text("Favori")
|
|
// }
|
|
// NavigationLink {
|
|
//
|
|
// } label: {
|
|
// Text("Black list")
|
|
// }
|
|
// }
|
|
}
|
|
.navigationTitle("Juge-Arbitre")
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
UmpireView()
|
|
}
|
|
|