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
|
|
@ -5,6 +5,25 @@ import type { Id } from "./_generated/dataModel";
|
|||
|
||||
import { requireAdmin, requireStaff } from "./rbac";
|
||||
|
||||
type TicketStatusNormalized = "PENDING" | "AWAITING_ATTENDANCE" | "PAUSED" | "RESOLVED" | "CLOSED";
|
||||
|
||||
const STATUS_NORMALIZE_MAP: Record<string, TicketStatusNormalized> = {
|
||||
NEW: "PENDING",
|
||||
PENDING: "PENDING",
|
||||
OPEN: "AWAITING_ATTENDANCE",
|
||||
AWAITING_ATTENDANCE: "AWAITING_ATTENDANCE",
|
||||
ON_HOLD: "PAUSED",
|
||||
PAUSED: "PAUSED",
|
||||
RESOLVED: "RESOLVED",
|
||||
CLOSED: "CLOSED",
|
||||
};
|
||||
|
||||
function normalizeStatus(status: string | null | undefined): TicketStatusNormalized {
|
||||
if (!status) return "PENDING";
|
||||
const normalized = STATUS_NORMALIZE_MAP[status.toUpperCase()];
|
||||
return normalized ?? "PENDING";
|
||||
}
|
||||
|
||||
const QUEUE_RENAME_LOOKUP: Record<string, string> = {
|
||||
"Suporte N1": "Chamados",
|
||||
"suporte-n1": "Chamados",
|
||||
|
|
@ -98,8 +117,14 @@ export const summary = query({
|
|||
.query("tickets")
|
||||
.withIndex("by_tenant_queue", (q) => q.eq("tenantId", tenantId).eq("queueId", qItem._id))
|
||||
.collect();
|
||||
const waiting = pending.filter((t) => t.status === "PENDING" || t.status === "ON_HOLD").length;
|
||||
const open = pending.filter((t) => t.status !== "RESOLVED" && t.status !== "CLOSED").length;
|
||||
const waiting = pending.filter((t) => {
|
||||
const status = normalizeStatus(t.status);
|
||||
return status === "PENDING" || status === "PAUSED";
|
||||
}).length;
|
||||
const open = pending.filter((t) => {
|
||||
const status = normalizeStatus(t.status);
|
||||
return status !== "RESOLVED" && status !== "CLOSED";
|
||||
}).length;
|
||||
const breached = 0;
|
||||
return { id: qItem._id, name: renameQueueString(qItem.name), pending: open, waiting, breached };
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue