parent
9dc16f9c81
commit
2987c509c5
@ -0,0 +1,70 @@ |
||||
// |
||||
// TournamentInscriptionView.swift |
||||
// PadelClub |
||||
// |
||||
// Created by Razmig Sarkissian on 19/05/2024. |
||||
// |
||||
|
||||
import SwiftUI |
||||
import LeStorage |
||||
|
||||
struct TournamentInscriptionView: View { |
||||
@EnvironmentObject var dataStore: DataStore |
||||
var tournament: Tournament |
||||
|
||||
@ViewBuilder |
||||
var body: some View { |
||||
Section { |
||||
NavigationLink(value: Screen.inscription) { |
||||
LabeledContent { |
||||
Text(tournament.unsortedTeams().count.formatted() + "/" + tournament.teamCount.formatted()) |
||||
} label: { |
||||
Text("Gestion des inscriptions") |
||||
if let closedRegistrationDate = tournament.closedRegistrationDate { |
||||
Text("clôturé le " + closedRegistrationDate.formatted(date: .abbreviated, time: .shortened)) |
||||
} |
||||
} |
||||
} |
||||
if let endOfInscriptionDate = tournament.mandatoryRegistrationCloseDate(), tournament.inscriptionClosed() == false && tournament.hasStarted() == false { |
||||
LabeledContent { |
||||
Text(endOfInscriptionDate.formatted(date: .abbreviated, time: .shortened)) |
||||
} label: { |
||||
Text("Date limite") |
||||
} |
||||
} |
||||
|
||||
if tournament.state() != .running { |
||||
NavigationLink(value: Screen.structure) { |
||||
LabeledContent { |
||||
Text(tournament.structureDescriptionLocalizedLabel()) |
||||
.tint(.master) |
||||
} label: { |
||||
LabelStructure() |
||||
} |
||||
} |
||||
} |
||||
} footer: { |
||||
if tournament.inscriptionClosed() == false && tournament.state() == .build && tournament.unsortedTeams().isEmpty == false && tournament.hasStarted() == false { |
||||
Button { |
||||
tournament.lockRegistration() |
||||
_save() |
||||
} label: { |
||||
Text("clôturer les inscriptions") |
||||
.underline() |
||||
} |
||||
.buttonStyle(.borderless) |
||||
} else if tournament.state() != .running { |
||||
Text("Nombre d'équipes, de poules, de qualifiés sortant, etc.") |
||||
} |
||||
} |
||||
} |
||||
|
||||
private func _save() { |
||||
do { |
||||
try dataStore.tournaments.addOrUpdate(instance: tournament) |
||||
} catch { |
||||
Logger.error(error) |
||||
} |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue