Add repair notes journal with running feed, visibility, and status tagging

New repair_note table for timestamped journal entries on tickets. Each
note captures author, content, visibility (internal or customer-facing),
and the ticket status at time of writing. Notes display as a running
feed on the ticket detail page with newest first. Internal notes have
a lock icon, customer-visible notes highlighted in blue. Supports add
and delete with appropriate permission gating.
This commit is contained in:
Ryan Moon
2026-03-29 10:27:39 -05:00
parent 01cff80f2b
commit 7eac03f6c2
11 changed files with 334 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
import { queryOptions } from '@tanstack/react-query'
import { api } from '@/lib/api-client'
import type { RepairTicket, RepairLineItem, RepairBatch, RepairServiceTemplate } from '@/types/repair'
import type { RepairTicket, RepairLineItem, RepairBatch, RepairNote, RepairServiceTemplate } from '@/types/repair'
import type { PaginatedResponse, PaginationInput } from '@forte/shared/schemas'
// --- Repair Tickets ---
@@ -89,6 +89,27 @@ export function repairBatchTicketsOptions(batchId: string, params: PaginationInp
})
}
// --- Repair Notes ---
export const repairNoteKeys = {
all: (ticketId: string) => ['repair-tickets', ticketId, 'notes'] as const,
}
export function repairNoteListOptions(ticketId: string) {
return queryOptions({
queryKey: repairNoteKeys.all(ticketId),
queryFn: () => api.get<{ data: RepairNote[] }>(`/v1/repair-tickets/${ticketId}/notes`),
enabled: !!ticketId,
})
}
export const repairNoteMutations = {
create: (ticketId: string, data: Record<string, unknown>) =>
api.post<RepairNote>(`/v1/repair-tickets/${ticketId}/notes`, data),
delete: (id: string) =>
api.del<RepairNote>(`/v1/repair-notes/${id}`),
}
// --- Repair Service Templates ---
export const repairServiceTemplateKeys = {