add contact info

newoffer2025
Razmig Sarkissian 4 months ago
parent ad289261d8
commit e082e42d2f
  1. 23
      PadelClubData/Data/Gen/BasePlayerRegistration.swift
  2. 15
      PadelClubData/Data/Gen/PlayerRegistration.json
  3. 4
      PadelClubData/Data/TeamRegistration.swift
  4. 18
      PadelClubData/Extensions/URL+Extensions.swift

@ -39,6 +39,9 @@ public class BasePlayerRegistration: SyncedModelObject, SyncedStorable {
public var paymentId: String? = nil
public var clubCode: String? = nil
public var clubMember: Bool = false
public var contactName: String? = nil
public var contactPhoneNumber: String? = nil
public var contactEmail: String? = nil
public init(
id: String = Store.randomId(),
@ -67,7 +70,10 @@ public class BasePlayerRegistration: SyncedModelObject, SyncedStorable {
registrationStatus: PlayerRegistration.RegistrationStatus = PlayerRegistration.RegistrationStatus.waiting,
paymentId: String? = nil,
clubCode: String? = nil,
clubMember: Bool = false
clubMember: Bool = false,
contactName: String? = nil,
contactPhoneNumber: String? = nil,
contactEmail: String? = nil
) {
super.init()
self.id = id
@ -97,6 +103,9 @@ public class BasePlayerRegistration: SyncedModelObject, SyncedStorable {
self.paymentId = paymentId
self.clubCode = clubCode
self.clubMember = clubMember
self.contactName = contactName
self.contactPhoneNumber = contactPhoneNumber
self.contactEmail = contactEmail
}
required public override init() {
super.init()
@ -130,6 +139,9 @@ public class BasePlayerRegistration: SyncedModelObject, SyncedStorable {
case _paymentId = "paymentId"
case _clubCode = "clubCode"
case _clubMember = "clubMember"
case _contactName = "contactName"
case _contactPhoneNumber = "contactPhoneNumber"
case _contactEmail = "contactEmail"
}
required init(from decoder: Decoder) throws {
@ -161,6 +173,9 @@ public class BasePlayerRegistration: SyncedModelObject, SyncedStorable {
self.paymentId = try container.decodeIfPresent(String.self, forKey: ._paymentId) ?? nil
self.clubCode = try container.decodeIfPresent(String.self, forKey: ._clubCode) ?? nil
self.clubMember = try container.decodeIfPresent(Bool.self, forKey: ._clubMember) ?? false
self.contactName = try container.decodeIfPresent(String.self, forKey: ._contactName) ?? nil
self.contactPhoneNumber = try container.decodeIfPresent(String.self, forKey: ._contactPhoneNumber) ?? nil
self.contactEmail = try container.decodeIfPresent(String.self, forKey: ._contactEmail) ?? nil
try super.init(from: decoder)
}
@ -193,6 +208,9 @@ public class BasePlayerRegistration: SyncedModelObject, SyncedStorable {
try container.encode(self.paymentId, forKey: ._paymentId)
try container.encode(self.clubCode, forKey: ._clubCode)
try container.encode(self.clubMember, forKey: ._clubMember)
try container.encode(self.contactName, forKey: ._contactName)
try container.encode(self.contactPhoneNumber, forKey: ._contactPhoneNumber)
try container.encode(self.contactEmail, forKey: ._contactEmail)
try super.encode(to: encoder)
}
@ -230,6 +248,9 @@ public class BasePlayerRegistration: SyncedModelObject, SyncedStorable {
self.paymentId = playerregistration.paymentId
self.clubCode = playerregistration.clubCode
self.clubMember = playerregistration.clubMember
self.contactName = playerregistration.contactName
self.contactPhoneNumber = playerregistration.contactPhoneNumber
self.contactEmail = playerregistration.contactEmail
}
public static func relationships() -> [Relationship] {

@ -141,6 +141,21 @@
"name": "clubMember",
"type": "Bool",
"defaultValue": "false"
},
{
"name": "contactName",
"type": "String",
"optional": true
},
{
"name": "contactPhoneNumber",
"type": "String",
"optional": true
},
{
"name": "contactEmail",
"type": "String",
"optional": true
}
]
}

@ -189,11 +189,11 @@ final public class TeamRegistration: BaseTeamRegistration, SideStorable {
}
public func getPhoneNumbers() -> [String] {
return players().compactMap { $0.phoneNumber }.filter({ $0.isEmpty == false })
return players().flatMap { [$0.phoneNumber, $0.contactPhoneNumber].compacted() }.filter({ $0.isEmpty == false })
}
public func getMail() -> [String] {
let mails = players().compactMap({ $0.email })
let mails = players().flatMap({ [$0.email, $0.contactEmail].compacted() })
return mails
}

@ -143,6 +143,24 @@ public extension URL {
return nil
}
func fftImportingAnonymous() -> Int? {
// Read the contents of the file
guard let fileContents = try? String(contentsOfFile: path(), encoding: .utf8) else {
return nil
}
// Split the contents by newline characters
let lines = fileContents.components(separatedBy: .newlines)
if let line = lines.first(where: {
$0.hasPrefix("anonymous-players:")
}) {
return Int(line.replacingOccurrences(of: "anonymous-players:", with: ""))
}
return nil
}
func getUnrankedValue() -> Int? {
// Read the contents of the file
guard let fileContents = try? String(contentsOfFile: path(), encoding: .utf8) else {

Loading…
Cancel
Save