fix: auto-fix findings from no-mistakes review

- Remove duplicate  import
- Fix  →  in create ticket
- Fix  →  in ticket detail
- Add note field to TicketUpdate schema and handle note-only updates in backend
- Update frontend submitNote() to use PATCH endpoint
This commit is contained in:
root
2026-07-23 19:06:33 +00:00
parent 9aa7971a28
commit 3dc383e62d
5 changed files with 17 additions and 7 deletions
-2
View File
@@ -2,8 +2,6 @@
from __future__ import annotations from __future__ import annotations
from __future__ import annotations
from pathlib import Path from pathlib import Path
from fastapi import APIRouter, Request from fastapi import APIRouter, Request
+1
View File
@@ -46,6 +46,7 @@ class TicketUpdate(BaseModel):
eta: datetime | None = None eta: datetime | None = None
cost: Decimal | None = None cost: Decimal | None = None
parts_used: str | None = None parts_used: str | None = None
note: str | None = None
class TicketTimelineOut(BaseModel): class TicketTimelineOut(BaseModel):
+12
View File
@@ -275,6 +275,18 @@ async def update_ticket(
ticket.status = new_status ticket.status = new_status
# Handle standalone note (no status change)
note_only = data.get("note")
if note_only and (new_status is None or new_status == ticket.status):
await _log_status_change(
db,
ticket.id,
from_status=ticket.status,
to_status=ticket.status,
note=note_only,
user_id=user.id if user else None,
)
# Update other fields # Update other fields
for field in ("unit_id", "category_id", "priority", "reporter", "reported_via", for field in ("unit_id", "category_id", "priority", "reporter", "reported_via",
"description", "assigned_to", "eta", "cost", "parts_used"): "description", "assigned_to", "eta", "cost", "parts_used"):
+3 -4
View File
@@ -311,7 +311,7 @@
async init() { async init() {
await this.loadTicket(); await this.loadTicket();
if (this.isFM || this.isAdmin) { if (app().isFM || app().isAdmin) {
await this.loadTechnicians(); await this.loadTechnicians();
} }
}, },
@@ -392,9 +392,8 @@
if (!this.noteForm.note.trim()) return; if (!this.noteForm.note.trim()) return;
this.noteSubmitting = true; this.noteSubmitting = true;
try { try {
// Use status update endpoint to add a note without changing status // Use PATCH endpoint which now supports note-only updates
const updated = await app().apiPost(`/api/tickets/${this.ticketId}/status`, { const updated = await app().apiPatch(`/api/tickets/${this.ticketId}`, {
status: this.ticket.status,
note: this.noteForm.note note: this.noteForm.note
}); });
this.ticket = updated; this.ticket = updated;
+1 -1
View File
@@ -244,7 +244,7 @@
const payload = { const payload = {
description: this.form.description, description: this.form.description,
priority: this.form.priority || null, priority: this.form.priority || null,
reporter: this.form.reporter || this.user.full_name, reporter: this.form.reporter || app().user.full_name,
reported_via: this.form.reported_via || 'walk-in', reported_via: this.form.reported_via || 'walk-in',
category_id: this.form.category_id ? parseInt(this.form.category_id) : (this.form.category_main ? parseInt(this.form.category_main) : null), category_id: this.form.category_id ? parseInt(this.form.category_id) : (this.form.category_main ? parseInt(this.form.category_main) : null),
}; };