fix search and lic umpire view

sync_v2
Raz 7 months ago
parent ea3e76e8e2
commit 1da8c48cdb
  1. 9
      PadelClub/ViewModel/SearchViewModel.swift
  2. 2
      PadelClub/Views/Navigation/Umpire/UmpireView.swift

@ -248,14 +248,15 @@ class SearchViewModel: ObservableObject, Identifiable {
.joined() .joined()
.trimmed .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 { if canonicalVersionWithoutPunctuation.isEmpty == false {
let wordsPredicates = wordsPredicates() let wordsPredicates = wordsPredicates()
if let wordsPredicates { if let wordsPredicates {
predicates.append(wordsPredicates) predicates.append(wordsPredicates)
} else {
predicates.append(
NSPredicate(
format: "license contains[cd] %@", canonicalVersionWithoutPunctuation))
} }
// Add match for full name // Add match for full name

@ -209,7 +209,7 @@ struct UmpireView: View {
NavigationStack { NavigationStack {
SelectablePlayerListView(allowSelection: 1, searchField: user.firstName + " " + user.lastName, playerSelectionAction: { players in SelectablePlayerListView(allowSelection: 1, searchField: user.firstName + " " + user.lastName, playerSelectionAction: { players in
if let player = players.first { if let player = players.first {
user.licenceId = player.license user.licenceId = player.license?.computedLicense
if user.clubsObjects().contains(where: { $0.code == player.clubCode }) == false { if user.clubsObjects().contains(where: { $0.code == player.clubCode }) == false {
let userClub = Club.findOrCreate(name: player.clubName!, code: player.clubCode) let userClub = Club.findOrCreate(name: player.clubName!, code: player.clubCode)
if userClub.hasBeenCreated(by: StoreCenter.main.userId) { if userClub.hasBeenCreated(by: StoreCenter.main.userId) {

Loading…
Cancel
Save