Jul 13 - Update codes to catch up with the web app updates: scheduled inspection and issue's handler
This commit is contained in:
@@ -408,6 +408,15 @@ struct APIIssueDetail: Decodable, Sendable {
|
||||
// Phase E — area and assignee context
|
||||
let areaName: String?
|
||||
let assignedToName: String?
|
||||
// Handler ("Handled By", phase35)
|
||||
let handlerType: String?
|
||||
let handlerLabel: String?
|
||||
let facilityHandlerName: String?
|
||||
let facilityHandlerContact: String?
|
||||
let facilityHandlerNotes: String?
|
||||
let vendorName: String?
|
||||
let vendorContact: String?
|
||||
let vendorNotes: String?
|
||||
|
||||
nonisolated init(from decoder: any Decoder) throws {
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
@@ -427,12 +436,23 @@ struct APIIssueDetail: Decodable, Sendable {
|
||||
resultPhotos = (try? c.decode([String].self, forKey: .resultPhotos)) ?? []
|
||||
areaName = try? c.decode(String.self, forKey: .areaName)
|
||||
assignedToName = try? c.decode(String.self, forKey: .assignedToName)
|
||||
handlerType = try? c.decode(String.self, forKey: .handlerType)
|
||||
handlerLabel = try? c.decode(String.self, forKey: .handlerLabel)
|
||||
facilityHandlerName = try? c.decode(String.self, forKey: .facilityHandlerName)
|
||||
facilityHandlerContact = try? c.decode(String.self, forKey: .facilityHandlerContact)
|
||||
facilityHandlerNotes = try? c.decode(String.self, forKey: .facilityHandlerNotes)
|
||||
vendorName = try? c.decode(String.self, forKey: .vendorName)
|
||||
vendorContact = try? c.decode(String.self, forKey: .vendorContact)
|
||||
vendorNotes = try? c.decode(String.self, forKey: .vendorNotes)
|
||||
}
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case id, status, severity, description, assignedTo
|
||||
case facilityId, facilityName, reportedAt, resolvedAt
|
||||
case resultNotes, verifiedAt, verificationNote, reportedByName, resultPhotos
|
||||
case areaName, assignedToName
|
||||
case handlerType, handlerLabel
|
||||
case facilityHandlerName, facilityHandlerContact, facilityHandlerNotes
|
||||
case vendorName, vendorContact, vendorNotes
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,6 +468,18 @@ struct APIIssueStatusUpdate: Decodable, Sendable {
|
||||
private enum CodingKeys: String, CodingKey { case issueId, status }
|
||||
}
|
||||
|
||||
struct APIIssueHandlerUpdate: Decodable, Sendable {
|
||||
let issueId: Int
|
||||
let handlerType: String
|
||||
|
||||
nonisolated init(from decoder: any Decoder) throws {
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
issueId = try c.decode(Int.self, forKey: .issueId)
|
||||
handlerType = try c.decode(String.self, forKey: .handlerType)
|
||||
}
|
||||
private enum CodingKeys: String, CodingKey { case issueId, handlerType }
|
||||
}
|
||||
|
||||
// ── Notification polling (Phase C) ────────────────────────────────────────────
|
||||
|
||||
struct APINotification: Decodable, Identifiable, Sendable {
|
||||
@@ -517,6 +549,15 @@ struct APIAssignedIssue: Decodable, Identifiable, Sendable {
|
||||
// Phase E — area and assignee context
|
||||
let areaName: String?
|
||||
let assignedToName: String?
|
||||
// Handler ("Handled By", phase35) — who resolves the issue
|
||||
let handlerType: String? // "internal" | "facility" | "vendor"
|
||||
let handlerLabel: String? // human-readable label
|
||||
let facilityHandlerName: String?
|
||||
let facilityHandlerContact: String?
|
||||
let facilityHandlerNotes: String?
|
||||
let vendorName: String?
|
||||
let vendorContact: String?
|
||||
let vendorNotes: String?
|
||||
|
||||
nonisolated init(from decoder: any Decoder) throws {
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
@@ -538,6 +579,14 @@ struct APIAssignedIssue: Decodable, Identifiable, Sendable {
|
||||
reportedByName = try? c.decode(String.self, forKey: .reportedByName)
|
||||
areaName = try? c.decode(String.self, forKey: .areaName)
|
||||
assignedToName = try? c.decode(String.self, forKey: .assignedToName)
|
||||
handlerType = try? c.decode(String.self, forKey: .handlerType)
|
||||
handlerLabel = try? c.decode(String.self, forKey: .handlerLabel)
|
||||
facilityHandlerName = try? c.decode(String.self, forKey: .facilityHandlerName)
|
||||
facilityHandlerContact = try? c.decode(String.self, forKey: .facilityHandlerContact)
|
||||
facilityHandlerNotes = try? c.decode(String.self, forKey: .facilityHandlerNotes)
|
||||
vendorName = try? c.decode(String.self, forKey: .vendorName)
|
||||
vendorContact = try? c.decode(String.self, forKey: .vendorContact)
|
||||
vendorNotes = try? c.decode(String.self, forKey: .vendorNotes)
|
||||
}
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case id, status, severity, description, assignedTo
|
||||
@@ -545,6 +594,9 @@ struct APIAssignedIssue: Decodable, Identifiable, Sendable {
|
||||
case photoPath, mobilePhotoPaths, resultPhotos
|
||||
case resultNotes, verifiedAt, verificationNote, reportedByName
|
||||
case areaName, assignedToName
|
||||
case handlerType, handlerLabel
|
||||
case facilityHandlerName, facilityHandlerContact, facilityHandlerNotes
|
||||
case vendorName, vendorContact, vendorNotes
|
||||
}
|
||||
}
|
||||
|
||||
@@ -564,6 +616,57 @@ struct APIAssignedIssuesResponseData: Decodable, Sendable {
|
||||
private enum CodingKeys: String, CodingKey { case issues, total, limit, offset }
|
||||
}
|
||||
|
||||
// ── Scheduled Inspections (phase36 — planned/recurring assignments) ───────────
|
||||
|
||||
struct APIScheduledInspection: Decodable, Identifiable, Sendable {
|
||||
let id: Int
|
||||
let facilityId: Int
|
||||
let facilityName: String?
|
||||
let templateId: Int
|
||||
let templateName: String?
|
||||
let inspectorId: Int?
|
||||
let frequency: String
|
||||
let frequencyLabel: String?
|
||||
let nextDueDate: String? // ISO date "YYYY-MM-DD"
|
||||
let isOverdue: Bool
|
||||
let notes: String?
|
||||
|
||||
nonisolated init(from decoder: any Decoder) throws {
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
id = try c.decode(Int.self, forKey: .id)
|
||||
facilityId = try c.decode(Int.self, forKey: .facilityId)
|
||||
facilityName = try? c.decode(String.self, forKey: .facilityName)
|
||||
templateId = try c.decode(Int.self, forKey: .templateId)
|
||||
templateName = try? c.decode(String.self, forKey: .templateName)
|
||||
inspectorId = try? c.decode(Int.self, forKey: .inspectorId)
|
||||
frequency = (try? c.decode(String.self, forKey: .frequency)) ?? "once"
|
||||
frequencyLabel = try? c.decode(String.self, forKey: .frequencyLabel)
|
||||
nextDueDate = try? c.decode(String.self, forKey: .nextDueDate)
|
||||
isOverdue = (try? c.decode(Bool.self, forKey: .isOverdue)) ?? false
|
||||
notes = try? c.decode(String.self, forKey: .notes)
|
||||
}
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case id, facilityId, facilityName, templateId, templateName
|
||||
case inspectorId, frequency, frequencyLabel, nextDueDate, isOverdue, notes
|
||||
}
|
||||
}
|
||||
|
||||
struct APIScheduledInspectionsResponseData: Decodable, Sendable {
|
||||
let scheduled: [APIScheduledInspection]
|
||||
let total: Int
|
||||
let limit: Int
|
||||
let offset: Int
|
||||
|
||||
nonisolated init(from decoder: any Decoder) throws {
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
scheduled = try c.decode([APIScheduledInspection].self, forKey: .scheduled)
|
||||
total = try c.decode(Int.self, forKey: .total)
|
||||
limit = try c.decode(Int.self, forKey: .limit)
|
||||
offset = try c.decode(Int.self, forKey: .offset)
|
||||
}
|
||||
private enum CodingKeys: String, CodingKey { case scheduled, total, limit, offset }
|
||||
}
|
||||
|
||||
// ── Dashboard Stats (Phase B) ─────────────────────────────────────────────────
|
||||
|
||||
struct APIDashboardStats: Decodable, Sendable {
|
||||
|
||||
Reference in New Issue
Block a user