You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
48 lines
1.1 KiB
//
|
|
// TournamentCategorySettingsView.swift
|
|
// PadelClub
|
|
//
|
|
// Created by razmig on 18/12/2024.
|
|
//
|
|
|
|
|
|
import SwiftUI
|
|
import LeStorage
|
|
|
|
struct TournamentCategorySettingsView: View {
|
|
@Environment(Tournament.self) private var tournament: Tournament
|
|
@EnvironmentObject var dataStore: DataStore
|
|
|
|
var body: some View {
|
|
List {
|
|
TournamentLevelPickerView()
|
|
}
|
|
.onChange(of: [
|
|
tournament.federalCategory,
|
|
]) {
|
|
_save()
|
|
}
|
|
.onChange(of: [
|
|
tournament.federalLevelCategory,
|
|
]) {
|
|
_save()
|
|
}
|
|
.onChange(of: [
|
|
tournament.federalAgeCategory,
|
|
]) {
|
|
_save()
|
|
}
|
|
}
|
|
|
|
private func _save() {
|
|
do {
|
|
if tournament.onlineRegistrationCanBeEnabled() == false, tournament.enableOnlineRegistration {
|
|
tournament.enableOnlineRegistration = false
|
|
}
|
|
try dataStore.tournaments.addOrUpdate(instance: tournament)
|
|
} catch {
|
|
Logger.error(error)
|
|
}
|
|
}
|
|
|
|
}
|
|
|