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. 12
      PadelClub/Views/Team/EditingTeamView.swift
  8. 5
      PadelClub/Views/Tournament/Screen/AddTeamView.swift

@ -2390,11 +2390,16 @@ defer {
func refreshTeamList(forced: Bool) async { func refreshTeamList(forced: Bool) async {
guard StoreCenter.main.isAuthenticated else { return } guard StoreCenter.main.isAuthenticated else { return }
guard tournamentStore?.store.fileCollectionsAllLoaded() == true 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 refreshInProgress = true
do { do {
try await self.tournamentStore?.playerRegistrations.loadDataFromServerIfAllowed(clear: true) 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) try await self.tournamentStore?.teamRegistrations.loadDataFromServerIfAllowed(clear: true)
refreshInProgress = false refreshInProgress = false
lastTeamRefresh = Date() lastTeamRefresh = Date()

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

@ -324,10 +324,18 @@ struct EventListView: View {
if let store = notification.object as? SyncedCollection<TeamRegistration> { if let store = notification.object as? SyncedCollection<TeamRegistration> {
if store.storeId == tournament.id { 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) .id(tournament.lastTeamRefresh)
.task(priority: .background) { .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") .navigationTitle("Juge-Arbitre")
.toolbar { .toolbar {
#if DEBUG #if DEBUG

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

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

@ -78,10 +78,9 @@ struct EditingTeamView: View {
var body: some View { var body: some View {
List { List {
Section { 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 editedTeam = team
} }
.disabled(team.hasPaidOnline())
TeamDetailView(team: team) TeamDetailView(team: team)
} header: { } header: {
if team.hasRegisteredOnline() { if team.hasRegisteredOnline() {
@ -90,9 +89,6 @@ struct EditingTeamView: View {
Text("Inscription par vous-même") Text("Inscription par vous-même")
} }
} footer: { } 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 { HStack {
CopyPasteButtonView(pasteValue: team.playersPasteData()) CopyPasteButtonView(pasteValue: team.playersPasteData())
Spacer() Spacer()
@ -105,7 +101,6 @@ struct EditingTeamView: View {
} }
} }
} }
}
.headerProminence(.increased) .headerProminence(.increased)
if team.hasRegisteredOnline() || team.hasPaidOnline() { if team.hasRegisteredOnline() || team.hasPaidOnline() {
@ -242,8 +237,11 @@ struct EditingTeamView: View {
} }
dismiss() dismiss()
} }
.disabled(team.hasPaidOnline())
} footer: { } 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) 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) { if tournament.isPlayerRankInadequate(player: p) {
Text("Trop bien classé !").foregroundStyle(.logoRed).bold() 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) PlayerView(player: p).tag(p.id)
.environment(tournament) .environment(tournament)
} }
.selectionDisabled(p.captain && p.hasPaidOnline())
} }
if let p = fetchPlayers.first(where: { $0.license == id }) { if let p = fetchPlayers.first(where: { $0.license == id }) {
VStack(alignment: .leading, spacing: 0) { VStack(alignment: .leading, spacing: 0) {

Loading…
Cancel
Save