sync_v2
Raz 8 months ago
parent 1f0f8ad023
commit 6bcb25a70e
  1. 9
      PadelClub/Data/Tournament.swift
  2. 11
      PadelClub/Extensions/String+Extensions.swift
  3. 2
      PadelClub/Utils/PadelRule.swift
  4. 7
      PadelClub/ViewModel/SearchViewModel.swift
  5. 2
      PadelClub/ViewModel/SetDescriptor.swift
  6. 2
      PadelClub/Views/Cashier/Event/EventCreationView.swift
  7. 2
      PadelClub/Views/Cashier/Event/EventTournamentsView.swift
  8. 2
      PadelClub/Views/Navigation/Agenda/CalendarView.swift
  9. 30
      PadelClub/Views/Score/EditScoreView.swift
  10. 1
      PadelClub/Views/Tournament/Screen/Components/TournamentCategorySettingsView.swift
  11. 19
      PadelClub/Views/Tournament/Screen/RegistrationSetupView.swift
  12. 2
      PadelClub/Views/Tournament/Shared/TournamentCellView.swift

@ -1931,18 +1931,13 @@ defer {
} }
} }
func setupFederalSettings(fromEvent event: Event?) { func setupFederalSettings() {
teamSorting = tournamentLevel.defaultTeamSortingType teamSorting = tournamentLevel.defaultTeamSortingType
groupStageMatchFormat = groupStageSmartMatchFormat() groupStageMatchFormat = groupStageSmartMatchFormat()
loserBracketMatchFormat = loserBracketSmartMatchFormat(5) loserBracketMatchFormat = loserBracketSmartMatchFormat(5)
matchFormat = roundSmartMatchFormat(5) matchFormat = roundSmartMatchFormat(5)
entryFee = tournamentLevel.entryFee entryFee = tournamentLevel.entryFee
if event?.tenupId != nil { registrationDateLimit = deadline(for: .inscription)
//enableOnlineRegistration = true
registrationDateLimit = deadline(for: .inscription)
}
//self.customizeUsingPreferences()
} }
func customizeUsingPreferences() { func customizeUsingPreferences() {

@ -182,6 +182,17 @@ extension String {
firstMatch(of: RegexStatic.phoneNumber) != nil firstMatch(of: RegexStatic.phoneNumber) != nil
} }
func cleanSearchText() -> String {
// Create a character set of all punctuation except slashes and hyphens
var punctuationToRemove = CharacterSet.punctuationCharacters
punctuationToRemove.remove(charactersIn: "/-")
// Remove the unwanted punctuation
return self.components(separatedBy: punctuationToRemove)
.joined(separator: " ")
.trimmingCharacters(in: .whitespacesAndNewlines)
}
//april 04-2024 bug with accent characters / adobe / fft //april 04-2024 bug with accent characters / adobe / fft
mutating func replace(characters: [(Character, Character)]) { mutating func replace(characters: [(Character, Character)]) {
for (targetChar, replacementChar) in characters { for (targetChar, replacementChar) in characters {

@ -1032,7 +1032,7 @@ enum SetFormat: Int, Hashable, Codable {
} }
func winner(teamOne: Int, teamTwo: Int) -> TeamPosition { func winner(teamOne: Int, teamTwo: Int) -> TeamPosition {
return teamOne >= teamTwo ? .one : .two return teamOne > teamTwo ? .one : .two
} }
func hasEnded(teamOne: Int, teamTwo: Int) -> Bool { func hasEnded(teamOne: Int, teamTwo: Int) -> Bool {

@ -167,7 +167,8 @@ class SearchViewModel: ObservableObject, Identifiable {
} }
func words() -> [String] { func words() -> [String] {
return searchText.canonicalVersionWithPunctuation.trimmed.components( let cleanedText = searchText.cleanSearchText().canonicalVersionWithPunctuation.trimmed
return cleanedText.components(
separatedBy: .whitespaces) separatedBy: .whitespaces)
} }
@ -436,11 +437,12 @@ class SearchViewModel: ObservableObject, Identifiable {
static func getSpecialSlashPredicate(inputString: String) -> NSPredicate? { static func getSpecialSlashPredicate(inputString: String) -> NSPredicate? {
// Define a regular expression to find slashes between alphabetic characters (not digits) // Define a regular expression to find slashes between alphabetic characters (not digits)
print(inputString) print(inputString)
let cleanedInput = inputString.cleanSearchText()
let pattern = /(\b[A-Za-z]+)\s*\/\s*([A-Za-z]+\b)/ let pattern = /(\b[A-Za-z]+)\s*\/\s*([A-Za-z]+\b)/
// Find matches in the input string // Find matches in the input string
guard let match = inputString.firstMatch(of: pattern) else { guard let match = cleanedInput.firstMatch(of: pattern) else {
print("No valid name pairs found") print("No valid name pairs found")
return nil return nil
} }
@ -498,6 +500,7 @@ class SearchViewModel: ObservableObject, Identifiable {
// Prepare text for processing - preserve hyphens but remove digits // Prepare text for processing - preserve hyphens but remove digits
var text = var text =
pasteField pasteField
.replacingOccurrences(of: "[\\(\\)\\[\\]\\{\\}]", with: "", options: .regularExpression)
.replacingOccurrences(of: "/", with: " ") // Replace slashes with spaces .replacingOccurrences(of: "/", with: " ") // Replace slashes with spaces
.trimmingCharacters(in: .whitespacesAndNewlines) .trimmingCharacters(in: .whitespacesAndNewlines)

@ -30,7 +30,7 @@ struct SetDescriptor: Identifiable, Equatable {
} }
var winner: TeamPosition? { var winner: TeamPosition? {
if let valueTeamTwo, let valueTeamOne { if let valueTeamTwo, let valueTeamOne, valueTeamOne != valueTeamTwo {
return setFormat.winner(teamOne: valueTeamOne, teamTwo: valueTeamTwo) return setFormat.winner(teamOne: valueTeamOne, teamTwo: valueTeamTwo)
} else { } else {
return nil return nil

@ -143,7 +143,7 @@ struct EventCreationView: View {
tournament.courtCount = selectedClub?.courtCount ?? 2 tournament.courtCount = selectedClub?.courtCount ?? 2
tournament.startDate = startingDate tournament.startDate = startingDate
tournament.dayDuration = duration tournament.dayDuration = duration
tournament.setupFederalSettings(fromEvent: event) tournament.setupFederalSettings()
} }
do { do {

@ -63,7 +63,7 @@ struct EventTournamentsView: View {
newTournament.courtCount = event.eventCourtCount() newTournament.courtCount = event.eventCourtCount()
newTournament.startDate = event.eventStartDate() newTournament.startDate = event.eventStartDate()
newTournament.dayDuration = event.eventDayDuration() newTournament.dayDuration = event.eventDayDuration()
newTournament.setupFederalSettings(fromEvent: event) newTournament.setupFederalSettings()
do { do {
try dataStore.tournaments.addOrUpdate(instance: newTournament) try dataStore.tournaments.addOrUpdate(instance: newTournament)

@ -173,7 +173,7 @@ struct CalendarView: View {
newTournament.federalTournamentAge = build.age newTournament.federalTournamentAge = build.age
newTournament.dayDuration = federalTournament.dayDuration newTournament.dayDuration = federalTournament.dayDuration
newTournament.startDate = federalTournament.startDate.atBeginningOfDay(hourInt: 9) newTournament.startDate = federalTournament.startDate.atBeginningOfDay(hourInt: 9)
newTournament.setupFederalSettings(fromEvent: event) newTournament.setupFederalSettings()
do { do {
try dataStore.tournaments.addOrUpdate(instance: newTournament) try dataStore.tournaments.addOrUpdate(instance: newTournament)
} catch { } catch {

@ -17,11 +17,13 @@ struct EditScoreView: View {
@Binding var confirmScoreEdition: Bool @Binding var confirmScoreEdition: Bool
@Environment(\.dismiss) private var dismiss @Environment(\.dismiss) private var dismiss
@State private var firstTeamIsFirstScoreToEnter: Bool = true @State private var firstTeamIsFirstScoreToEnter: Bool = true
@State private var shouldEndMatch: Bool = false
init(match: Match, confirmScoreEdition: Binding<Bool>) { init(match: Match, confirmScoreEdition: Binding<Bool>) {
let matchDescriptor = MatchDescriptor(match: match) let matchDescriptor = MatchDescriptor(match: match)
_matchDescriptor = .init(wrappedValue: matchDescriptor) _matchDescriptor = .init(wrappedValue: matchDescriptor)
_confirmScoreEdition = confirmScoreEdition _confirmScoreEdition = confirmScoreEdition
_shouldEndMatch = .init(wrappedValue: matchDescriptor.hasEnded)
} }
var defaultTeamIsActive: Bool { var defaultTeamIsActive: Bool {
@ -187,27 +189,27 @@ struct EditScoreView: View {
} footer: { } footer: {
Text("Termine la rencontre sur ce score") Text("Termine la rencontre sur ce score")
} }
} } else if matchDescriptor.match?.hasEnded() == false {
if matchDescriptor.match?.hasEnded() == false {
Section { Section {
RowButtonView("Mise à jour") { Toggle(isOn: $shouldEndMatch) {
matchDescriptor.match?.updateScore(fromMatchDescriptor: matchDescriptor) Text("Terminer le match")
save()
dismiss()
} }
} footer: {
Text("Met à jour le score, ne termine pas la rencontre")
}
Section { RowButtonView("Confirmer") {
RowButtonView("Terminer la rencontre") { if shouldEndMatch {
matchDescriptor.match?.setUnfinishedScore(fromMatchDescriptor: matchDescriptor) matchDescriptor.match?.setUnfinishedScore(fromMatchDescriptor: matchDescriptor)
} else {
matchDescriptor.match?.updateScore(fromMatchDescriptor: matchDescriptor)
}
save() save()
dismiss() dismiss()
} }
} footer: { } footer: {
Text("Le match n'a pas pu aboutir.") if shouldEndMatch {
Text("Le match n'a pas pu aboutir.")
} else {
Text("Met à jour le score, ne termine pas la rencontre")
}
} }
} }
} }

@ -83,6 +83,7 @@ struct TournamentCategorySettingsView: View {
.onChange(of: [ .onChange(of: [
tournament.federalLevelCategory, tournament.federalLevelCategory,
]) { ]) {
tournament.setupFederalSettings()
_save() _save()
} }
.onChange(of: [ .onChange(of: [

@ -79,11 +79,6 @@ struct RegistrationSetupView: View {
var body: some View { var body: some View {
List { List {
if displayWarning() {
Text("Attention, l'inscription en ligne est activée et vous avez des équipes inscrites en ligne, en modifiant la structure ces équipes seront intégrées ou retirées de votre sélection d'équipes. Padel Club saura prévenir les équipes inscrites en ligne automatiquement.")
.foregroundStyle(.logoRed)
}
Section { Section {
Toggle(isOn: $enableOnlineRegistration) { Toggle(isOn: $enableOnlineRegistration) {
Text("Activer") Text("Activer")
@ -151,6 +146,12 @@ struct RegistrationSetupView: View {
} }
Section { Section {
if displayWarning() {
Text("Attention, l'inscription en ligne est activée et vous avez des équipes inscrites en ligne, en modifiant la structure ces équipes seront intégrées ou retirées de votre sélection d'équipes. Padel Club saura prévenir les équipes inscrites en ligne automatiquement.")
.foregroundStyle(.logoRed)
}
// Toggle(isOn: $targetTeamCountEnabled) { // Toggle(isOn: $targetTeamCountEnabled) {
// Text("Activer une limite") // Text("Activer une limite")
// } // }
@ -162,7 +163,7 @@ struct RegistrationSetupView: View {
} header: { } header: {
Text("Paires admises") Text("Paires admises")
} footer: { } footer: {
Text("Les inscriptions seront indiqués en attente pour les joueurs au-délà de cette limite dans le cas où aucune limite de liste d'attente n'est active ou non atteinte. Dans le cas contraire, plus aucune inscription ne seront possibles.") Text("Les inscriptions seront indiquées en attente pour les joueurs au-délà de cette limite dans le cas où aucune limite de liste d'attente n'est active ou non atteinte. Dans le cas contraire, plus aucune inscription ne seront possibles.")
} }
Section { Section {
@ -311,11 +312,7 @@ struct RegistrationSetupView: View {
tournament.registrationDateLimit = registrationDateLimit tournament.registrationDateLimit = registrationDateLimit
} }
if targetTeamCountEnabled == false { tournament.teamCount = targetTeamCount
tournament.teamCount = 24
} else {
tournament.teamCount = targetTeamCount
}
if waitingListLimitEnabled == false { if waitingListLimitEnabled == false {
tournament.waitingListLimit = nil tournament.waitingListLimit = nil

@ -202,7 +202,7 @@ struct TournamentCellView: View {
newTournament.federalTournamentAge = build.age newTournament.federalTournamentAge = build.age
newTournament.dayDuration = federalTournament.dayDuration newTournament.dayDuration = federalTournament.dayDuration
newTournament.startDate = federalTournament.startDate.atBeginningOfDay(hourInt: 9) newTournament.startDate = federalTournament.startDate.atBeginningOfDay(hourInt: 9)
newTournament.setupFederalSettings(fromEvent: event) newTournament.setupFederalSettings()
do { do {
try dataStore.tournaments.addOrUpdate(instance: newTournament) try dataStore.tournaments.addOrUpdate(instance: newTournament)
} catch { } catch {

Loading…
Cancel
Save