fix reg stuff

paca_championship
Raz 11 months ago
parent 78624bd422
commit a356d9768c
  1. 6
      PadelClub/Assets.xcassets/logoRed.colorset/Contents.json
  2. 6
      PadelClub/Assets.xcassets/logoYellow.colorset/Contents.json
  3. 23
      PadelClub/Data/Tournament.swift
  4. 81
      PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift
  5. 20
      PadelClub/Views/Tournament/Screen/RegisrationSetupView.swift

@ -5,9 +5,9 @@
"color-space" : "srgb", "color-space" : "srgb",
"components" : { "components" : {
"alpha" : "1.000", "alpha" : "1.000",
"blue" : "0.220", "blue" : "0x38",
"green" : "0.251", "green" : "0x40",
"red" : "0.910" "red" : "0xE8"
} }
}, },
"idiom" : "universal" "idiom" : "universal"

@ -5,9 +5,9 @@
"color-space" : "srgb", "color-space" : "srgb",
"components" : { "components" : {
"alpha" : "1.000", "alpha" : "1.000",
"blue" : "0.000", "blue" : "0x00",
"green" : "0.827", "green" : "0xD2",
"red" : "1.000" "red" : "0xFF"
} }
}, },
"idiom" : "universal" "idiom" : "universal"

@ -346,10 +346,10 @@ final class Tournament : ModelObject, Storable {
try container.encode(initialSeedRound, forKey: ._initialSeedRound) try container.encode(initialSeedRound, forKey: ._initialSeedRound)
try container.encode(initialSeedCount, forKey: ._initialSeedCount) try container.encode(initialSeedCount, forKey: ._initialSeedCount)
try container.encode(enableOnlineRegistration, forKey: ._enableOnlineRegistration) try container.encode(enableOnlineRegistration, forKey: ._enableOnlineRegistration)
try container.encodeIfPresent(registrationDateLimit, forKey: ._registrationDateLimit) try container.encode(registrationDateLimit, forKey: ._registrationDateLimit)
try container.encodeIfPresent(openingRegistrationDate, forKey: ._openingRegistrationDate) try container.encode(openingRegistrationDate, forKey: ._openingRegistrationDate)
try container.encodeIfPresent(targetTeamCount, forKey: ._targetTeamCount) try container.encode(targetTeamCount, forKey: ._targetTeamCount)
try container.encodeIfPresent(waitingListLimit, forKey: ._waitingListLimit) try container.encode(waitingListLimit, forKey: ._waitingListLimit)
try container.encode(accountIsRequired, forKey: ._accountIsRequired) try container.encode(accountIsRequired, forKey: ._accountIsRequired)
try container.encode(licenseIsRequired, forKey: ._licenseIsRequired) try container.encode(licenseIsRequired, forKey: ._licenseIsRequired)
@ -2460,7 +2460,7 @@ defer {
} }
func getOnlineRegistrationStatus() -> OnlineRegistrationStatus { func getOnlineRegistrationStatus() -> OnlineRegistrationStatus {
if supposedlyInProgress() { if hasStarted() {
return .inProgress return .inProgress
} }
if closedRegistrationDate != nil { if closedRegistrationDate != nil {
@ -2496,22 +2496,9 @@ defer {
if waitingListCount >= waitingListLimit { if waitingListCount >= waitingListLimit {
return .waitingListFull 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 .waitingListPossible
} }
return .registrationFull
}
} }
return .open return .open

@ -49,6 +49,9 @@ struct InscriptionManagerView: View {
@State private var compactMode: Bool = true @State private var compactMode: Bool = true
@State private var pasteString: String? @State private var pasteString: String?
@State private var registrationIssues: Int? = nil @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 { var tournamentStore: TournamentStore {
return self.tournament.tournamentStore return self.tournament.tournamentStore
@ -247,22 +250,19 @@ struct InscriptionManagerView: View {
RowButtonView("Importer un fichier") { RowButtonView("Importer un fichier") {
presentImportView = true 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)
} }
} }
.refreshable {
await _refreshList()
}
.onAppear { .onAppear {
_setHash() _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 { private func _teamRegisteredView() -> some View {
List { List {
let selectedSortedTeams = tournament.selectedSortedTeams() let selectedSortedTeams = tournament.selectedSortedTeams()
@ -798,7 +834,30 @@ struct InscriptionManagerView: View {
if let closedRegistrationDate = tournament.closedRegistrationDate { if let closedRegistrationDate = tournament.closedRegistrationDate {
CloseDatePicker(closedRegistrationDate: 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: { } header: {
HStack { HStack {
Spacer() Spacer()

@ -150,9 +150,10 @@ struct RegisrationSetupView: View {
if tournament.isAnimation() { if tournament.isAnimation() {
Section { Section {
Toggle(isOn: $userAccountIsRequired) { // Toggle(isOn: $userAccountIsRequired) {
Text("Compte Padel Club requis pour s'inscrire") // Text("Compte Padel Club requis pour s'inscrire")
} // }
// .disabled(true)
Toggle(isOn: $licenseIsRequired) { Toggle(isOn: $licenseIsRequired) {
Text("Licence FFT requise pour s'inscrire") Text("Licence FFT requise pour s'inscrire")
@ -304,11 +305,10 @@ enum OnlineRegistrationStatus: Int {
case notEnabled = 2 case notEnabled = 2
case notStarted = 3 case notStarted = 3
case ended = 4 case ended = 4
case registrationFull = 5 case waitingListPossible = 5
case waitingListPossible = 6 case waitingListFull = 6
case waitingListFull = 7 case inProgress = 7
case inProgress = 8 case endedWithResults = 8
case endedWithResults = 9
var displayName: String { var displayName: String {
switch self { switch self {
@ -320,8 +320,6 @@ enum OnlineRegistrationStatus: Int {
return "Not Started" return "Not Started"
case .ended: case .ended:
return "Ended" return "Ended"
case .registrationFull:
return "Registration Full"
case .waitingListPossible: case .waitingListPossible:
return "Waiting List Possible" return "Waiting List Possible"
case .waitingListFull: case .waitingListFull:
@ -343,8 +341,6 @@ enum OnlineRegistrationStatus: Int {
return "Inscription pas encore ouverte" return "Inscription pas encore ouverte"
case .ended: case .ended:
return "Inscription terminée" return "Inscription terminée"
case .registrationFull:
return "Inscription complète"
case .waitingListPossible: case .waitingListPossible:
return "Liste d'attente disponible" return "Liste d'attente disponible"
case .waitingListFull: case .waitingListFull:

Loading…
Cancel
Save