"use client"; import { useQuery } from "convex/react"; import { api } from "@/convex/_generated/api"; import { DEFAULT_TENANT_ID } from "@/lib/constants"; import { mapTicketWithDetailsFromServer } from "@/lib/mappers/ticket"; import type { Id } from "@/convex/_generated/dataModel"; import type { TicketWithDetails } from "@/lib/schemas/ticket"; import { Card, CardContent } from "@/components/ui/card"; import { Skeleton } from "@/components/ui/skeleton"; import { TicketComments } from "@/components/tickets/ticket-comments.rich"; import { TicketDetailsPanel } from "@/components/tickets/ticket-details-panel"; import { TicketSummaryHeader } from "@/components/tickets/ticket-summary-header"; import { TicketTimeline } from "@/components/tickets/ticket-timeline"; import { useAuth } from "@/lib/auth-client"; export function TicketDetailView({ id }: { id: string }) { const { convexUserId } = useAuth(); const canLoadTicket = Boolean(convexUserId); const t = useQuery( api.tickets.getById, canLoadTicket ? { tenantId: DEFAULT_TENANT_ID, id: id as Id<"tickets">, viewerId: convexUserId as Id<"users">, } : "skip" ); const isLoading = !convexUserId || t === undefined; if (isLoading) { return (
{Array.from({ length: 3 }).map((_, i) => (
))}
{Array.from({ length: 5 }).map((_, i) => ())}
); } if (!t) { return (

Ticket não encontrado

O ticket solicitado não existe ou você não tem permissão para visualizá-lo.

); } const ticket = mapTicketWithDetailsFromServer(t as unknown) as TicketWithDetails | null; if (!ticket) { return (

Ticket não encontrado

O ticket solicitado não existe ou você não tem permissão para visualizá-lo.

); } return (
); }