Jul 30 - Update iPad - inspector can re-inspect and create follow-up
This commit is contained in:
@@ -658,6 +658,11 @@ struct APIScheduledInspection: Decodable, Identifiable, Sendable {
|
||||
let nextDueDate: String? // ISO date "YYYY-MM-DD"
|
||||
let isOverdue: Bool
|
||||
let notes: String?
|
||||
/// Set when this schedule is a planned follow-up of a specific inspection
|
||||
/// (phase45, "Schedule Follow-up"). Carried onto the inspection started
|
||||
/// from it so the run lands as a linked re-inspection. Nil for an ordinary
|
||||
/// schedule, and on servers older than phase45.
|
||||
let parentInspectionId: Int?
|
||||
|
||||
nonisolated init(from decoder: any Decoder) throws {
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
@@ -672,10 +677,12 @@ struct APIScheduledInspection: Decodable, Identifiable, Sendable {
|
||||
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)
|
||||
parentInspectionId = try? c.decode(Int.self, forKey: .parentInspectionId)
|
||||
}
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case id, facilityId, facilityName, templateId, templateName
|
||||
case inspectorId, frequency, frequencyLabel, nextDueDate, isOverdue, notes
|
||||
case parentInspectionId
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,6 +702,21 @@ struct APIScheduledInspectionsResponseData: Decodable, Sendable {
|
||||
private enum CodingKeys: String, CodingKey { case scheduled, total, limit, offset }
|
||||
}
|
||||
|
||||
/// Response of `POST /api/v1/scheduled-inspections/follow-up` (phase45).
|
||||
/// `created` is false when the server re-dated an existing follow-up for the
|
||||
/// same parent instead of adding a second one.
|
||||
struct APIScheduledFollowUpResponseData: Decodable, Sendable {
|
||||
let scheduled: APIScheduledInspection
|
||||
let created: Bool
|
||||
|
||||
nonisolated init(from decoder: any Decoder) throws {
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
scheduled = try c.decode(APIScheduledInspection.self, forKey: .scheduled)
|
||||
created = (try? c.decode(Bool.self, forKey: .created)) ?? true
|
||||
}
|
||||
private enum CodingKeys: String, CodingKey { case scheduled, created }
|
||||
}
|
||||
|
||||
// ── Dashboard Stats (Phase B) ─────────────────────────────────────────────────
|
||||
|
||||
struct APIDashboardStats: Decodable, Sendable {
|
||||
|
||||
Reference in New Issue
Block a user