diff --git a/PadelClub/Assets.xcassets/logoRed.colorset/Contents.json b/PadelClub/Assets.xcassets/logoRed.colorset/Contents.json index ded2ed9..7c05d3f 100644 --- a/PadelClub/Assets.xcassets/logoRed.colorset/Contents.json +++ b/PadelClub/Assets.xcassets/logoRed.colorset/Contents.json @@ -5,9 +5,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0.220", - "green" : "0.251", - "red" : "0.910" + "blue" : "0x38", + "green" : "0x40", + "red" : "0xE8" } }, "idiom" : "universal" diff --git a/PadelClub/Assets.xcassets/logoYellow.colorset/Contents.json b/PadelClub/Assets.xcassets/logoYellow.colorset/Contents.json index afbfa83..93a4a81 100644 --- a/PadelClub/Assets.xcassets/logoYellow.colorset/Contents.json +++ b/PadelClub/Assets.xcassets/logoYellow.colorset/Contents.json @@ -5,9 +5,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0.000", - "green" : "0.827", - "red" : "1.000" + "blue" : "0x00", + "green" : "0xD2", + "red" : "0xFF" } }, "idiom" : "universal" diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index 2e11f4c..b2f3407 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -346,10 +346,10 @@ final class Tournament : ModelObject, Storable { try container.encode(initialSeedRound, forKey: ._initialSeedRound) try container.encode(initialSeedCount, forKey: ._initialSeedCount) try container.encode(enableOnlineRegistration, forKey: ._enableOnlineRegistration) - try container.encodeIfPresent(registrationDateLimit, forKey: ._registrationDateLimit) - try container.encodeIfPresent(openingRegistrationDate, forKey: ._openingRegistrationDate) - try container.encodeIfPresent(targetTeamCount, forKey: ._targetTeamCount) - try container.encodeIfPresent(waitingListLimit, forKey: ._waitingListLimit) + try container.encode(registrationDateLimit, forKey: ._registrationDateLimit) + try container.encode(openingRegistrationDate, forKey: ._openingRegistrationDate) + try container.encode(targetTeamCount, forKey: ._targetTeamCount) + try container.encode(waitingListLimit, forKey: ._waitingListLimit) try container.encode(accountIsRequired, forKey: ._accountIsRequired) try container.encode(licenseIsRequired, forKey: ._licenseIsRequired) @@ -2460,7 +2460,7 @@ defer { } func getOnlineRegistrationStatus() -> OnlineRegistrationStatus { - if supposedlyInProgress() { + if hasStarted() { return .inProgress } if closedRegistrationDate != nil { @@ -2496,21 +2496,8 @@ defer { if waitingListCount >= waitingListLimit { return .waitingListFull } - return .waitingListPossible } - return .registrationFull - } - - let nonWalkoutTeamCount = currentTeamCount - if nonWalkoutTeamCount >= targetTeamCount { - if let waitingListLimit = waitingListLimit { - let waitingListCount = nonWalkoutTeamCount - targetTeamCount - if waitingListCount >= waitingListLimit { - return .waitingListFull - } - return .waitingListPossible - } - return .registrationFull + return .waitingListPossible } } diff --git a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift index 8da301b..4117005 100644 --- a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift +++ b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift @@ -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() diff --git a/PadelClub/Views/Tournament/Screen/RegisrationSetupView.swift b/PadelClub/Views/Tournament/Screen/RegisrationSetupView.swift index 3c2fd13..f602265 100644 --- a/PadelClub/Views/Tournament/Screen/RegisrationSetupView.swift +++ b/PadelClub/Views/Tournament/Screen/RegisrationSetupView.swift @@ -150,9 +150,10 @@ struct RegisrationSetupView: View { if tournament.isAnimation() { Section { - Toggle(isOn: $userAccountIsRequired) { - Text("Compte Padel Club requis pour s'inscrire") - } +// Toggle(isOn: $userAccountIsRequired) { +// Text("Compte Padel Club requis pour s'inscrire") +// } +// .disabled(true) Toggle(isOn: $licenseIsRequired) { Text("Licence FFT requise pour s'inscrire") @@ -304,11 +305,10 @@ enum OnlineRegistrationStatus: Int { case notEnabled = 2 case notStarted = 3 case ended = 4 - case registrationFull = 5 - case waitingListPossible = 6 - case waitingListFull = 7 - case inProgress = 8 - case endedWithResults = 9 + case waitingListPossible = 5 + case waitingListFull = 6 + case inProgress = 7 + case endedWithResults = 8 var displayName: String { switch self { @@ -320,8 +320,6 @@ enum OnlineRegistrationStatus: Int { return "Not Started" case .ended: return "Ended" - case .registrationFull: - return "Registration Full" case .waitingListPossible: return "Waiting List Possible" case .waitingListFull: @@ -343,8 +341,6 @@ enum OnlineRegistrationStatus: Int { return "Inscription pas encore ouverte" case .ended: return "Inscription terminée" - case .registrationFull: - return "Inscription complète" case .waitingListPossible: return "Liste d'attente disponible" case .waitingListFull: