From 90da3a7aa2bf991904c1d7201250154ea84f1493 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Wed, 18 Mar 2026 20:07:59 -0500 Subject: Omit resolution when reopening resolved tickets --- Hutch/Views/Tickets/TicketDetailView.swift | 5 +---- Hutch/Views/Tickets/TicketDetailViewModel.swift | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'Hutch/Views') diff --git a/Hutch/Views/Tickets/TicketDetailView.swift b/Hutch/Views/Tickets/TicketDetailView.swift index 6b2be4f..f553bd8 100644 --- a/Hutch/Views/Tickets/TicketDetailView.swift +++ b/Hutch/Views/Tickets/TicketDetailView.swift @@ -71,10 +71,7 @@ struct TicketDetailView: View { if ticket.status == .resolved { Button { Task { - await viewModel.updateStatus( - status: .reported, - resolution: .unresolved - ) + await viewModel.updateStatus(status: .reported) } } label: { SwiftUI.Label("Reopen", systemImage: "arrow.uturn.backward") diff --git a/Hutch/Views/Tickets/TicketDetailViewModel.swift b/Hutch/Views/Tickets/TicketDetailViewModel.swift index 70eaf0a..90e33aa 100644 --- a/Hutch/Views/Tickets/TicketDetailViewModel.swift +++ b/Hutch/Views/Tickets/TicketDetailViewModel.swift @@ -130,6 +130,19 @@ final class TicketDetailViewModel { return lhs.created < rhs.created } + static func statusUpdateInput( + status: TicketStatus, + resolution: TicketResolution? + ) -> [String: any Sendable] { + var input: [String: any Sendable] = [ + "status": status.rawValue + ] + if status == .resolved, let resolution { + input["resolution"] = resolution.rawValue + } + return input + } + init(ownerUsername: String, trackerName: String, trackerId: Int, trackerRid: String, ticketId: Int, client: SRHTClient) { self.ownerUsername = ownerUsername self.trackerName = trackerName @@ -360,16 +373,13 @@ final class TicketDetailViewModel { // MARK: - Ticket Actions - func updateStatus(status: TicketStatus, resolution: TicketResolution) async { + func updateStatus(status: TicketStatus, resolution: TicketResolution? = nil) async { guard !isPerformingAction else { return } isPerformingAction = true error = nil do { - let input: [String: any Sendable] = [ - "status": status.rawValue, - "resolution": resolution.rawValue - ] + let input = Self.statusUpdateInput(status: status, resolution: resolution) _ = try await client.execute( service: .todo, query: Self.updateStatusMutation, -- cgit v1.2.3