Aug 17 - Update customer inspector can update issue status

This commit is contained in:
2026-08-17 16:46:26 -04:00
parent 436ef5dafb
commit 607da7ae47
4 changed files with 72 additions and 7 deletions
@@ -290,10 +290,15 @@ struct IssueDetailView: View {
/// Inspector can update status only if the issue has synced (has a serverId)
/// and we are online. Admins/directors can always update when online.
///
/// Uses `Constants.Roles.issueActors` rather than a hand-written list: the
/// old `role == "inspector"` check silently excluded Customer Inspectors
/// (`external_inspector`), who the API has always accepted here the
/// Update Status control simply never appeared for them, with no error to
/// explain why.
private var canUpdateStatus: Bool {
guard sync.isOnline, issue.serverId != nil else { return false }
let role = AuthManager.shared.currentUserRole
return role == "admin" || role == "director" || role == "inspector"
return Constants.Roles.issueActors.contains(AuthManager.shared.currentUserRole)
}
private let allStatuses: [(value: String, label: String, color: Color)] = [
@@ -308,9 +313,7 @@ struct IssueDetailView: View {
/// admin/director/PM); the server enforces facility scope for inspectors.
private var canEditHandler: Bool {
guard sync.isOnline, issue.serverId != nil else { return false }
let role = AuthManager.shared.currentUserRole
return role == "admin" || role == "director"
|| role == "inspector" || role == "project_manager"
return Constants.Roles.issueActors.contains(AuthManager.shared.currentUserRole)
}
private func handlerTypeLabel(_ type: String) -> String {
@@ -371,9 +371,12 @@ struct HistoryDetailView: View {
/// Auditors are read-only everywhere else and the API rejects them (403),
/// so the two action buttons are hidden rather than shown failing.
///
/// `issueActors` is the same set minus auditor, and unlike the literal
/// list this replaced it includes Customer Inspectors, who perform
/// inspections exactly as our own do.
private var canStartFollowUp: Bool {
["admin", "director", "inspector", "project_manager"]
.contains(auth.currentUserRole)
Constants.Roles.issueActors.contains(auth.currentUserRole)
}
// Local SwiftData copy used only for follow-up sync-back.