feat: enhance tickets portal and admin flows

This commit is contained in:
Esdras Renan 2025-10-07 02:26:09 -03:00
parent 9cdd8763b4
commit c15f0a5b09
67 changed files with 1101 additions and 338 deletions

View file

@ -3,7 +3,6 @@
import { useMemo } from "react"
import { useQuery } from "convex/react"
import { IconInbox, IconAlertTriangle, IconFilter } from "@tabler/icons-react"
// @ts-expect-error Convex runtime API lacks TypeScript declarations
import { api } from "@/convex/_generated/api"
import type { Id } from "@/convex/_generated/dataModel"
import { useAuth } from "@/lib/auth-client"
@ -20,12 +19,11 @@ const PRIORITY_LABELS: Record<string, string> = {
}
const STATUS_LABELS: Record<string, string> = {
NEW: "Novo",
OPEN: "Em andamento",
PENDING: "Pendente",
ON_HOLD: "Em espera",
RESOLVED: "Resolvido",
CLOSED: "Encerrado",
PENDING: "Pendentes",
AWAITING_ATTENDANCE: "Aguardando atendimento",
PAUSED: "Pausados",
RESOLVED: "Resolvidos",
CLOSED: "Encerrados",
}
export function BacklogReport() {
@ -38,7 +36,7 @@ export function BacklogReport() {
const mostCriticalPriority = useMemo(() => {
if (!data) return null
const entries = Object.entries(data.priorityCounts)
const entries = Object.entries(data.priorityCounts) as Array<[string, number]>
if (entries.length === 0) return null
return entries.reduce((prev, current) => (current[1] > prev[1] ? current : prev))
}, [data])
@ -104,7 +102,7 @@ export function BacklogReport() {
</CardHeader>
<CardContent>
<div className="grid gap-4 md:grid-cols-2 xl:grid-cols-3">
{Object.entries(data.statusCounts).map(([status, total]) => (
{(Object.entries(data.statusCounts) as Array<[string, number]>).map(([status, total]) => (
<div key={status} className="rounded-xl border border-slate-200 p-4">
<p className="text-xs font-semibold uppercase tracking-wide text-neutral-500">
{STATUS_LABELS[status] ?? status}
@ -125,7 +123,7 @@ export function BacklogReport() {
</CardHeader>
<CardContent>
<div className="space-y-3">
{Object.entries(data.priorityCounts).map(([priority, total]) => (
{(Object.entries(data.priorityCounts) as Array<[string, number]>).map(([priority, total]) => (
<div key={priority} className="flex items-center justify-between rounded-xl border border-slate-200 px-4 py-3">
<span className="text-sm font-medium text-neutral-800">
{PRIORITY_LABELS[priority] ?? priority}
@ -153,7 +151,7 @@ export function BacklogReport() {
</p>
) : (
<ul className="space-y-3">
{data.queueCounts.map((queue) => (
{data.queueCounts.map((queue: { id: string; name: string; total: number }) => (
<li key={queue.id} className="flex items-center justify-between rounded-xl border border-slate-200 px-4 py-3">
<div className="flex flex-col">
<span className="text-sm font-medium text-neutral-900">{queue.name}</span>