client(feat): implement ticket completion feature with documentation …#12
client(feat): implement ticket completion feature with documentation …#12
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces a comprehensive ticket completion workflow with mandatory resolution documentation. The changes enhance both the user interface and backend to support documenting how tickets are resolved before marking them as complete.
- Added a new documentation field to the ticket model and database operations
- Created a modal-based completion workflow that requires resolution documentation
- Enhanced the ticket detail and edit views to display and manage documentation
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| server/internal/models/ticket.go | Added documentation field to Ticket struct and BSON tags |
| server/internal/storage/storage.go | Added documentation field support in create and update operations |
| server/internal/api/handlers.go | Added new completion endpoint for marking tickets as closed |
| client/lib/types/ticket.ts | Added optional documentation field to Ticket interface |
| client/lib/api/tickets.ts | Added completeTicket API function |
| client/lib/hooks/queries/use-tickets.ts | Added completion hook and improved cache management |
| client/components/tickets/ticket-edit.tsx | Enhanced form with documentation field and safer default values |
| client/components/tickets/ticket-detail.tsx | Added completion button, documentation display, and completion modal |
| client/components/tickets/ticket-complete-modal.tsx | New modal component for ticket completion with required documentation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| return useMutation<Ticket, Error, string>({ | ||
| mutationFn: (id) => completeTicket(id), | ||
| onSuccess: () => client.invalidateQueries({ queryKey: ["tickets"] }), | ||
| }); |
There was a problem hiding this comment.
The useCompleteTicket hook is defined but not used in the actual completion flow. The ticket-detail.tsx component uses updateTicket instead of completeTicket for completion. Consider removing this unused hook or updating the completion flow to use it.
| updateTicket({ | ||
| id: ticketId, | ||
| updates: { | ||
| status: "Closed", | ||
| documentation: documentation | ||
| } | ||
| }, { | ||
| onSuccess: (updatedTicket) => { | ||
| setStatus("Closed"); | ||
| setIsCompletionModalOpen(false); | ||
| setIsCompleting(false); | ||
| onUpdate(); // Call immediately since cache is updated | ||
| }, | ||
| onError: (error) => { | ||
| console.error('Error updating ticket:', error); | ||
| setIsCompleting(false); | ||
| }, | ||
| }); |
There was a problem hiding this comment.
The completion flow bypasses the dedicated completion endpoint (/api/v1/tickets/{id}/complete) and uses the general update endpoint instead. This creates inconsistency - there's a specific completion API that's not being used. Consider using the completeTicket function or removing the unused completion endpoint.
| } | ||
| sugar = h.logger.Sugar() | ||
| ) | ||
|
|
There was a problem hiding this comment.
The completion endpoint only sets the status to 'Closed' but doesn't handle the documentation field that the frontend is trying to set. This creates a mismatch between the frontend completion workflow (which includes documentation) and the backend completion endpoint.
| // Attempt to decode documentation from the request body, if present | |
| var body map[string]any | |
| if r.Body != nil { | |
| if err := decodeInto(r.Body, &body); err != nil && err.Error() != "EOF" { | |
| sugar.Error(err) | |
| http.Error(w, errInternal.Error(), http.StatusInternalServerError) | |
| return | |
| } | |
| if doc, ok := body["documentation"]; ok { | |
| updates["documentation"] = doc | |
| } | |
| } |
This pull request introduces a comprehensive "resolution documentation" workflow for tickets, improving both the user interface and backend support for documenting how tickets are resolved. Users are now prompted to provide documentation before completing a ticket, and this information is displayed in the ticket details. The changes also include UI/UX enhancements and backend API updates to support the new workflow.
Ticket Completion & Documentation Workflow
TicketCompleteModalcomponent that prompts users to provide resolution documentation before marking a ticket as complete. The modal enforces documentation as a required field and provides helpful guidance for writing it. (client/components/tickets/ticket-complete-modal.tsx)client/components/tickets/ticket-detail.tsx) [1] [2] [3] [4] [5]client/components/tickets/ticket-detail.tsx)client/components/tickets/ticket-edit.tsx) [1] [2] [3] [4] [5] [6] [7] [8] [9]documentationfield to theTickettype. (client/lib/types/ticket.ts)Backend & API Enhancements
POST /api/v1/tickets/{id}/complete), which sets the ticket status to "Closed". (server/internal/api/handlers.go) [1] [2]completeTicketfunction to the client API and a React Query hook for ticket completion. (client/lib/api/tickets.ts,client/lib/hooks/queries/use-tickets.ts) [1] [2] [3]Other Improvements
client/lib/hooks/queries/use-tickets.ts)These changes together ensure that every completed ticket includes a documented resolution, making it easier for team members to learn from previous work and improving the maintainability of the ticketing system.