feat: enhance tickets portal and admin flows
This commit is contained in:
parent
9cdd8763b4
commit
c15f0a5b09
67 changed files with 1101 additions and 338 deletions
|
|
@ -1,5 +1,24 @@
|
|||
import { z } from "zod";
|
||||
import { ticketSchema, ticketWithDetailsSchema } from "@/lib/schemas/ticket";
|
||||
import { ticketSchema, ticketStatusSchema, ticketWithDetailsSchema } from "@/lib/schemas/ticket";
|
||||
|
||||
type NormalizedTicketStatus = z.infer<typeof ticketStatusSchema>;
|
||||
|
||||
const STATUS_MAP: Record<string, NormalizedTicketStatus> = {
|
||||
NEW: "PENDING",
|
||||
PENDING: "PENDING",
|
||||
OPEN: "AWAITING_ATTENDANCE",
|
||||
AWAITING_ATTENDANCE: "AWAITING_ATTENDANCE",
|
||||
ON_HOLD: "PAUSED",
|
||||
PAUSED: "PAUSED",
|
||||
RESOLVED: "RESOLVED",
|
||||
CLOSED: "CLOSED",
|
||||
};
|
||||
|
||||
function normalizeTicketStatus(status: unknown): NormalizedTicketStatus {
|
||||
if (typeof status !== "string") return "PENDING";
|
||||
const normalized = STATUS_MAP[status.toUpperCase()];
|
||||
return normalized ?? "PENDING";
|
||||
}
|
||||
|
||||
// Server shapes: datas como number (epoch ms) e alguns nullables
|
||||
// Relaxamos email/urls no shape do servidor para evitar que payloads parciais quebrem o app.
|
||||
|
|
@ -104,6 +123,7 @@ export function mapTicketFromServer(input: unknown) {
|
|||
const s = serverTicketSchema.parse(input);
|
||||
const ui = {
|
||||
...s,
|
||||
status: normalizeTicketStatus(s.status),
|
||||
category: s.category ?? undefined,
|
||||
subcategory: s.subcategory ?? undefined,
|
||||
lastTimelineEntry: s.lastTimelineEntry ?? undefined,
|
||||
|
|
@ -154,6 +174,7 @@ export function mapTicketWithDetailsFromServer(input: unknown) {
|
|||
const ui = {
|
||||
...s,
|
||||
customFields,
|
||||
status: normalizeTicketStatus(s.status),
|
||||
category: s.category ?? undefined,
|
||||
subcategory: s.subcategory ?? undefined,
|
||||
lastTimelineEntry: s.lastTimelineEntry ?? undefined,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue