Ajusta timeline, comentários internos e contadores de trabalho

This commit is contained in:
Esdras Renan 2025-10-07 22:12:18 -03:00
parent ee18619519
commit ef25cbe799
7 changed files with 212 additions and 69 deletions

View file

@ -16,6 +16,7 @@ import { env } from "@/lib/env"
import { assertAuthenticatedSession } from "@/lib/auth-server"
import { mapTicketWithDetailsFromServer } from "@/lib/mappers/ticket"
import { DEFAULT_TENANT_ID } from "@/lib/constants"
import { TICKET_TIMELINE_LABELS } from "@/lib/ticket-timeline-labels"
// Force Node.js runtime for pdfkit compatibility
export const runtime = "nodejs"
@ -53,25 +54,6 @@ const channelLabel: Record<string, string> = {
OTHER: "Outro",
}
const timelineLabel: Record<string, string> = {
CREATED: "Chamado criado",
STATUS_CHANGED: "Status atualizado",
ASSIGNEE_CHANGED: "Responsável alterado",
COMMENT_ADDED: "Novo comentário",
COMMENT_EDITED: "Comentário editado",
ATTACHMENT_REMOVED: "Anexo removido",
QUEUE_CHANGED: "Fila alterada",
PRIORITY_CHANGED: "Prioridade alterada",
WORK_STARTED: "Atendimento iniciado",
WORK_PAUSED: "Atendimento pausado",
CATEGORY_CHANGED: "Categoria alterada",
MANAGER_NOTIFIED: "Gestor notificado",
SUBJECT_CHANGED: "Assunto atualizado",
SUMMARY_CHANGED: "Resumo atualizado",
VISIT_SCHEDULED: "Visita agendada",
CSAT_RECEIVED: "CSAT recebido",
CSAT_RATED: "CSAT avaliado",
}
function formatDateTime(date: Date | null | undefined) {
if (!date) return "—"
@ -485,7 +467,7 @@ export async function GET(_request: Request, context: { params: Promise<{ id: st
doc.moveDown(0.6)
const timelineSorted = [...ticket.timeline].sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime())
timelineSorted.forEach((event) => {
const label = timelineLabel[event.type] ?? event.type
const label = TICKET_TIMELINE_LABELS[event.type] ?? event.type
doc
.font(hasInter ? "Inter-Bold" : "Helvetica-Bold")
.fontSize(11)