// Models/PendingPhoto.swift // ------------------------- // SwiftData model for photos waiting to be uploaded to the server. // Photos are saved locally first, uploaded during sync, then the // local path reference is replaced with the server path. import Foundation import SwiftData @Model final class PendingPhoto { @Attribute(.unique) var localId: String /// Absolute path in app's Documents/JQC/Photos/ directory var localFilePath: String /// "inspection" | "issue" var entityType: String /// References LocalInspection.localId or LocalIssue.localId var entityLocalId: String /// For inspection form image fields — the field's id string var fieldId: String? /// Populated after successful upload var serverPath: String? /// "pending" | "uploaded" | "failed" var uploadStatus: String var createdAt: Date var inspection: LocalInspection? init( localFilePath: String, entityType: String, entityLocalId: String, fieldId: String? = nil ) { self.localId = UUID().uuidString self.localFilePath = localFilePath self.entityType = entityType self.entityLocalId = entityLocalId self.fieldId = fieldId self.serverPath = nil self.uploadStatus = "pending" self.createdAt = Date() } }