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.
144 lines
3.8 KiB
144 lines
3.8 KiB
//
|
|
// Business.swift
|
|
// PadelClubData
|
|
//
|
|
// Created by Laurent Morvillier on 30/04/2025.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
public protocol SpinDrawable {
|
|
func segmentLabel(_ displayStyle: DisplayStyle, hideNames: Bool) -> [String]
|
|
}
|
|
|
|
public enum DayPeriod: Int, CaseIterable, Identifiable, Codable {
|
|
|
|
public var id: Int { self.rawValue }
|
|
|
|
case all
|
|
case weekend
|
|
case week
|
|
|
|
public func localizedDayPeriodLabel() -> String {
|
|
switch self {
|
|
case .all:
|
|
return "n'importe"
|
|
case .week:
|
|
return "la semaine"
|
|
case .weekend:
|
|
return "le week-end"
|
|
}
|
|
}
|
|
}
|
|
|
|
public enum OnlineRegistrationStatus: Int {
|
|
case open = 1
|
|
case notEnabled = 2
|
|
case notStarted = 3
|
|
case ended = 4
|
|
case waitingListPossible = 5
|
|
case waitingListFull = 6
|
|
case inProgress = 7
|
|
case endedWithResults = 8
|
|
|
|
public var displayName: String {
|
|
switch self {
|
|
case .open:
|
|
return "Open"
|
|
case .notEnabled:
|
|
return "Not Enabled"
|
|
case .notStarted:
|
|
return "Not Started"
|
|
case .ended:
|
|
return "Ended"
|
|
case .waitingListPossible:
|
|
return "Waiting List Possible"
|
|
case .waitingListFull:
|
|
return "Waiting List Full"
|
|
case .inProgress:
|
|
return "In Progress"
|
|
case .endedWithResults:
|
|
return "Ended with Results"
|
|
}
|
|
}
|
|
|
|
public func statusLocalized() -> String {
|
|
switch self {
|
|
case .open:
|
|
return "Inscription ouverte"
|
|
case .notEnabled:
|
|
return "Inscription désactivée"
|
|
case .notStarted:
|
|
return "Inscription pas encore ouverte"
|
|
case .ended:
|
|
return "Inscription terminée"
|
|
case .waitingListPossible:
|
|
return "Liste d'attente disponible"
|
|
case .waitingListFull:
|
|
return "Liste d'attente complète"
|
|
case .inProgress:
|
|
return "Tournoi en cours"
|
|
case .endedWithResults:
|
|
return "Tournoi terminé"
|
|
}
|
|
}
|
|
}
|
|
|
|
public enum PaymentStatus {
|
|
case notEnabled
|
|
case notConfigured // Online payment not set up (no Stripe account)
|
|
case optionalPayment // Online payment is optional
|
|
case mandatoryRefundEnabled // Online payment is mandatory, and refunds are enabled within the refund period
|
|
case mandatoryRefundEnded // Online payment is mandatory, refunds were enabled but the refund period has ended
|
|
case mandatoryNoRefund // Online payment is mandatory, but refunds are not enabled
|
|
|
|
/**
|
|
Returns a localized string representation of the payment status.
|
|
This method allows for easy display of the status in the UI.
|
|
*/
|
|
public func statusLocalized() -> String {
|
|
switch self {
|
|
case .notEnabled:
|
|
return "Paiement en ligne désactivé"
|
|
case .notConfigured:
|
|
return "Non configuré"
|
|
case .optionalPayment:
|
|
return "Facultatif"
|
|
case .mandatoryRefundEnabled:
|
|
return "Obligatoire avec remboursement"
|
|
case .mandatoryRefundEnded:
|
|
return "Obligatoire, remboursement terminé"
|
|
case .mandatoryNoRefund:
|
|
return "Obligatoire sans remboursement"
|
|
}
|
|
}
|
|
}
|
|
|
|
public enum PlayerFilterOption: Int, Hashable, CaseIterable, Identifiable {
|
|
case all = -1
|
|
case male = 1
|
|
case female = 0
|
|
|
|
public var id: Int { rawValue }
|
|
|
|
public func icon() -> String {
|
|
switch self {
|
|
case .all:
|
|
return "Tous"
|
|
case .male:
|
|
return "Homme"
|
|
case .female:
|
|
return "Femme"
|
|
}
|
|
}
|
|
|
|
public var localizedPlayerLabel: String {
|
|
switch self {
|
|
case .female:
|
|
return "joueuse"
|
|
default:
|
|
return "joueur"
|
|
}
|
|
}
|
|
|
|
}
|
|
|