fix online payment stuff

online_payment
Raz 7 months ago
parent dafc180b61
commit 7988a9585c
  1. 9
      PadelClub/Data/Tournament.swift
  2. 2
      PadelClub/Utils/Network/RefundService.swift
  3. 12
      PadelClub/Views/Navigation/Agenda/EventListView.swift
  4. 5
      PadelClub/Views/Navigation/Umpire/UmpireView.swift
  5. 4
      PadelClub/Views/Player/Components/PlayerPayView.swift
  6. 14
      PadelClub/Views/Player/PlayerDetailView.swift
  7. 30
      PadelClub/Views/Team/EditingTeamView.swift
  8. 5
      PadelClub/Views/Tournament/Screen/AddTeamView.swift

@ -2390,11 +2390,16 @@ defer {
func refreshTeamList(forced: Bool) async {
guard StoreCenter.main.isAuthenticated else { return }
guard tournamentStore?.store.fileCollectionsAllLoaded() == true else { return }
guard shouldRefreshTeams(forced: forced), refreshInProgress == false, enableOnlineRegistration, hasEnded() == false else { return }
guard shouldRefreshTeams(forced: forced), refreshInProgress == false else { return }
if forced == false {
guard enableOnlineRegistration, hasEnded() == false else {
return
}
}
refreshInProgress = true
do {
try await self.tournamentStore?.playerRegistrations.loadDataFromServerIfAllowed(clear: true)
try await self.tournamentStore?.teamScores.loadDataFromServerIfAllowed(clear: true)
//try await self.tournamentStore?.teamScores.loadDataFromServerIfAllowed(clear: true)
try await self.tournamentStore?.teamRegistrations.loadDataFromServerIfAllowed(clear: true)
refreshInProgress = false
lastTeamRefresh = Date()

@ -20,7 +20,7 @@ class RefundService {
throw RefundError.requestFailed
}
let refundResponse = try JSONDecoder().decode(RefundResponse.self, from: data)
let refundResponse = try JSON.decoder.decode(RefundResponse.self, from: data)
return refundResponse
}
}

@ -324,10 +324,18 @@ struct EventListView: View {
if let store = notification.object as? SyncedCollection<TeamRegistration> {
if store.storeId == tournament.id {
tournament.lastTeamRefresh = Date()
if tournament.store?.fileCollectionsAllLoaded() == true {
tournament.lastTeamRefresh = nil
}
}
}
if let store = notification.object as? SyncedCollection<PlayerRegistration> {
if store.storeId == tournament.id {
if tournament.store?.fileCollectionsAllLoaded() == true {
tournament.lastTeamRefresh = nil
}
}
}
})
.id(tournament.lastTeamRefresh)
.task(priority: .background) {

@ -243,7 +243,10 @@ struct UmpireView: View {
// }
// }
}
.id(StoreCenter.main.isAuthenticated)
.onChange(of: StoreCenter.main.userId) {
license = dataStore.user.licenceId ?? ""
licenseMessage = nil
}
.navigationTitle("Juge-Arbitre")
.toolbar {
#if DEBUG

@ -20,7 +20,11 @@ struct PlayerPayView: View {
Text(type.localizedLabel()).tag(type as PlayerPaymentType?)
}
} label: {
if player.hasPaidOnline() {
Text("a payé en ligne").foregroundStyle(.logoRed)
}
}
.disabled(player.hasPaidOnline())
.pickerStyle(.menu)
.fixedSize()
.onChange(of: player.paymentType) {

@ -38,20 +38,28 @@ struct PlayerDetailView: View {
Text("Source des informations")
}
if tournament.enableOnlineRegistration {
if tournament.enableOnlineRegistration || player.registeredOnline || player.hasPaidOnline() {
Section {
LabeledContent {
Text(player.registeredOnline ? "Oui" : "Non")
} label: {
Text("Inscription en ligne")
}
if player.captain {
LabeledContent {
Text(player.hasPaidOnline() ? "Oui" : "Non")
} label: {
Text("A payé pour l'équipe en ligne")
}
}
}
}
Section {
Toggle("Joueur sur place", isOn: $player.hasArrived)
Toggle("Capitaine", isOn: $player.captain)
Toggle("Coach", isOn: $player.coach)
//Toggle("Capitaine", isOn: $player.captain).disabled(player.hasPaidOnline())
//Toggle("Coach", isOn: $player.coach)
}
Section {

@ -78,10 +78,9 @@ struct EditingTeamView: View {
var body: some View {
List {
Section {
RowButtonView("Modifier la composition de l'équipe", role: team.hasRegisteredOnline() ? .destructive : .none, confirmationMessage: "Vous êtes sur le point de modifier une équipe qui s'est inscrite en ligne.") {
RowButtonView("Modifier la composition de l'équipe", role: (team.hasRegisteredOnline() || team.hasPaidOnline()) ? .destructive : .none, confirmationMessage: "Vous êtes sur le point de modifier une équipe qui s'est inscrite en ligne.") {
editedTeam = team
}
.disabled(team.hasPaidOnline())
TeamDetailView(team: team)
} header: {
if team.hasRegisteredOnline() {
@ -90,19 +89,15 @@ struct EditingTeamView: View {
Text("Inscription par vous-même")
}
} footer: {
if team.hasPaidOnline() {
Text("Cette équipe a réglé son inscription en ligne, la modification de l'équipe est impossible.").foregroundStyle(.logoRed)
} else {
HStack {
CopyPasteButtonView(pasteValue: team.playersPasteData())
Spacer()
NavigationLink {
GroupStageTeamReplacementView(team: team)
.environment(tournament)
} label: {
Text("Chercher à remplacer")
.underline()
}
HStack {
CopyPasteButtonView(pasteValue: team.playersPasteData())
Spacer()
NavigationLink {
GroupStageTeamReplacementView(team: team)
.environment(tournament)
} label: {
Text("Chercher à remplacer")
.underline()
}
}
}
@ -242,8 +237,11 @@ struct EditingTeamView: View {
}
dismiss()
}
.disabled(team.hasPaidOnline())
} footer: {
if team.hasRegisteredOnline() {
if team.hasPaidOnline() {
Text("Il n'est pas possible de supprimer cette équipe, leur inscription a été payée en ligne. Vous pouvez les mettre forfait et/ou les rembourser.").foregroundStyle(.logoRed)
} else if team.hasRegisteredOnline() {
Text("Attention, supprimer cette équipe notifiera par email que leur inscription a été annulée.").foregroundStyle(.logoRed)
}
}

@ -492,9 +492,14 @@ struct AddTeamView: View {
if tournament.isPlayerRankInadequate(player: p) {
Text("Trop bien classé !").foregroundStyle(.logoRed).bold()
}
if p.captain, p.hasPaidOnline() {
Text("A payé pour l'équipe en ligne").foregroundStyle(.logoRed).bold()
}
PlayerView(player: p).tag(p.id)
.environment(tournament)
}
.selectionDisabled(p.captain && p.hasPaidOnline())
}
if let p = fetchPlayers.first(where: { $0.license == id }) {
VStack(alignment: .leading, spacing: 0) {

Loading…
Cancel
Save