add payment stuff

online_payment
Raz 7 months ago
commit 9d31ee90d1
  1. 8
      PadelClub/Data/Federal/FederalTournament.swift
  2. 10
      PadelClub/Views/Cashier/Event/EventCreationView.swift
  3. 28
      PadelClub/Views/Club/ClubSearchView.swift
  4. 1
      PadelClub/Views/Club/CreateClubView.swift
  5. 1
      PadelClub/Views/Navigation/MainView.swift
  6. 8
      PadelClub/Views/Navigation/Umpire/UmpireView.swift
  7. 10
      PadelClub/Views/Tournament/Screen/Components/EventClubSettingsView.swift

@ -40,6 +40,14 @@ struct FederalTournament: Identifiable, Codable {
Logger.error(error)
}
}
if let club, club.creator == nil {
club.creator = StoreCenter.main.userId
do {
try DataStore.shared.clubs.addOrUpdate(instance: club)
} catch {
Logger.error(error)
}
}
return event!
}

@ -131,7 +131,15 @@ struct EventCreationView: View {
private func _validate() {
let event = Event(creator: StoreCenter.main.userId, name: eventName)
event.club = selectedClub?.id
if let selectedClub, selectedClub.creator == nil {
selectedClub.creator = StoreCenter.main.userId
do {
try dataStore.clubs.addOrUpdate(instance: selectedClub)
} catch {
Logger.error(error)
}
}
do {
try dataStore.events.addOrUpdate(instance: event)
} catch {

@ -28,6 +28,7 @@ struct ClubSearchView: View {
@State private var showingSettingsAlert = false
@State private var newClub: Club?
@State private var error: Error?
@State private var selectedClubId: String?
var presentClubCreationView: Binding<Bool> { Binding(
get: { newClub != nil },
@ -90,8 +91,18 @@ struct ClubSearchView: View {
Section {
ForEach(_filteredClubs()) { clubMark in
Button {
let clubToEdit = club ?? Club.findOrCreate(name: clubMark.nom, code: clubMark.clubID)
_importClub(clubToEdit: clubToEdit, clubMarker: clubMark)
Task {
selectedClubId = clubMark.id
do {
dataStore.clubs.reset()
try await dataStore.clubs.loadDataFromServerIfAllowed()
} catch {
Logger.error(error)
}
let clubToEdit = club ?? Club.findOrCreate(name: clubMark.nom, code: clubMark.clubID)
_importClub(clubToEdit: clubToEdit, clubMarker: clubMark)
selectedClubId = nil
}
} label: {
clubView(clubMark)
.contentShape(Rectangle())
@ -118,13 +129,6 @@ struct ClubSearchView: View {
}
}
}
.task {
do {
try await dataStore.clubs.loadDataFromServerIfAllowed()
} catch {
Logger.error(error)
}
}
.listStyle(.grouped)
.onChange(of: searchPresented) {
locationManager.lastError = nil
@ -385,7 +389,11 @@ struct ClubSearchView: View {
@ViewBuilder
private func clubView(_ club: ClubMarker) -> some View {
LabeledContent {
Text(club.distance(from: locationManager.location))
if club.id == selectedClubId {
ProgressView()
} else {
Text(club.distance(from: locationManager.location))
}
} label: {
Text(club.nom).lineLimit(1)
Text(club.ville).font(.caption)

@ -44,6 +44,7 @@ struct CreateClubView: View {
if validationInProgress {
Task {
do {
dataStore.clubs.reset()
try await dataStore.clubs.loadDataFromServerIfAllowed()
} catch {
Logger.error(error)

@ -103,6 +103,7 @@ struct MainView: View {
//await self._checkSourceFileAvailability()
if StoreCenter.main.isAuthenticated {
do {
dataStore.clubs.reset()
try await dataStore.clubs.loadDataFromServerIfAllowed()
} catch {
Logger.error(error)

@ -322,17 +322,9 @@ struct UmpireView: View {
}
user.setUserClub(userClub)
}
self.dataStore.saveUser()
}
})
}
.task {
do {
try await dataStore.clubs.loadDataFromServerIfAllowed()
} catch {
Logger.error(error)
}
}
}
.navigationDestination(for: UmpireScreen.self) { screen in
switch screen {

@ -71,6 +71,16 @@ struct EventClubSettingsView: View {
private func _setClub(club: Club) {
event.club = club.id
if club.creator == nil {
club.creator = StoreCenter.main.userId
do {
try dataStore.clubs.addOrUpdate(instance: club)
} catch {
Logger.error(error)
}
}
do {
try dataStore.events.addOrUpdate(instance: event)
} catch {

Loading…
Cancel
Save