|
|
|
|
@ -49,6 +49,9 @@ struct InscriptionManagerView: View { |
|
|
|
|
@State private var compactMode: Bool = true |
|
|
|
|
@State private var pasteString: String? |
|
|
|
|
@State private var registrationIssues: Int? = nil |
|
|
|
|
@State private var refreshResult: String? = nil |
|
|
|
|
@State private var refreshInProgress: Bool = false |
|
|
|
|
@State private var refreshStatus: Bool? |
|
|
|
|
|
|
|
|
|
var tournamentStore: TournamentStore { |
|
|
|
|
return self.tournament.tournamentStore |
|
|
|
|
@ -247,21 +250,18 @@ struct InscriptionManagerView: View { |
|
|
|
|
RowButtonView("Importer un fichier") { |
|
|
|
|
presentImportView = true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if tournament.enableOnlineRegistration { |
|
|
|
|
RowButtonView("Rafraîchir la liste") { |
|
|
|
|
await _refreshList() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.refreshable { |
|
|
|
|
do { |
|
|
|
|
self.tournament.tournamentStore.playerRegistrations.reset() |
|
|
|
|
try await self.tournament.tournamentStore.playerRegistrations.loadDataFromServerIfAllowed() |
|
|
|
|
|
|
|
|
|
self.tournament.tournamentStore.teamRegistrations.reset() |
|
|
|
|
try await self.tournament.tournamentStore.teamRegistrations.loadDataFromServerIfAllowed() |
|
|
|
|
_setHash() |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
await _refreshList() |
|
|
|
|
} |
|
|
|
|
.onAppear { |
|
|
|
|
_setHash() |
|
|
|
|
@ -537,6 +537,42 @@ struct InscriptionManagerView: View { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _refreshList() async { |
|
|
|
|
if refreshInProgress { return } |
|
|
|
|
|
|
|
|
|
refreshResult = nil |
|
|
|
|
refreshStatus = nil |
|
|
|
|
refreshInProgress = true |
|
|
|
|
do { |
|
|
|
|
|
|
|
|
|
let storeIdentifier = StoreIdentifier(value: tournament.id, parameterName: "tournament") |
|
|
|
|
let serverPlayers: [PlayerRegistration] = try await StoreCenter.main.service().get(identifier: storeIdentifier) |
|
|
|
|
let serverTeamScores: [TeamScore] = try await StoreCenter.main.service().get(identifier: storeIdentifier) |
|
|
|
|
let serverTeams: [TeamRegistration] = try await StoreCenter.main.service().get(identifier: storeIdentifier) |
|
|
|
|
|
|
|
|
|
self.tournamentStore.playerRegistrations.reset() |
|
|
|
|
self.tournamentStore.teamScores.reset() |
|
|
|
|
self.tournamentStore.teamRegistrations.reset() |
|
|
|
|
|
|
|
|
|
try self.tournamentStore.playerRegistrations.addOrUpdate(contentOfs: serverPlayers) |
|
|
|
|
try self.tournamentStore.teamScores.addOrUpdate(contentOfs: serverTeamScores) |
|
|
|
|
try self.tournamentStore.teamRegistrations.addOrUpdate(contentOfs: serverTeams) |
|
|
|
|
|
|
|
|
|
_setHash() |
|
|
|
|
|
|
|
|
|
self.refreshResult = "la synchronization a réussi" |
|
|
|
|
self.refreshStatus = true |
|
|
|
|
refreshInProgress = false |
|
|
|
|
|
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
|
|
|
|
|
self.refreshResult = "la synchronization a échoué" |
|
|
|
|
self.refreshStatus = false |
|
|
|
|
refreshInProgress = false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _teamRegisteredView() -> some View { |
|
|
|
|
List { |
|
|
|
|
let selectedSortedTeams = tournament.selectedSortedTeams() |
|
|
|
|
@ -798,7 +834,30 @@ struct InscriptionManagerView: View { |
|
|
|
|
if let closedRegistrationDate = tournament.closedRegistrationDate { |
|
|
|
|
CloseDatePicker(closedRegistrationDate: closedRegistrationDate) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if tournament.enableOnlineRegistration { |
|
|
|
|
Button { |
|
|
|
|
Task { |
|
|
|
|
await _refreshList() |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
LabeledContent { |
|
|
|
|
if refreshInProgress { |
|
|
|
|
ProgressView() |
|
|
|
|
} else if let refreshStatus { |
|
|
|
|
if refreshStatus { |
|
|
|
|
Image(systemName: "checkmark").foregroundStyle(.green).font(.headline) |
|
|
|
|
} else { |
|
|
|
|
Image(systemName: "xmark").foregroundStyle(.logoRed).font(.headline) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
Text("Récupérer les inscriptions en ligne") |
|
|
|
|
if let refreshResult { |
|
|
|
|
Text(refreshResult) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} header: { |
|
|
|
|
HStack { |
|
|
|
|
Spacer() |
|
|
|
|
|