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
groupStageMatchFormat = groupStageSmartMatchFormat()
loserBracketMatchFormat = loserBracketSmartMatchFormat(5)
matchFormat = roundSmartMatchFormat(5)
entryFee = tournamentLevel.entryFee
if event?.tenupId != nil {
//enableOnlineRegistration = true
registrationDateLimit = deadline(for: .inscription)
}
//self.customizeUsingPreferences()
registrationDateLimit = deadline(for: .inscription)
}
func customizeUsingPreferences() {

@ -182,6 +182,17 @@ extension String {
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
mutating func replace(characters: [(Character, Character)]) {
for (targetChar, replacementChar) in characters {

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

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

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

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

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

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

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

@ -79,11 +79,6 @@ struct RegistrationSetupView: View {
var body: some View {
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 {
Toggle(isOn: $enableOnlineRegistration) {
Text("Activer")
@ -151,6 +146,12 @@ struct RegistrationSetupView: View {
}
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) {
// Text("Activer une limite")
// }
@ -162,7 +163,7 @@ struct RegistrationSetupView: View {
} header: {
Text("Paires admises")
} 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 {
@ -311,11 +312,7 @@ struct RegistrationSetupView: View {
tournament.registrationDateLimit = registrationDateLimit
}
if targetTeamCountEnabled == false {
tournament.teamCount = 24
} else {
tournament.teamCount = targetTeamCount
}
tournament.teamCount = targetTeamCount
if waitingListLimitEnabled == false {
tournament.waitingListLimit = nil

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

Loading…
Cancel
Save