Jul 30 - Update iPad - inspector can re-inspect and create follow-up

This commit is contained in:
Nguyen Ngo
2026-07-30 16:16:15 -04:00
parent b7990cc9ba
commit dac7e6c597
16 changed files with 961 additions and 19 deletions
+50
View File
@@ -429,6 +429,56 @@ actor APIClient {
return result.scheduled
}
/// Plan a follow-up re-inspection of `parentInspectionId` for `dueDate`
/// (phase45) the deferred twin of "Re-inspect Now" in history detail.
///
/// Only the parent and the date are sent: the server derives facility,
/// template and assignee from the parent inspection, so a follow-up can
/// only ever target the thing it is a follow-up of. The schedule it creates
/// carries `parent_inspection_id`, which the inspection started from it
/// inherits that is what makes the eventual run a linked re-inspection.
///
/// Idempotent server-side: retrying re-dates the existing active follow-up
/// for this parent instead of creating a second one.
///
/// `dueDate` must be formatted `yyyy-MM-dd`; the server rejects a past date.
func createScheduledFollowUp(
parentInspectionId: Int,
dueDate: String,
notes: String?
) async throws -> APIScheduledInspection {
var body: [String: Any] = [
"parent_inspection_id": parentInspectionId,
"due_date": dueDate,
]
// Raw snake_case body keys JSONSerialization applies no key strategy
// (rule 65).
if let n = notes?.trimmingCharacters(in: .whitespacesAndNewlines), !n.isEmpty {
body["notes"] = n
}
let result: APIScheduledFollowUpResponseData = try await post(
"/api/v1/scheduled-inspections/follow-up", body: body
)
return result.scheduled
}
// Follow-up Requests
/// Inspections a director/admin has flagged as needing a follow-up.
///
/// Same endpoint and response shape as `fetchInspectionHistory`, but with
/// the `follow_up_required` filter so the server returns the complete
/// outstanding set rather than the recent page history shows. The limit is
/// the endpoint's maximum for the same reason this list drives actionable
/// work, and a follow-up raised on a months-old inspection must still
/// appear. Inspector-scoped server-side.
func fetchFollowUpRequests() async throws -> [APIInspectionSummary] {
let result: InspectionHistoryResponseData = try await request(
"/api/v1/inspections?follow_up_required=true&limit=200"
)
return result.inspections
}
// Issue Handler ("Handled By")
/// Set who handles an issue. `details` carries any of the optional