feat: add queue summary widget and layout fixes

This commit is contained in:
Esdras Renan 2025-11-06 17:05:31 -03:00
parent f7976e2c39
commit a542846313
12 changed files with 350 additions and 45 deletions

View file

@ -16,13 +16,14 @@ interface TicketQueueSummaryProps {
export function TicketQueueSummaryCards({ queues }: TicketQueueSummaryProps) {
const { convexUserId, isStaff } = useAuth()
const enabled = Boolean(isStaff && convexUserId)
const shouldFetch = Boolean(!queues && enabled)
const fromServer = useQuery(
api.queues.summary,
enabled ? { tenantId: DEFAULT_TENANT_ID, viewerId: convexUserId as Id<"users"> } : "skip"
shouldFetch ? { tenantId: DEFAULT_TENANT_ID, viewerId: convexUserId as Id<"users"> } : "skip"
) as TicketQueueSummary[] | undefined
const data: TicketQueueSummary[] = queues ?? fromServer ?? []
if (!queues && fromServer === undefined) {
if (!queues && shouldFetch && fromServer === undefined) {
return (
<div className="grid gap-4 md:grid-cols-2 xl:grid-cols-3">
{Array.from({ length: 3 }).map((_, index) => (