diff --git a/PadelClub/ViewModel/SearchViewModel.swift b/PadelClub/ViewModel/SearchViewModel.swift index 483cd87..9320e26 100644 --- a/PadelClub/ViewModel/SearchViewModel.swift +++ b/PadelClub/ViewModel/SearchViewModel.swift @@ -248,14 +248,15 @@ class SearchViewModel: ObservableObject, Identifiable { .joined() .trimmed + // Check for license numbers + let matches = canonicalVersionWithoutPunctuation.licencesFound() + let licensesPredicates = matches.map { NSPredicate(format: "license contains[cd] %@", $0) } + predicates.append(NSCompoundPredicate(orPredicateWithSubpredicates: licensesPredicates)) + if canonicalVersionWithoutPunctuation.isEmpty == false { let wordsPredicates = wordsPredicates() if let wordsPredicates { predicates.append(wordsPredicates) - } else { - predicates.append( - NSPredicate( - format: "license contains[cd] %@", canonicalVersionWithoutPunctuation)) } // Add match for full name diff --git a/PadelClub/Views/Navigation/Umpire/UmpireView.swift b/PadelClub/Views/Navigation/Umpire/UmpireView.swift index c6d5b5b..2d184d3 100644 --- a/PadelClub/Views/Navigation/Umpire/UmpireView.swift +++ b/PadelClub/Views/Navigation/Umpire/UmpireView.swift @@ -209,7 +209,7 @@ struct UmpireView: View { NavigationStack { SelectablePlayerListView(allowSelection: 1, searchField: user.firstName + " " + user.lastName, playerSelectionAction: { players in if let player = players.first { - user.licenceId = player.license + user.licenceId = player.license?.computedLicense if user.clubsObjects().contains(where: { $0.code == player.clubCode }) == false { let userClub = Club.findOrCreate(name: player.clubName!, code: player.clubCode) if userClub.hasBeenCreated(by: StoreCenter.main.userId) {