handle may 2024 anonymous stuff

multistore
Razmig Sarkissian 2 years ago
parent efafff9eff
commit 0a3110967a
  1. 4
      PadelClub/Data/Coredata/ImportedPlayer+Extensions.swift
  2. 10
      PadelClub/Data/Federal/FederalPlayer.swift
  3. 4
      PadelClub/Data/Federal/PlayerHolder.swift
  4. 49
      PadelClub/Utils/FileImportManager.swift
  5. 2
      PadelClub/Views/Cashier/CashierView.swift
  6. 2
      PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift
  7. 2
      PadelClub/Views/Match/Components/MatchTeamDetailView.swift
  8. 89
      PadelClub/Views/Navigation/Toolbox/PadelClubView.swift
  9. 27
      PadelClub/Views/Player/Components/EditablePlayerView.swift
  10. 4
      PadelClub/Views/Shared/ImportedPlayerView.swift
  11. 38
      PadelClub/Views/Tournament/FileImportView.swift
  12. 2
      PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift

@ -24,11 +24,11 @@ extension ImportedPlayer: PlayerHolder {
} }
func getFirstName() -> String { func getFirstName() -> String {
self.firstName ?? "prénom inconnu" self.firstName ?? ""
} }
func getLastName() -> String { func getLastName() -> String {
self.lastName ?? "nom inconnu" self.lastName ?? ""
} }
func formattedLicense() -> String { func formattedLicense() -> String {

@ -7,7 +7,7 @@
import Foundation import Foundation
struct FederalPlayer: Decodable { class FederalPlayer: Decodable {
var rank: Int var rank: Int
var lastName: String var lastName: String
var firstName: String var firstName: String
@ -27,7 +27,7 @@ struct FederalPlayer: Decodable {
let code, codeFov: String let code, codeFov: String
} }
init(from decoder: Decoder) throws { required init(from decoder: Decoder) throws {
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {
case nom case nom
case prenom case prenom
@ -77,7 +77,6 @@ struct FederalPlayer: Decodable {
tournamentCount = try? container.decodeIfPresent(Int.self, forKey: .nombreDeTournois) tournamentCount = try? container.decodeIfPresent(Int.self, forKey: .nombreDeTournois)
let assimile = try container.decode(Bool.self, forKey: .assimile) let assimile = try container.decode(Bool.self, forKey: .assimile)
assimilation = assimile ? "Oui" : "Non" assimilation = assimile ? "Oui" : "Non"
fullNameCanonical = _lastName.canonicalVersion + " " + _firstName.canonicalVersion
} }
@ -109,8 +108,6 @@ struct FederalPlayer: Decodable {
return modifiedString return modifiedString
} }
var fullNameCanonical: String
/* /*
;RANG;NOM;PRENOM;Nationalité;N° Licence;POINTS;Assimilation;NB. DE TOURNOIS JOUES;LIGUE;CODE CLUB;CLUB; ;RANG;NOM;PRENOM;Nationalité;N° Licence;POINTS;Assimilation;NB. DE TOURNOIS JOUES;LIGUE;CODE CLUB;CLUB;
*/ */
@ -139,7 +136,7 @@ struct FederalPlayer: Decodable {
$0.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty $0.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
})) }))
// print(result) //print(result)
if result.count < 11 { if result.count < 11 {
return nil return nil
} }
@ -151,7 +148,6 @@ struct FederalPlayer: Decodable {
lastName = result[1] lastName = result[1]
firstName = result[2] firstName = result[2]
fullNameCanonical = result[1].canonicalVersion + " " + result[2].canonicalVersion
country = result[3] country = result[3]
license = result[4] license = result[4]

@ -29,4 +29,8 @@ extension PlayerHolder {
var isAssimilated: Bool { var isAssimilated: Bool {
assimilation == "Oui" assimilation == "Oui"
} }
func isAnonymous() -> Bool {
getFirstName().isEmpty && getLastName().isEmpty
}
} }

@ -11,6 +11,31 @@ import LeStorage
class FileImportManager { class FileImportManager {
static let shared = FileImportManager() static let shared = FileImportManager()
func updatePlayers(isMale: Bool, players: inout [FederalPlayer]) {
guard let mostRecentDateAvailable = URL.importDateFormatter.date(from: "05-2024") else { return }
let replacements: [(Character, Character)] = [("Á", "ç"), ("", "à"), ("Ù", "ô"), ("Ë", "è"), ("Ó", "î"), ("Î", "ë"), ("", "É"), ("Ô", "ï"), ("È", "é"), ("«", "Ç"), ("»", "È")]
var playersLeft = players
SourceFileManager.shared.allFilesSortedByDate(isMale).filter({ $0.dateFromPath.isEarlierThan(mostRecentDateAvailable) }).forEach({ url in
if playersLeft.isEmpty == false {
let federalPlayers = readCSV(inputFile: url)
let replacementsCharacters = url.dateFromPath.monthYearFormatted != "04-2024" ? [] : replacements
playersLeft.forEach { importedPlayer in
if let federalPlayer = federalPlayers.first(where: { $0.license == importedPlayer.license }) {
var lastName = federalPlayer.lastName
lastName.replace(characters: replacementsCharacters)
var firstName = federalPlayer.firstName
firstName.replace(characters: replacementsCharacters)
importedPlayer.lastName = lastName
importedPlayer.firstName = firstName
}
}
playersLeft.removeAll(where: { $0.lastName.isEmpty == false })
}
})
}
func foundInWomenData(license: String?) -> Bool { func foundInWomenData(license: String?) -> Bool {
guard let license = license?.strippedLicense else { guard let license = license?.strippedLicense else {
return false return false
@ -68,11 +93,23 @@ class FileImportManager {
let previousTeam: TeamRegistration? let previousTeam: TeamRegistration?
var registrationDate: Date? = nil var registrationDate: Date? = nil
init(players: [PlayerRegistration], tournamentCategory: TournamentCategory, previousTeam: TeamRegistration?, registrationDate: Date? = nil) { init(players: [PlayerRegistration], tournamentCategory: TournamentCategory, previousTeam: TeamRegistration?, registrationDate: Date? = nil, tournament: Tournament) {
self.players = Set(players) self.players = Set(players)
self.tournamentCategory = tournamentCategory self.tournamentCategory = tournamentCategory
self.previousTeam = previousTeam self.previousTeam = previousTeam
if players.count < 2 {
let s = players.compactMap { $0.sex?.rawValue }
var missing = tournamentCategory.mandatoryPlayerType()
s.forEach { i in
if let index = missing.firstIndex(of: i) {
missing.remove(at: index)
}
}
let significantPlayerCount = 2
self.weight = (players.prefix(significantPlayerCount).map { $0.computedRank } + missing.map { tournament.unrankValue(for: $0 == 1 ? true : false ) ?? 0 }).prefix(significantPlayerCount).reduce(0,+)
} else {
self.weight = players.map { $0.computedRank }.reduce(0,+) self.weight = players.map { $0.computedRank }.reduce(0,+)
}
self.registrationDate = registrationDate self.registrationDate = registrationDate
} }
@ -214,7 +251,7 @@ class FileImportManager {
playerOne.setComputedRank(in: tournament) playerOne.setComputedRank(in: tournament)
let playerTwo = PlayerRegistration(federalData: Array(resultTwo[0...7]), sex: sexPlayerTwo, sexUnknown: sexUnknown) let playerTwo = PlayerRegistration(federalData: Array(resultTwo[0...7]), sex: sexPlayerTwo, sexUnknown: sexUnknown)
playerTwo.setComputedRank(in: tournament) playerTwo.setComputedRank(in: tournament)
let team = TeamHolder(players: [playerOne, playerTwo], tournamentCategory: tournamentCategory, previousTeam: tournament.findTeam([playerOne, playerTwo])) let team = TeamHolder(players: [playerOne, playerTwo], tournamentCategory: tournamentCategory, previousTeam: tournament.findTeam([playerOne, playerTwo]), tournament: tournament)
results.append(team) results.append(team)
} }
} }
@ -261,7 +298,7 @@ class FileImportManager {
let playerTwo = PlayerRegistration(federalData: Array(result[8...]), sex: sexPlayerTwo, sexUnknown: sexUnknown) let playerTwo = PlayerRegistration(federalData: Array(result[8...]), sex: sexPlayerTwo, sexUnknown: sexUnknown)
playerTwo.setComputedRank(in: tournament) playerTwo.setComputedRank(in: tournament)
let team = TeamHolder(players: [playerOne, playerTwo], tournamentCategory: tournamentCategory, previousTeam: tournament.findTeam([playerOne, playerTwo])) let team = TeamHolder(players: [playerOne, playerTwo], tournamentCategory: tournamentCategory, previousTeam: tournament.findTeam([playerOne, playerTwo]), tournament: tournament)
results.append(team) results.append(team)
} }
} }
@ -270,11 +307,11 @@ class FileImportManager {
} }
private func _getPadelClubTeams(from fileContent: String, tournament: Tournament) async -> [TeamHolder] { private func _getPadelClubTeams(from fileContent: String, tournament: Tournament) async -> [TeamHolder] {
let lines = fileContent.components(separatedBy: "\n\n") var lines = fileContent.components(separatedBy: "\n\n")
var results: [TeamHolder] = [] var results: [TeamHolder] = []
let fetchRequest = ImportedPlayer.fetchRequest() let fetchRequest = ImportedPlayer.fetchRequest()
let federalContext = PersistenceController.shared.localContainer.viewContext let federalContext = PersistenceController.shared.localContainer.viewContext
lines.removeAll(where: { $0.contains("Liste d'attente")})
lines.forEach { team in lines.forEach { team in
let data = team.components(separatedBy: "\n") let data = team.components(separatedBy: "\n")
let players = team.licencesFound() let players = team.licencesFound()
@ -292,7 +329,7 @@ class FileImportManager {
} }
return nil return nil
} }
let team = TeamHolder(players: registeredPlayers, tournamentCategory: tournament.tournamentCategory, previousTeam: tournament.findTeam(registeredPlayers), registrationDate: registrationDate) let team = TeamHolder(players: registeredPlayers, tournamentCategory: tournament.tournamentCategory, previousTeam: tournament.findTeam(registeredPlayers), registrationDate: registrationDate, tournament: tournament)
results.append(team) results.append(team)
} }
} }

@ -159,7 +159,7 @@ struct CashierView: View {
@ViewBuilder @ViewBuilder
func computedPlayerView(_ player: PlayerRegistration) -> some View { func computedPlayerView(_ player: PlayerRegistration) -> some View {
EditablePlayerView(player: player, editingOptions: [.licenceId, .payment]) EditablePlayerView(player: player, editingOptions: [.licenceId, .name, .payment])
} }
private func _shouldDisplayTeam(_ team: TeamRegistration) -> Bool { private func _shouldDisplayTeam(_ team: TeamRegistration) -> Bool {

@ -17,7 +17,7 @@ struct GroupStageTeamView: View {
List { List {
Section { Section {
ForEach(team.players()) { player in ForEach(team.players()) { player in
EditablePlayerView(player: player, editingOptions: [.licenceId, .payment]) EditablePlayerView(player: player, editingOptions: [.licenceId, .name, .payment])
} }
} }

@ -31,7 +31,7 @@ struct MatchTeamDetailView: View {
private func _teamDetailView(_ team: TeamRegistration, inTournament tournament: Tournament?) -> some View { private func _teamDetailView(_ team: TeamRegistration, inTournament tournament: Tournament?) -> some View {
Section { Section {
ForEach(team.players()) { player in ForEach(team.players()) { player in
EditablePlayerView(player: player, editingOptions: [.licenceId, .payment]) EditablePlayerView(player: player, editingOptions: [.licenceId, .name, .payment])
} }
} header: { } header: {
TeamHeaderView(team: team, teamIndex: tournament?.indexOf(team: team), tournament: nil) TeamHeaderView(team: team, teamIndex: tournament?.indexOf(team: team), tournament: nil)

@ -26,6 +26,11 @@ struct PadelClubView: View {
animation: .default) animation: .default)
private var players: FetchedResults<ImportedPlayer> private var players: FetchedResults<ImportedPlayer>
@FetchRequest(
sortDescriptors: [],
predicate: NSPredicate(format: "lastName == %@ && firstName == %@", "", ""),
animation: .default)
private var anonymousPlayers: FetchedResults<ImportedPlayer>
var _mostRecentDateAvailable: Date? { var _mostRecentDateAvailable: Date? {
SourceFileManager.shared.mostRecentDateAvailable SourceFileManager.shared.mostRecentDateAvailable
@ -38,6 +43,37 @@ struct PadelClubView: View {
var body: some View { var body: some View {
List { List {
#if targetEnvironment(simulator)
/*
["36435", "BOUNOUA", "walid", "France", "3311600", "15,00", "Non", "2", "AUVERGNE RHONE-ALPES", "50 73 0046", "CHAMBERY TC"]
["36435", "BRUL…", "Romain", "France", "2993139", "15,00", "Non", "2", "NOUVELLE AQUITAINE", "59 33 0447", "SAINT LOUBES TC"]
*/
Section {
RowButtonView("Exporter en csv") {
for fileURL in SourceFileManager.shared.jsonFiles() {
let decoder = JSONDecoder()
decoder.userInfo[.maleData] = fileURL.manData
do {
let data = try Data(contentsOf: fileURL)
let players = try decoder.decode([FederalPlayer].self, from: data)
var anonymousPlayers = players.filter { $0.firstName.isEmpty && $0.lastName.isEmpty }
let okPlayers = players.filter { $0.firstName.isEmpty == false && $0.lastName.isEmpty == false }
print("before anonymousPlayers.count", anonymousPlayers.count)
FileImportManager.shared.updatePlayers(isMale: fileURL.manData, players: &anonymousPlayers)
print("after anonymousPlayers.count", anonymousPlayers.filter { $0.firstName.isEmpty && $0.lastName.isEmpty }
.count)
SourceFileManager.shared.exportToCSV(players: okPlayers + anonymousPlayers, sourceFileType: fileURL.manData ? .messieurs : .dames, date: fileURL.dateFromPath)
} catch {
Logger.error(error)
}
}
}
}
#endif
if let _lastDataSourceDate { if let _lastDataSourceDate {
Section { Section {
LabeledContent { LabeledContent {
@ -46,6 +82,11 @@ struct PadelClubView: View {
Text(_lastDataSourceDate.monthYearFormatted) Text(_lastDataSourceDate.monthYearFormatted)
Text("Classement mensuel utilisé") Text("Classement mensuel utilisé")
} }
.contextMenu {
Button("Ré-importer") {
_startImporting()
}
}
} }
if let mostRecentDateAvailable = SourceFileManager.shared.mostRecentDateAvailable, _lastDataSourceDate.isEarlierThan(mostRecentDateAvailable) { if let mostRecentDateAvailable = SourceFileManager.shared.mostRecentDateAvailable, _lastDataSourceDate.isEarlierThan(mostRecentDateAvailable) {
@ -56,30 +97,26 @@ struct PadelClubView: View {
} }
} }
#if targetEnvironment(simulator)
/*
["36435", "BOUNOUA", "walid", "France", "3311600", "15,00", "Non", "2", "AUVERGNE RHONE-ALPES", "50 73 0046", "CHAMBERY TC"]
["36435", "BRUL…", "Romain", "France", "2993139", "15,00", "Non", "2", "NOUVELLE AQUITAINE", "59 33 0447", "SAINT LOUBES TC"]
*/
Section { Section {
RowButtonView("Exporter en csv") { LabeledContent {
for fileURL in SourceFileManager.shared.jsonFiles() { Text(players.filter{ $0.male }.count.formatted())
let decoder = JSONDecoder() } label: {
decoder.userInfo[.maleData] = fileURL.manData Text("Messieurs")
do {
let data = try Data(contentsOf: fileURL)
let players = try decoder.decode([FederalPlayer].self, from: data)
SourceFileManager.shared.exportToCSV(players: players, sourceFileType: fileURL.manData ? .messieurs : .dames, date: fileURL.dateFromPath)
} catch {
Logger.error(error)
} }
LabeledContent {
Text(players.filter{ $0.male == false }.count.formatted())
} label: {
Text("Dames")
} }
LabeledContent {
Text(anonymousPlayers.count.formatted())
} label: {
Text("Joueurs anonymes")
} }
} header: {
Text(players.count.formatted() + " joueurs")
} }
#endif
} }
if importingFiles { if importingFiles {
@ -104,16 +141,16 @@ struct PadelClubView: View {
Text(maleUnrankedValue.formatted()) Text(maleUnrankedValue.formatted())
} }
} label: { } label: {
Text("Messieurs")
Text("Rang d'un non classé") Text("Rang d'un non classé")
Text("Messieurs")
} }
LabeledContent { LabeledContent {
if let femaleUnrankedValue = monthData.femaleUnrankedValue { if let femaleUnrankedValue = monthData.femaleUnrankedValue {
Text(femaleUnrankedValue.formatted()) Text(femaleUnrankedValue.formatted())
} }
} label: { } label: {
Text("Dames")
Text("Rang d'une non classée") Text("Rang d'une non classée")
Text("Dames")
} }
} header: { } header: {
Text(monthData.monthKey) Text(monthData.monthKey)
@ -129,13 +166,20 @@ struct PadelClubView: View {
} }
} }
.headerProminence(.increased) .headerProminence(.increased)
.navigationTitle("Source des données fédérales") .navigationTitle("Données fédérales")
} }
@ViewBuilder @ViewBuilder
func _activityStatus() -> some View { func _activityStatus() -> some View {
if checkingFiles || importingFiles { if checkingFiles || importingFiles {
HStack(spacing: 20) {
ProgressView() ProgressView()
if let mostRecentDateAvailable = SourceFileManager.shared.mostRecentDateAvailable {
if mostRecentDateAvailable > SourceFileManager.shared.lastDataSourceDate() ?? .distantPast {
Text("import " + mostRecentDateAvailable.monthYearFormatted)
}
}
}
} else if let _mostRecentDateAvailable { } else if let _mostRecentDateAvailable {
if _mostRecentDateAvailable > _lastDataSourceDate ?? .distantPast { if _mostRecentDateAvailable > _lastDataSourceDate ?? .distantPast {
Text(_mostRecentDateAvailable.monthYearFormatted + " disponible à l'importation") Text(_mostRecentDateAvailable.monthYearFormatted + " disponible à l'importation")
@ -168,6 +212,7 @@ struct PadelClubView: View {
await MonthData.calculateCurrentUnrankedValues(mostRecentDateAvailable: mostRecentDate) await MonthData.calculateCurrentUnrankedValues(mostRecentDateAvailable: mostRecentDate)
} }
importingFiles = false importingFiles = false
viewContext.refreshAllObjects()
} }
} }
} }

@ -12,13 +12,16 @@ struct EditablePlayerView: View {
enum PlayerEditingOption { enum PlayerEditingOption {
case payment case payment
case licenceId case licenceId
case name
} }
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
var player: PlayerRegistration @Bindable var player: PlayerRegistration
var editingOptions: [PlayerEditingOption] var editingOptions: [PlayerEditingOption]
@State private var editedLicenceId = "" @State private var editedLicenceId = ""
@State private var shouldPresentLicenceIdEdition: Bool = false @State private var shouldPresentLicenceIdEdition: Bool = false
@State private var presentLastNameUpdate: Bool = false
@State private var presentFirstNameUpdate: Bool = false
var body: some View { var body: some View {
computedPlayerView(player) computedPlayerView(player)
@ -30,6 +33,19 @@ struct EditablePlayerView: View {
try? dataStore.playerRegistrations.addOrUpdate(instance: player) try? dataStore.playerRegistrations.addOrUpdate(instance: player)
} }
} }
.alert("Prénom", isPresented: $presentFirstNameUpdate) {
TextField("Prénom", text: $player.firstName)
.onSubmit {
try? dataStore.playerRegistrations.addOrUpdate(instance: player)
}
}
.alert("Nom", isPresented: $presentLastNameUpdate) {
TextField("Nom", text: $player.lastName)
.onSubmit {
try? dataStore.playerRegistrations.addOrUpdate(instance: player)
}
}
} }
// TODO: Guard // TODO: Guard
@ -61,6 +77,15 @@ struct EditablePlayerView: View {
} }
} }
if editingOptions.contains(.name) {
Divider()
Button("Modifier le prénom") {
presentFirstNameUpdate = true
}
Button("Modifier le nom") {
presentLastNameUpdate = true
}
}
if editingOptions.contains(.licenceId) { if editingOptions.contains(.licenceId) {
Divider() Divider()
if let licenseYearValidity = player.tournament()?.licenseYearValidity(), player.isValidLicenseNumber(year: licenseYearValidity) == false, player.licenceId != nil { if let licenseYearValidity = player.tournament()?.licenseYearValidity(), player.isValidLicenseNumber(year: licenseYearValidity) == false, player.licenceId != nil {

@ -15,8 +15,12 @@ struct ImportedPlayerView: View {
var body: some View { var body: some View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
HStack { HStack {
if player.isAnonymous() {
Text("Joueur Anonyme")
} else {
Text(player.getLastName().capitalized) Text(player.getLastName().capitalized)
Text(player.getFirstName().capitalized) Text(player.getFirstName().capitalized)
}
if index == nil { if index == nil {
Text(player.male ? "" : "") Text(player.male ? "" : "")
} }

@ -14,9 +14,9 @@ struct FileImportView: View {
@Environment(Tournament.self) var tournament: Tournament @Environment(Tournament.self) var tournament: Tournament
@Environment(\.dismiss) private var dismiss @Environment(\.dismiss) private var dismiss
let fileContent: String?
let notFoundAreWalkOutTip = NotFoundAreWalkOutTip() let notFoundAreWalkOutTip = NotFoundAreWalkOutTip()
@State private var fileContent: String?
@State private var teams: [FileImportManager.TeamHolder] = [] @State private var teams: [FileImportManager.TeamHolder] = []
@State private var isShowing = false @State private var isShowing = false
@State private var didImport = false @State private var didImport = false
@ -40,14 +40,8 @@ struct FileImportView: View {
convertingFile = false convertingFile = false
isShowing.toggle() isShowing.toggle()
} }
} footer: {
if fileProvider == .frenchFederation {
let footerString = "Fichier provenant de [beach-padel.app.fft.fr](\(URLs.beachPadel.rawValue))"
Text(.init(footerString))
}
} }
if fileContent != nil {
Section { Section {
Picker(selection: $fileProvider) { Picker(selection: $fileProvider) {
ForEach(FileImportManager.FileProvider.allCases) { ForEach(FileImportManager.FileProvider.allCases) {
@ -56,6 +50,17 @@ struct FileImportView: View {
} label: { } label: {
Text("Source du fichier") Text("Source du fichier")
} }
RowButtonView("Démarrer l'importation") {
if let fileContent {
await _startImport(fileContent: fileContent)
}
}
.disabled(fileContent == nil)
} footer: {
if fileProvider == .frenchFederation {
let footerString = "Fichier provenant de [beach-padel.app.fft.fr](\(URLs.beachPadel.rawValue))"
Text(.init(footerString))
} }
} }
} }
@ -160,13 +165,6 @@ struct FileImportView: View {
} }
} }
} }
.onAppear {
if let fileContent {
Task {
await _startImport(fileContent: fileContent)
}
}
}
.fileImporter(isPresented: $isShowing, allowedContentTypes: [.spreadsheet, .commaSeparatedText, .text], allowsMultipleSelection: false, onCompletion: { results in .fileImporter(isPresented: $isShowing, allowedContentTypes: [.spreadsheet, .commaSeparatedText, .text], allowsMultipleSelection: false, onCompletion: { results in
switch results { switch results {
@ -178,16 +176,11 @@ struct FileImportView: View {
teams.removeAll() teams.removeAll()
Task { Task {
do { do {
var fileContent: String?
if selectedFile.lastPathComponent.hasSuffix("xls") { if selectedFile.lastPathComponent.hasSuffix("xls") {
fileContent = try await CloudConvert.manager.uploadFile(selectedFile) fileContent = try await CloudConvert.manager.uploadFile(selectedFile)
} else { } else {
fileContent = try String(contentsOf: selectedFile) fileContent = try String(contentsOf: selectedFile)
} }
if let fileContent {
await _startImport(fileContent: fileContent)
}
selectedFile.stopAccessingSecurityScopedResource() selectedFile.stopAccessingSecurityScopedResource()
} catch { } catch {
errorMessage = error.localizedDescription errorMessage = error.localizedDescription
@ -204,10 +197,7 @@ struct FileImportView: View {
.onOpenURL { url in .onOpenURL { url in
do { do {
let fileContent = try String(contentsOf: url) fileContent = try String(contentsOf: url)
Task {
await _startImport(fileContent: fileContent)
}
} catch { } catch {
errorMessage = error.localizedDescription errorMessage = error.localizedDescription
} }
@ -302,7 +292,7 @@ struct FileImportView: View {
} }
#Preview { #Preview {
FileImportView(fileContent: nil) FileImportView()
.environment(Tournament.mock()) .environment(Tournament.mock())
} }

@ -104,7 +104,7 @@ struct InscriptionManagerView: View {
} }
.sheet(isPresented: $presentImportView) { .sheet(isPresented: $presentImportView) {
NavigationStack { NavigationStack {
FileImportView(fileContent: nil) FileImportView()
} }
.tint(.master) .tint(.master)
} }

Loading…
Cancel
Save