Fix Excel export XML order and gate time adjustments on close
This commit is contained in:
parent
be9816a3a8
commit
9d569d987d
4 changed files with 379 additions and 254 deletions
|
|
@ -59,6 +59,8 @@ import Link from "next/link"
|
|||
import { useRouter } from "next/navigation"
|
||||
import { useAuth } from "@/lib/auth-client"
|
||||
import type { Id } from "@/convex/_generated/dataModel"
|
||||
import { TicketStatusBadge } from "@/components/tickets/status-badge"
|
||||
import type { TicketPriority, TicketStatus } from "@/lib/schemas/ticket"
|
||||
|
||||
type MachineMetrics = Record<string, unknown> | null
|
||||
|
||||
|
|
@ -92,8 +94,8 @@ type MachineTicketSummary = {
|
|||
id: string
|
||||
reference: number
|
||||
subject: string
|
||||
status: string
|
||||
priority: string
|
||||
status: TicketStatus
|
||||
priority: TicketPriority
|
||||
updatedAt: number
|
||||
createdAt: number
|
||||
machine: { id: string | null; hostname: string | null } | null
|
||||
|
|
@ -870,11 +872,24 @@ const statusLabels: Record<string, string> = {
|
|||
unknown: "Desconhecida",
|
||||
}
|
||||
|
||||
const TICKET_STATUS_LABELS: Record<string, string> = {
|
||||
PENDING: "Pendente",
|
||||
AWAITING_ATTENDANCE: "Em andamento",
|
||||
PAUSED: "Pausado",
|
||||
RESOLVED: "Resolvido",
|
||||
const TICKET_PRIORITY_META: Record<string, { label: string; badgeClass: string }> = {
|
||||
LOW: { label: "Baixa", badgeClass: "border border-slate-200 bg-slate-100 text-slate-600" },
|
||||
MEDIUM: { label: "Média", badgeClass: "border border-sky-200 bg-sky-100 text-sky-700" },
|
||||
HIGH: { label: "Alta", badgeClass: "border border-amber-200 bg-amber-50 text-amber-700" },
|
||||
URGENT: { label: "Urgente", badgeClass: "border border-rose-200 bg-rose-50 text-rose-700" },
|
||||
}
|
||||
|
||||
function getTicketPriorityMeta(priority: TicketPriority | string | null | undefined) {
|
||||
if (!priority) {
|
||||
return { label: "Sem prioridade", badgeClass: "border border-slate-200 bg-slate-100 text-neutral-600" }
|
||||
}
|
||||
const normalized = priority.toUpperCase()
|
||||
return (
|
||||
TICKET_PRIORITY_META[normalized] ?? {
|
||||
label: priority.charAt(0).toUpperCase() + priority.slice(1).toLowerCase(),
|
||||
badgeClass: "border border-slate-200 bg-slate-100 text-neutral-600",
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const statusClasses: Record<string, string> = {
|
||||
|
|
@ -2347,29 +2362,32 @@ export function MachineDetails({ machine }: MachineDetailsProps) {
|
|||
<p className="text-xs text-[color:var(--accent-foreground)]/80">Nenhum chamado em aberto registrado diretamente por esta máquina.</p>
|
||||
) : (
|
||||
<ul className="space-y-2">
|
||||
{machineTickets.map((ticket) => (
|
||||
<li
|
||||
key={ticket.id}
|
||||
className="flex flex-wrap items-center justify-between gap-3 rounded-xl border border-[color:var(--accent)] bg-white px-3 py-2 text-sm shadow-sm"
|
||||
>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="truncate font-medium text-neutral-900">
|
||||
#{ticket.reference} · {ticket.subject}
|
||||
</p>
|
||||
<p className="text-xs text-neutral-500">
|
||||
Atualizado {formatRelativeTime(new Date(ticket.updatedAt))}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Badge variant="outline" className="border-slate-200 text-[11px] uppercase text-neutral-600">
|
||||
{ticket.priority}
|
||||
</Badge>
|
||||
<Badge className="bg-indigo-600 text-[11px] uppercase tracking-wide text-white">
|
||||
{TICKET_STATUS_LABELS[ticket.status] ?? ticket.status}
|
||||
</Badge>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
{machineTickets.map((ticket) => {
|
||||
const priorityMeta = getTicketPriorityMeta(ticket.priority)
|
||||
return (
|
||||
<li key={ticket.id}>
|
||||
<Link
|
||||
href={`/tickets/${ticket.id}`}
|
||||
className="flex flex-wrap items-center justify-between gap-3 rounded-xl border border-[color:var(--accent)] bg-white px-3 py-2 text-sm shadow-sm transition hover:-translate-y-0.5 hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--accent)] focus-visible:ring-offset-2"
|
||||
>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="truncate font-medium text-neutral-900">
|
||||
#{ticket.reference} · {ticket.subject}
|
||||
</p>
|
||||
<p className="text-xs text-neutral-500">
|
||||
Atualizado {formatRelativeTime(new Date(ticket.updatedAt))}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Badge className={cn("rounded-full px-3 py-1 text-xs font-semibold", priorityMeta.badgeClass)}>
|
||||
{priorityMeta.label}
|
||||
</Badge>
|
||||
<TicketStatusBadge status={ticket.status} className="h-7 px-3 text-xs font-semibold" />
|
||||
</div>
|
||||
</Link>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue