sync3
Laurent 6 months ago
commit 9fa8e60f95
  1. 12
      PadelClub.xcodeproj/project.pbxproj
  2. 2704
      PadelClub/Data/Tournament.swift
  3. 34
      PadelClub/Views/Cashier/CashierDetailView.swift
  4. 56
      PadelClub/Views/Tournament/ConsolationTournamentImportView.swift
  5. 21
      PadelClub/Views/User/AccountView.swift

@ -3116,7 +3116,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2.19;
MARKETING_VERSION = 1.2.20;
PRODUCT_BUNDLE_IDENTIFIER = app.padelclub;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -3162,7 +3162,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2.19;
MARKETING_VERSION = 1.2.20;
PRODUCT_BUNDLE_IDENTIFIER = app.padelclub;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -3281,7 +3281,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2.19;
MARKETING_VERSION = 1.2.20;
PRODUCT_BUNDLE_IDENTIFIER = app.padelclub;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -3326,7 +3326,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2.19;
MARKETING_VERSION = 1.2.20;
PRODUCT_BUNDLE_IDENTIFIER = app.padelclub;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -3370,7 +3370,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2.19;
MARKETING_VERSION = 1.2.20;
PRODUCT_BUNDLE_IDENTIFIER = app.padelclub.beta;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -3412,7 +3412,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2.19;
MARKETING_VERSION = 1.2.20;
PRODUCT_BUNDLE_IDENTIFIER = app.padelclub.beta;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";

File diff suppressed because it is too large Load Diff

@ -11,6 +11,7 @@ import PadelClubData
struct CashierDetailView: View {
var tournaments : [Tournament]
@State private var earnings: Double? = nil
@State private var remainingAmount: Double? = nil
@State private var paidCompletion: Double? = nil
init(tournaments: [Tournament]) {
@ -25,6 +26,16 @@ struct CashierDetailView: View {
List {
if tournaments.count > 1 {
Section {
LabeledContent {
if let remainingAmount {
Text(remainingAmount.formatted(.currency(code: Locale.defaultCurrency()).precision(.fractionLength(0))))
} else {
ProgressView()
}
} label: {
Text("Reste à encaisser")
}
LabeledContent {
if let earnings {
Text(earnings.formatted(.currency(code: Locale.defaultCurrency()).precision(.fractionLength(0))))
@ -58,10 +69,18 @@ struct CashierDetailView: View {
if paidCompletion == nil {
_getPaidCompletion()
}
if remainingAmount == nil {
_getRemainingAmount()
}
}
}
}
private func _getRemainingAmount() {
remainingAmount = tournaments.map { $0.remainingAmount() }.reduce(0,+)
}
private func _getEarnings() {
earnings = tournaments.map { $0.earnings() }.reduce(0,+)
}
@ -89,11 +108,22 @@ struct CashierDetailView: View {
let tournament: Tournament
let showTournamentTitle: Bool
@State private var earnings: Double? = nil
@State private var remainingAmount: Double? = nil
@State private var paidCompletion: Double? = nil
@State private var presence: Double? = nil
var body: some View {
Section {
LabeledContent {
if let remainingAmount {
Text(remainingAmount.formatted(.currency(code: Locale.defaultCurrency()).precision(.fractionLength(0))))
} else {
ProgressView()
}
} label: {
Text("Reste à encaisser")
}
LabeledContent {
if let earnings {
Text(earnings.formatted(.currency(code: Locale.defaultCurrency()).precision(.fractionLength(0))))
@ -131,6 +161,10 @@ struct CashierDetailView: View {
if presence == nil {
presence = tournament.presenceStatus()
}
if remainingAmount == nil {
remainingAmount = tournament.remainingAmount()
}
}
}
}

@ -17,6 +17,7 @@ struct ConsolationTournamentImportView: View {
@State private var selectedTournament: Tournament?
@State private var selectedImportSelector: ImportSelector = .groupStage
@State private var selectedImportType: ImportType = .losers
@State private var selectedGroupStagePosition: Set<Int> = Set()
enum ImportType: Int, Identifiable, CaseIterable {
case losers
@ -135,6 +136,36 @@ struct ConsolationTournamentImportView: View {
Text("Type")
}
}
if selectedImportSelector == .groupStage, selectedImportType == .losers {
NavigationLink {
List(selection: $selectedGroupStagePosition) {
ForEach(selectedTournament.groupStageLosingPositions()) { position in
let text: String = "\(position)" + position.ordinalFormattedSuffix()
Text(text)
.tag(position)
}
}
.environment(\.editMode, Binding.constant(EditMode.active))
.navigationTitle("Position des poules")
.navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar)
} label: {
LabeledContent {
if selectedGroupStagePosition.isEmpty {
Text("Tous les perdants")
} else {
let value: String = selectedGroupStagePosition.map({ position in
let text: String = "\(position)" + position.ordinalFormattedSuffix()
return text
}).joined(separator: ", ")
Text(value)
}
} label: {
Text("Sélection des positions")
}
}
}
}
}
@ -155,16 +186,15 @@ struct ConsolationTournamentImportView: View {
let teams = _teamsToImport(selectedTournament: selectedTournament)
Section {
RowButtonView("Importer les équipes") {
await _importTeams(selectedTournament: selectedTournament, teams: teams)
dismiss()
}
.disabled(teams.isEmpty)
} footer: {
if teams.isEmpty {
Text("Aucune équipe détectée").foregroundStyle(.logoRed)
if teams.isEmpty == false {
Section {
RowButtonView("Importer les \(teams.count) équipes") {
await _importTeams(selectedTournament: selectedTournament, teams: teams)
dismiss()
}
}
} else {
Text("Aucune équipe à importer").foregroundStyle(.logoRed)
}
}
}
@ -186,7 +216,13 @@ struct ConsolationTournamentImportView: View {
teams = selectedTournament.groupStageTeams().filter({
switch selectedImportType {
case .losers:
return $0.qualified == false
if selectedGroupStagePosition.isEmpty {
return $0.qualified == false
} else if let position = $0.groupStagePosition {
return $0.qualified == false && selectedGroupStagePosition.contains(position)
} else {
return $0.qualified == false
}
case .winners:
return $0.qualified
case .all:

@ -36,10 +36,25 @@ struct AccountView: View {
}
}
Section {
RowButtonView("Supprimer mon compte", role: .destructive, confirmationMessage: "Voulez-vous vraiment supprimer définitivement votre compte et ses données associées ?") {
DataStore.shared.deleteAccount()
// handler()
NavigationLink {
List {
Section {
Text("Attention la suppression de votre compte est irréversible. Vous perdrez l'accès à tous vos tournois créés jusqu'à présent.").foregroundStyle(.logoRed).bold()
}
RowButtonView("Supprimer mon compte", role: .destructive, confirmationMessage: "Voulez-vous vraiment supprimer définitivement votre compte et ses données associées ?") {
DataStore.shared.deleteAccount()
}
}
.navigationTitle("Supprimer votre compte")
.navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar)
.toolbarBackground(.logoRed, for: .navigationBar)
} label: {
Text("Suppression du compte")
}
} header: {
Text("Accéder à l'écran de suppression de compte.")
}
}.navigationTitle(user.username)
}

Loading…
Cancel
Save