78 lines
2.1 KiB
Swift
78 lines
2.1 KiB
Swift
import Foundation
|
|
|
|
struct LeadDetail: Equatable, Sendable {
|
|
let lead: Lead
|
|
let customerType: String
|
|
let contactName: String?
|
|
let contactRole: String?
|
|
let mobile: String?
|
|
let email: String?
|
|
let tankOptions: [LeadTankOption]
|
|
var offers: [LeadOffer]
|
|
let photos: [LeadPhoto]
|
|
}
|
|
|
|
struct LeadTankOption: Identifiable, Equatable, Sendable {
|
|
let id: String
|
|
let title: String
|
|
let tank: Tank
|
|
}
|
|
|
|
struct LeadOffer: Identifiable, Equatable, Sendable {
|
|
let id: String
|
|
let title: String
|
|
let kind: LeadOfferKind
|
|
let amount: Decimal
|
|
let billing: LeadBilling
|
|
let validUntil: Date?
|
|
let acceptedAt: Date?
|
|
var groups: [LeadDocumentGroup]
|
|
var tank: Tank? = nil
|
|
|
|
var documents: [LeadDocument] { groups.flatMap(\.documents) }
|
|
var signedCount: Int { documents.filter { $0.status == .signed }.count }
|
|
var isComplete: Bool { !documents.isEmpty && signedCount == documents.count }
|
|
}
|
|
|
|
enum LeadOfferKind: String, Sendable { case purchase, rental, service }
|
|
enum LeadBilling: String, Sendable { case once, monthly, annually }
|
|
|
|
struct LeadDocumentGroup: Identifiable, Equatable, Sendable {
|
|
let id: String
|
|
let title: String
|
|
var documents: [LeadDocument]
|
|
var signedCount: Int { documents.filter { $0.status == .signed }.count }
|
|
var isComplete: Bool { !documents.isEmpty && signedCount == documents.count }
|
|
}
|
|
|
|
struct LeadDocument: Identifiable, Equatable, Sendable {
|
|
let id: String
|
|
let title: String
|
|
let pageCount: Int
|
|
var status: LeadSignatureStatus
|
|
let file: LeadFileReference
|
|
var signaturePlacement: PDFSignaturePlacement? = nil
|
|
}
|
|
|
|
enum LeadSignatureStatus: String, Sendable { case pending, signed }
|
|
|
|
struct LeadPhoto: Identifiable, Equatable, Sendable {
|
|
let id: String
|
|
let title: String
|
|
let isAR: Bool
|
|
let thumbnail: LeadFileReference
|
|
let original: LeadFileReference
|
|
}
|
|
|
|
struct LeadFileReference: Hashable, Sendable {
|
|
let id: String
|
|
let version: String
|
|
let kind: LeadFileKind
|
|
}
|
|
|
|
enum LeadFileKind: String, Sendable { case pdf, image }
|
|
|
|
enum LeadFileError: Error, Equatable {
|
|
case notFound, invalidFile, storageUnavailable
|
|
}
|