feat: improve ticket export and navigation

This commit is contained in:
Esdras Renan 2025-10-13 00:08:18 -03:00
parent 0731c5d1ea
commit 7d6f3bea01
28 changed files with 1612 additions and 609 deletions

View file

@ -16,14 +16,16 @@ import { Button } from "@/components/ui/button"
import { PortalTicketCard } from "@/components/portal/portal-ticket-card"
export function PortalTicketList() {
const { convexUserId, session } = useAuth()
const { convexUserId, session, machineContext } = useAuth()
const viewerId = (convexUserId ?? machineContext?.assignedUserId ?? null) as Id<"users"> | null
const ticketsRaw = useQuery(
api.tickets.list,
convexUserId
viewerId
? {
tenantId: session?.user.tenantId ?? DEFAULT_TENANT_ID,
viewerId: convexUserId as Id<"users">,
viewerId,
limit: 100,
}
: "skip"
@ -34,7 +36,9 @@ export function PortalTicketList() {
return mapTicketsFromServerList((ticketsRaw as unknown[]) ?? [])
}, [ticketsRaw])
if (ticketsRaw === undefined) {
const isLoading = Boolean(viewerId && ticketsRaw === undefined)
if (isLoading) {
return (
<Card className="rounded-2xl border border-slate-200 bg-white shadow-sm">
<CardHeader className="flex items-center gap-2 px-5 py-5">
@ -48,7 +52,7 @@ export function PortalTicketList() {
)
}
if (!tickets.length) {
if (!viewerId || !tickets.length) {
return (
<Card className="rounded-2xl border border-slate-200 bg-white shadow-sm">
<CardHeader className="px-5 py-5">