diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 542e56d..0e37f4d 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -3174,7 +3174,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 9; + CURRENT_PROJECT_VERSION = 10; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; @@ -3219,7 +3219,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 9; + CURRENT_PROJECT_VERSION = 10; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; diff --git a/PadelClub/ViewModel/FederalDataViewModel.swift b/PadelClub/ViewModel/FederalDataViewModel.swift index 71c0cf1..a5579b7 100644 --- a/PadelClub/ViewModel/FederalDataViewModel.swift +++ b/PadelClub/ViewModel/FederalDataViewModel.swift @@ -22,7 +22,8 @@ class FederalDataViewModel { var searchAttemptCount: Int = 0 var dayDuration: Int? var dayPeriod: DayPeriod = .all - + var lastError: NetworkManagerError? + func filterStatus() -> String { var labels: [String] = [] labels.append(contentsOf: levels.map { $0.localizedLevelLabel() }.formatList()) diff --git a/PadelClub/Views/Navigation/Agenda/ActivityView.swift b/PadelClub/Views/Navigation/Agenda/ActivityView.swift index 58eb1fb..48bdf11 100644 --- a/PadelClub/Views/Navigation/Agenda/ActivityView.swift +++ b/PadelClub/Views/Navigation/Agenda/ActivityView.swift @@ -134,8 +134,12 @@ struct ActivityView: View { ContentUnavailableView { Label("Une erreur est survenue", systemImage: "exclamationmark.circle.fill") } description: { - Text(error.localizedDescription) + Text("Tenup est peut-être en maintenance. " + error.localizedDescription) } actions: { + Link(destination: URLs.tenup.url) { + Text("Voir si tenup est en maintenance") + } + RowButtonView("D'accord.") { self.error = nil } @@ -510,15 +514,32 @@ struct ActivityView: View { .padding() } } else { - ContentUnavailableView { - Label("Aucun tournoi", systemImage: "shield.slash") - } description: { - Text("Aucun tournoi ne correspond aux critères sélectionnés.") - } actions: { - FooterButtonView("modifier vos critères de recherche") { - displaySearchView = true + if federalDataViewModel.lastError == nil { + ContentUnavailableView { + Label("Aucun tournoi", systemImage: "shield.slash") + } description: { + Text("Aucun tournoi ne correspond aux critères sélectionnés.") + } actions: { + FooterButtonView("modifier vos critères de recherche") { + displaySearchView = true + } + .padding() + } + } else { + ContentUnavailableView { + Label("Une erreur est survenue", systemImage: "exclamationmark.circle.fill") + } description: { + Text("Tenup est peut-être en maintenance, veuillez ré-essayer plus tard.") + } actions: { + Link(destination: URLs.tenup.url) { + Text("Voir si tenup est en maintenance") + } + + FooterButtonView("modifier vos critères de recherche") { + displaySearchView = true + } + .padding() } - .padding() } } } diff --git a/PadelClub/Views/Navigation/Agenda/TournamentLookUpView.swift b/PadelClub/Views/Navigation/Agenda/TournamentLookUpView.swift index 396fb0d..93e9aa6 100644 --- a/PadelClub/Views/Navigation/Agenda/TournamentLookUpView.swift +++ b/PadelClub/Views/Navigation/Agenda/TournamentLookUpView.swift @@ -181,6 +181,7 @@ struct TournamentLookUpView: View { federalDataViewModel.levels = Set(levels) federalDataViewModel.categories = Set(categories) federalDataViewModel.ageCategories = Set(ages) + federalDataViewModel.lastError = nil Task { await getNewPage() @@ -223,7 +224,12 @@ struct TournamentLookUpView: View { await getNewBuildForm() } else { let commands = try await NetworkFederalService.shared.getAllFederalTournaments(sortingOption: dataStore.appSettings.sortingOption, page: page, startDate: dataStore.appSettings.startDate, endDate: dataStore.appSettings.endDate, city: dataStore.appSettings.city, distance: dataStore.appSettings.distance, categories: categories, levels: levels, lat: locationManager.location?.coordinate.latitude.formatted(.number.locale(Locale(identifier: "us"))), lng: locationManager.location?.coordinate.longitude.formatted(.number.locale(Locale(identifier: "us"))), ages: ages, types: types, nationalCup: dataStore.appSettings.nationalCup) + if commands.anySatisfy({ $0.command == "alert" }) { + federalDataViewModel.lastError = .maintenance + } + let resultCommand = commands.first(where: { $0.results != nil }) + if let newTournaments = resultCommand?.results?.items { newTournaments.forEach { ft in // let isValid = ft.tournaments.anySatisfy({ build in