multistore
Razmig Sarkissian 1 year ago
parent 44f353e24d
commit 48e872a41b
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 2
      PadelClub/Data/Event.swift
  3. 9
      PadelClub/Data/Tournament.swift
  4. 18
      PadelClub/Views/Navigation/Agenda/EventListView.swift
  5. 21
      PadelClub/Views/Navigation/Toolbox/ToolboxView.swift
  6. 11
      PadelClub/Views/Tournament/Screen/Components/TournamentStatusView.swift
  7. 4
      PadelClub/Views/Tournament/TournamentInitView.swift

@ -1882,7 +1882,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 72; CURRENT_PROJECT_VERSION = 73;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
@ -1922,7 +1922,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 72; CURRENT_PROJECT_VERSION = 73;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6; DEVELOPMENT_TEAM = BQ3Y44M3Q6;

@ -37,7 +37,7 @@ class Event: ModelObject, Storable {
// MARK: - Computed dependencies // MARK: - Computed dependencies
var tournaments: [Tournament] { var tournaments: [Tournament] {
DataStore.shared.tournaments.filter { $0.event == self.id } DataStore.shared.tournaments.filter { $0.event == self.id && $0.isDeleted == false }
} }
func clubObject() -> Club? { func clubObject() -> Club? {

@ -1258,6 +1258,15 @@ defer {
return [tournamentLevel.localizedLabel(displayStyle) + " " + tournamentCategory.localizedLabel(), displayStyle == .wide ? name : nil].compactMap({ $0 }).joined(separator: " - ") return [tournamentLevel.localizedLabel(displayStyle) + " " + tournamentCategory.localizedLabel(), displayStyle == .wide ? name : nil].compactMap({ $0 }).joined(separator: " - ")
} }
func localizedTournamentType() -> String {
switch tournamentLevel {
case .unlisted:
return tournamentLevel.localizedLabel(.short)
default:
return tournamentLevel.localizedLabel(.short) + tournamentCategory.localizedLabel(.short)
}
}
func hideWeight() -> Bool { func hideWeight() -> Bool {
return tournamentLevel.hideWeight() return tournamentLevel.hideWeight()
} }

@ -110,6 +110,24 @@ struct EventListView: View {
Label("Voir dans le gestionnaire", systemImage: "line.diagonal.arrow") Label("Voir dans le gestionnaire", systemImage: "line.diagonal.arrow")
} }
} }
#if DEBUG
.swipeActions(edge: .trailing, allowsFullSwipe: true) {
Button(role: .destructive) {
do {
let event = tournament.eventObject()
let isLastTournament = event?.tournaments.count == 1
try dataStore.tournaments.delete(instance: tournament)
if let event, isLastTournament {
try dataStore.events.delete(instance: event)
}
} catch {
Logger.error(error)
}
} label: {
LabelDelete()
}
}
#endif
} }
private func _federalTournamentView(_ federalTournament: FederalTournament) -> some View { private func _federalTournamentView(_ federalTournament: FederalTournament) -> some View {

@ -11,7 +11,8 @@ import LeStorage
struct ToolboxView: View { struct ToolboxView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@Environment(NavigationViewModel.self) private var navigation: NavigationViewModel @Environment(NavigationViewModel.self) private var navigation: NavigationViewModel
@State private var didResetApiCalls: Bool = false
var body: some View { var body: some View {
@Bindable var navigation = navigation @Bindable var navigation = navigation
NavigationStack(path: $navigation.toolboxPath) { NavigationStack(path: $navigation.toolboxPath) {
@ -19,6 +20,11 @@ struct ToolboxView: View {
Section { Section {
Text("Version de l'application").badge(PadelClubApp.appVersion) Text("Version de l'application").badge(PadelClubApp.appVersion)
.onTapGesture(count: 5) {
Store.main.resetApiCalls()
didResetApiCalls = true
}
SupportButtonView(contentIsUnavailable: false) SupportButtonView(contentIsUnavailable: false)
if Store.main.userId == "94f45ed2-8938-4c32-a4b6-e4525073dd33" { if Store.main.userId == "94f45ed2-8938-4c32-a4b6-e4525073dd33" {
@ -137,6 +143,19 @@ struct ToolboxView: View {
Link("Accéder au guide de la compétition de la FFT", destination: URLs.padelRules.url) Link("Accéder au guide de la compétition de la FFT", destination: URLs.padelRules.url)
} }
} }
.overlay(alignment: .bottom) {
if didResetApiCalls {
Label("failed api calls deleted", systemImage: "checkmark")
.toastFormatted()
.deferredRendering(for: .seconds(3))
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
didResetApiCalls = false
}
}
}
}
.navigationTitle(TabDestination.toolbox.title) .navigationTitle(TabDestination.toolbox.title)
} }
} }

@ -46,7 +46,12 @@ struct TournamentStatusView: View {
RowButtonView("Supprimer le tournoi", role: .destructive) { RowButtonView("Supprimer le tournoi", role: .destructive) {
if tournament.payment == nil { if tournament.payment == nil {
do { do {
let event = tournament.eventObject()
let isLastTournament = event?.tournaments.count == 1
try dataStore.tournaments.delete(instance: tournament) try dataStore.tournaments.delete(instance: tournament)
if let event, isLastTournament {
try dataStore.events.delete(instance: event)
}
} catch { } catch {
Logger.error(error) Logger.error(error)
} }
@ -62,10 +67,6 @@ struct TournamentStatusView: View {
} }
navigation.path = NavigationPath() navigation.path = NavigationPath()
} }
} footer: {
if tournament.payment == nil {
Text("")
}
} }
if tournament.hasEnded() == false && tournament.isCanceled == false { if tournament.hasEnded() == false && tournament.isCanceled == false {
@ -81,7 +82,7 @@ struct TournamentStatusView: View {
dismiss() dismiss()
} }
} footer: { } footer: {
Text(.init("Si votre tournoi n'a pas pu aboutir à cause de la météo ou autre, vous pouvez l'annuler et il ne sera pas comptabilisé. Toutes les données du tournoi seront conservées. Le tournoi visible sur [Padel Club](\(URLs.main.rawValue))")) Text(.init("Si votre tournoi n'a pas pu aboutir à cause de la météo ou autre, vous pouvez l'annuler et il ne sera pas comptabilisé. Toutes les données du tournoi seront conservées. Le tournoi reste visible sur [Padel Club](\(URLs.main.rawValue))"))
} }
} }

@ -41,10 +41,10 @@ struct TournamentInitView: View {
NavigationLink(value: Screen.settings) { NavigationLink(value: Screen.settings) {
LabeledContent { LabeledContent {
Text(tournament.tournamentTitle(.short)) Text(tournament.localizedTournamentType())
} label: { } label: {
LabelSettings() LabelSettings()
Text("Formats, statut, club, prix, etc.") Text("Formats, club, prix et plus")
} }
} }

Loading…
Cancel
Save