fix club creation error

add teamCountLimit
sync_v2
Raz 8 months ago
parent 31666591b2
commit c4c2a5a893
  1. 12
      PadelClub.xcodeproj/project.pbxproj
  2. 2
      PadelClub/Data/Club.swift
  3. 9
      PadelClub/Data/Gen/BaseTournament.swift
  4. 6
      PadelClub/Data/Gen/Tournament.json
  5. 13
      PadelClub/Data/Tournament.swift
  6. 4
      PadelClub/Views/Navigation/Agenda/EventListView.swift
  7. 2
      PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift
  8. 24
      PadelClub/Views/Tournament/Screen/RegistrationSetupView.swift
  9. 3
      PadelClubTests/ServerDataTests.swift

@ -3640,7 +3640,7 @@
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
@ -3686,7 +3686,7 @@
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6;
@ -3803,7 +3803,7 @@
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
@ -3849,7 +3849,7 @@
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6;
@ -3895,7 +3895,7 @@
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
@ -3938,7 +3938,7 @@
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6;

@ -108,7 +108,7 @@ extension Club {
if let club {
return club
} else {
let club = Club(creator: StoreCenter.main.userId, name: name, code: code, city: city, zipCode: zipCode)
let club = Club(creator: StoreCenter.main.userId, name: name, acronym: name.acronym(), code: code, city: city, zipCode: zipCode)
club.relatedUser = StoreCenter.main.userId
return club
}

@ -69,6 +69,7 @@ class BaseTournament: SyncedModelObject, SyncedStorable {
var hideUmpireMail: Bool = false
var hideUmpirePhone: Bool = true
var disableRankingFederalRuling: Bool = false
var teamCountLimit: Bool = true
init(
id: String = Store.randomId(),
@ -128,7 +129,8 @@ class BaseTournament: SyncedModelObject, SyncedStorable {
umpireCustomPhone: String? = nil,
hideUmpireMail: Bool = false,
hideUmpirePhone: Bool = true,
disableRankingFederalRuling: Bool = false
disableRankingFederalRuling: Bool = false,
teamCountLimit: Bool = true
) {
super.init()
self.id = id
@ -189,6 +191,7 @@ class BaseTournament: SyncedModelObject, SyncedStorable {
self.hideUmpireMail = hideUmpireMail
self.hideUmpirePhone = hideUmpirePhone
self.disableRankingFederalRuling = disableRankingFederalRuling
self.teamCountLimit = teamCountLimit
}
enum CodingKeys: String, CodingKey {
@ -250,6 +253,7 @@ class BaseTournament: SyncedModelObject, SyncedStorable {
case _hideUmpireMail = "hideUmpireMail"
case _hideUmpirePhone = "hideUmpirePhone"
case _disableRankingFederalRuling = "disableRankingFederalRuling"
case _teamCountLimit = "teamCountLimit"
}
private static func _decodePayment(container: KeyedDecodingContainer<CodingKeys>) throws -> TournamentPayment? {
@ -373,6 +377,7 @@ class BaseTournament: SyncedModelObject, SyncedStorable {
self.hideUmpireMail = try container.decodeIfPresent(Bool.self, forKey: ._hideUmpireMail) ?? false
self.hideUmpirePhone = try container.decodeIfPresent(Bool.self, forKey: ._hideUmpirePhone) ?? true
self.disableRankingFederalRuling = try container.decodeIfPresent(Bool.self, forKey: ._disableRankingFederalRuling) ?? false
self.teamCountLimit = try container.decodeIfPresent(Bool.self, forKey: ._teamCountLimit) ?? true
try super.init(from: decoder)
}
@ -436,6 +441,7 @@ class BaseTournament: SyncedModelObject, SyncedStorable {
try container.encode(self.hideUmpireMail, forKey: ._hideUmpireMail)
try container.encode(self.hideUmpirePhone, forKey: ._hideUmpirePhone)
try container.encode(self.disableRankingFederalRuling, forKey: ._disableRankingFederalRuling)
try container.encode(self.teamCountLimit, forKey: ._teamCountLimit)
try super.encode(to: encoder)
}
@ -504,6 +510,7 @@ class BaseTournament: SyncedModelObject, SyncedStorable {
self.hideUmpireMail = tournament.hideUmpireMail
self.hideUmpirePhone = tournament.hideUmpirePhone
self.disableRankingFederalRuling = tournament.disableRankingFederalRuling
self.teamCountLimit = tournament.teamCountLimit
}
static func relationships() -> [Relationship] {

@ -295,6 +295,12 @@
"type": "Bool",
"defaultValue": "false",
"optional": false
},
{
"name": "teamCountLimit",
"type": "Bool",
"defaultValue": "true",
"optional": false
}
]
}

@ -17,7 +17,10 @@ final class Tournament: BaseTournament {
var lastTeamRefresh: Date?
var refreshRanking: Bool = false
func shouldRefreshTeams() -> Bool {
func shouldRefreshTeams(forced: Bool) -> Bool {
if forced {
return true
}
guard let lastTeamRefresh else { return true }
return lastTeamRefresh.timeIntervalSinceNow < -600
}
@ -36,7 +39,8 @@ final class Tournament: BaseTournament {
umpireCustomPhone: String? = nil,
hideUmpireMail: Bool = false,
hideUmpirePhone: Bool = true,
disableRankingFederalRuling: Bool = false
disableRankingFederalRuling: Bool = false,
teamCountLimit: Bool = true
) {
super.init()
self.event = event
@ -105,6 +109,7 @@ final class Tournament: BaseTournament {
self.umpireCustomMail = umpireCustomMail
self.umpireCustomContact = umpireCustomContact
self.disableRankingFederalRuling = disableRankingFederalRuling
self.teamCountLimit = teamCountLimit
}
required init(from decoder: Decoder) throws {
@ -2379,10 +2384,10 @@ defer {
enableOnlineRegistration && onlineTeams().isEmpty == false && hasEnded() == false && hasStarted() == false
}
func refreshTeamList() async {
func refreshTeamList(forced: Bool) async {
guard StoreCenter.main.isAuthenticated else { return }
guard tournamentStore?.store.fileCollectionsAllLoaded() == true else { return }
guard shouldRefreshTeams(), refreshInProgress == false, enableOnlineRegistration, hasEnded() == false else { return }
guard shouldRefreshTeams(forced: forced), refreshInProgress == false, enableOnlineRegistration, hasEnded() == false else { return }
refreshInProgress = true
do {
try await self.tournamentStore?.playerRegistrations.loadDataFromServerIfAllowed(clear: true)

@ -199,7 +199,7 @@ struct EventListView: View {
Button {
Task {
await pcTournaments.concurrentForEach { tournament in
await tournament.refreshTeamList()
await tournament.refreshTeamList(forced: true)
}
}
} label: {
@ -323,7 +323,7 @@ struct EventListView: View {
})
.id(tournament.lastTeamRefresh)
.task(priority: .background) {
await tournament.refreshTeamList()
await tournament.refreshTeamList(forced: false)
}
}
.listRowView(isActive: tournament.enableOnlineRegistration, color: .green, hideColorVariation: true)

@ -576,7 +576,7 @@ struct InscriptionManagerView: View {
refreshResult = nil
refreshStatus = nil
do {
await self.tournament.refreshTeamList()
await self.tournament.refreshTeamList(forced: forced)
_setHash()
if let lastTeamRefresh = self.tournament.lastTeamRefresh?.formatted(date: .abbreviated, time: .shortened) {

@ -17,7 +17,7 @@ struct RegistrationSetupView: View {
@State private var targetTeamCount: Int
@State private var waitingListLimit: Int
@State private var registrationDateLimitEnabled: Bool
@State private var targetTeamCountEnabled: Bool
@State private var teamCountLimit: Bool
@State private var waitingListLimitEnabled: Bool
@State private var openingRegistrationDateEnabled: Bool
@State private var userAccountIsRequired: Bool
@ -54,7 +54,7 @@ struct RegistrationSetupView: View {
// Target Team Count
_targetTeamCount = .init(wrappedValue: tournament.teamCount) // Default value
_targetTeamCountEnabled = .init(wrappedValue: false)
_teamCountLimit = .init(wrappedValue: tournament.teamCountLimit)
// Waiting List Limit
if let waitingListLimit = tournament.waitingListLimit {
@ -152,14 +152,13 @@ struct RegistrationSetupView: View {
}
// Toggle(isOn: $targetTeamCountEnabled) {
// Text("Activer une limite")
// }
//
// if targetTeamCountEnabled {
// StepperView(count: $targetTeamCount, minimum: 4)
// }
StepperView(count: $targetTeamCount, minimum: 4)
Toggle(isOn: $teamCountLimit) {
Text("Activer une limite")
}
if teamCountLimit {
StepperView(count: $targetTeamCount, minimum: 4)
}
} header: {
Text("Paires admises")
} footer: {
@ -255,7 +254,7 @@ struct RegistrationSetupView: View {
_hasChanged()
}
.onChange(of: targetTeamCountEnabled) {
.onChange(of: teamCountLimit) {
_hasChanged()
}
@ -311,7 +310,8 @@ struct RegistrationSetupView: View {
} else {
tournament.registrationDateLimit = registrationDateLimit
}
tournament.teamCountLimit = teamCountLimit
tournament.teamCount = targetTeamCount
if waitingListLimitEnabled == false {

@ -113,7 +113,7 @@ final class ServerDataTests: XCTestCase {
return
}
let tournament = Tournament(event: eventId, name: "RG Homme", startDate: Date(), endDate: nil, creationDate: Date(), isPrivate: false, groupStageFormat: MatchFormat.megaTie, roundFormat: MatchFormat.nineGames, loserRoundFormat: MatchFormat.nineGamesDecisivePoint, groupStageSortMode: GroupStageOrderingMode.snake, groupStageCount: 2, rankSourceDate: Date(), dayDuration: 5, teamCount: 3, teamSorting: TeamSortingType.rank, federalCategory: TournamentCategory.mix, federalLevelCategory: TournamentLevel.p1000, federalAgeCategory: FederalTournamentAge.a45, closedRegistrationDate: Date(), groupStageAdditionalQualified: 4, courtCount: 9, prioritizeClubMembers: true, qualifiedPerGroupStage: 1, teamsPerGroupStage: 2, entryFee: 30.0, additionalEstimationDuration: 5, isDeleted: true, publishTeams: true, publishSummons: true, publishGroupStages: true, publishBrackets: true, shouldVerifyBracket: true, shouldVerifyGroupStage: true, hideTeamsWeight: true, publishTournament: true, hidePointsEarned: true, publishRankings: true, loserBracketMode: .manual, initialSeedRound: 8, initialSeedCount: 4, accountIsRequired: false, licenseIsRequired: false, minimumPlayerPerTeam: 3, maximumPlayerPerTeam: 5, information: "Super", umpireCustomMail: "razmig@padelclub.app", umpireCustomContact: "Raz", umpireCustomPhone: "+33681598193", hideUmpireMail: true, hideUmpirePhone: true, disableRankingFederalRuling: true)
let tournament = Tournament(event: eventId, name: "RG Homme", startDate: Date(), endDate: nil, creationDate: Date(), isPrivate: false, groupStageFormat: MatchFormat.megaTie, roundFormat: MatchFormat.nineGames, loserRoundFormat: MatchFormat.nineGamesDecisivePoint, groupStageSortMode: GroupStageOrderingMode.snake, groupStageCount: 2, rankSourceDate: Date(), dayDuration: 5, teamCount: 3, teamSorting: TeamSortingType.rank, federalCategory: TournamentCategory.mix, federalLevelCategory: TournamentLevel.p1000, federalAgeCategory: FederalTournamentAge.a45, closedRegistrationDate: Date(), groupStageAdditionalQualified: 4, courtCount: 9, prioritizeClubMembers: true, qualifiedPerGroupStage: 1, teamsPerGroupStage: 2, entryFee: 30.0, additionalEstimationDuration: 5, isDeleted: true, publishTeams: true, publishSummons: true, publishGroupStages: true, publishBrackets: true, shouldVerifyBracket: true, shouldVerifyGroupStage: true, hideTeamsWeight: true, publishTournament: true, hidePointsEarned: true, publishRankings: true, loserBracketMode: .manual, initialSeedRound: 8, initialSeedCount: 4, accountIsRequired: false, licenseIsRequired: false, minimumPlayerPerTeam: 3, maximumPlayerPerTeam: 5, information: "Super", umpireCustomMail: "razmig@padelclub.app", umpireCustomContact: "Raz", umpireCustomPhone: "+33681598193", hideUmpireMail: true, hideUmpirePhone: true, disableRankingFederalRuling: true, teamCountLimit: false)
if let t = try await StoreCenter.main.service().post(tournament) {
@ -169,6 +169,7 @@ final class ServerDataTests: XCTestCase {
assert(t.hideUmpireMail == tournament.hideUmpireMail)
assert(t.hideUmpirePhone == tournament.hideUmpirePhone)
assert(t.disableRankingFederalRuling == tournament.disableRankingFederalRuling)
assert(t.teamCountLimit == tournament.teamCountLimit)
} else {
XCTFail("missing data")
}

Loading…
Cancel
Save