Ajusta timeline, comentários internos e contadores de trabalho
This commit is contained in:
parent
ee18619519
commit
ef25cbe799
7 changed files with 212 additions and 69 deletions
|
|
@ -2,11 +2,13 @@ import { format } from "date-fns"
|
|||
import type { ComponentType, ReactNode } from "react"
|
||||
import { ptBR } from "date-fns/locale"
|
||||
import {
|
||||
IconCalendar,
|
||||
IconClockHour4,
|
||||
IconFolders,
|
||||
IconNote,
|
||||
IconPaperclip,
|
||||
IconSquareCheck,
|
||||
IconStar,
|
||||
IconUserCircle,
|
||||
} from "@tabler/icons-react"
|
||||
|
||||
|
|
@ -14,6 +16,7 @@ import type { TicketWithDetails } from "@/lib/schemas/ticket"
|
|||
import { Card, CardContent } from "@/components/ui/card"
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
import { TICKET_TIMELINE_LABELS } from "@/lib/ticket-timeline-labels"
|
||||
|
||||
const timelineIcons: Record<string, ComponentType<{ className?: string }>> = {
|
||||
CREATED: IconUserCircle,
|
||||
|
|
@ -29,23 +32,13 @@ const timelineIcons: Record<string, ComponentType<{ className?: string }>> = {
|
|||
PRIORITY_CHANGED: IconSquareCheck,
|
||||
ATTACHMENT_REMOVED: IconPaperclip,
|
||||
CATEGORY_CHANGED: IconFolders,
|
||||
MANAGER_NOTIFIED: IconUserCircle,
|
||||
VISIT_SCHEDULED: IconCalendar,
|
||||
CSAT_RECEIVED: IconStar,
|
||||
CSAT_RATED: IconStar,
|
||||
}
|
||||
|
||||
const timelineLabels: Record<string, string> = {
|
||||
CREATED: "Criado",
|
||||
STATUS_CHANGED: "Status alterado",
|
||||
ASSIGNEE_CHANGED: "Responsável alterado",
|
||||
COMMENT_ADDED: "Comentário adicionado",
|
||||
COMMENT_EDITED: "Comentário editado",
|
||||
WORK_STARTED: "Atendimento iniciado",
|
||||
WORK_PAUSED: "Atendimento pausado",
|
||||
SUBJECT_CHANGED: "Assunto atualizado",
|
||||
SUMMARY_CHANGED: "Resumo atualizado",
|
||||
QUEUE_CHANGED: "Fila alterada",
|
||||
PRIORITY_CHANGED: "Prioridade alterada",
|
||||
ATTACHMENT_REMOVED: "Anexo removido",
|
||||
CATEGORY_CHANGED: "Categoria alterada",
|
||||
}
|
||||
const timelineLabels: Record<string, string> = TICKET_TIMELINE_LABELS
|
||||
|
||||
interface TicketTimelineProps {
|
||||
ticket: TicketWithDetails
|
||||
|
|
@ -122,6 +115,17 @@ export function TicketTimeline({ ticket }: TicketTimelineProps) {
|
|||
pauseReason?: string
|
||||
pauseReasonLabel?: string
|
||||
pauseNote?: string
|
||||
managerName?: string
|
||||
managerUserName?: string
|
||||
manager?: string
|
||||
managerId?: string
|
||||
managerUserId?: string
|
||||
scheduledFor?: number | string
|
||||
scheduledAt?: number | string
|
||||
score?: number
|
||||
rating?: number
|
||||
maxScore?: number
|
||||
max?: number
|
||||
}
|
||||
|
||||
let message: ReactNode = null
|
||||
|
|
@ -182,6 +186,42 @@ export function TicketTimeline({ ticket }: TicketTimelineProps) {
|
|||
message = "Categoria removida"
|
||||
}
|
||||
}
|
||||
if (entry.type === "MANAGER_NOTIFIED") {
|
||||
const manager =
|
||||
payload.managerName ??
|
||||
payload.managerUserName ??
|
||||
payload.manager ??
|
||||
payload.managerId ??
|
||||
payload.managerUserId
|
||||
message = manager ? `Gestor notificado: ${manager}` : "Gestor notificado"
|
||||
}
|
||||
if (entry.type === "VISIT_SCHEDULED") {
|
||||
const scheduledRaw = payload.scheduledFor ?? payload.scheduledAt
|
||||
let formatted: string | null = null
|
||||
if (typeof scheduledRaw === "number" || typeof scheduledRaw === "string") {
|
||||
const date = new Date(scheduledRaw)
|
||||
if (!Number.isNaN(date.getTime())) {
|
||||
formatted = format(date, "dd MMM yyyy HH:mm", { locale: ptBR })
|
||||
}
|
||||
}
|
||||
message = formatted ? `Visita agendada para ${formatted}` : "Visita agendada"
|
||||
}
|
||||
if (entry.type === "CSAT_RECEIVED") {
|
||||
message = "CSAT recebido"
|
||||
}
|
||||
if (entry.type === "CSAT_RATED") {
|
||||
const score = typeof payload.score === "number" ? payload.score : payload.rating
|
||||
const maxScore =
|
||||
typeof payload.maxScore === "number"
|
||||
? payload.maxScore
|
||||
: typeof payload.max === "number"
|
||||
? payload.max
|
||||
: undefined
|
||||
message =
|
||||
typeof score === "number"
|
||||
? `CSAT avaliado: ${score}${typeof maxScore === "number" ? `/${maxScore}` : ""}`
|
||||
: "CSAT avaliado"
|
||||
}
|
||||
if (!message) return null
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue