refactor: use Convex skip sentinel in query args
This commit is contained in:
parent
3de7eccaa8
commit
bd2f22d046
32 changed files with 167 additions and 157 deletions
|
|
@ -41,34 +41,34 @@ export function SlaReport() {
|
|||
const tenantId = session?.user.tenantId ?? DEFAULT_TENANT_ID
|
||||
const enabled = Boolean(isStaff && convexUserId)
|
||||
const data = useQuery(
|
||||
enabled ? api.reports.slaOverview : undefined,
|
||||
api.reports.slaOverview,
|
||||
enabled
|
||||
? ({ tenantId, viewerId: convexUserId as Id<"users">, range: timeRange, companyId: companyId === "all" ? undefined : (companyId as Id<"companies">) })
|
||||
: undefined
|
||||
: "skip"
|
||||
)
|
||||
const agents = useQuery(
|
||||
enabled ? api.reports.agentProductivity : undefined,
|
||||
api.reports.agentProductivity,
|
||||
enabled
|
||||
? ({ tenantId, viewerId: convexUserId as Id<"users">, range: timeRange, companyId: companyId === "all" ? undefined : (companyId as Id<"companies">) })
|
||||
: undefined
|
||||
: "skip"
|
||||
) as { rangeDays: number; items: Array<{ agentId: string; name: string | null; email: string | null; open: number; resolved: number; avgFirstResponseMinutes: number | null; avgResolutionMinutes: number | null; workedHours: number }> } | undefined
|
||||
|
||||
const openedResolved = useQuery(
|
||||
enabled ? api.reports.openedResolvedByDay : undefined,
|
||||
api.reports.openedResolvedByDay,
|
||||
enabled
|
||||
? ({ tenantId, viewerId: convexUserId as Id<"users">, range: timeRange, companyId: companyId === "all" ? undefined : (companyId as Id<"companies">) })
|
||||
: undefined
|
||||
: "skip"
|
||||
) as { rangeDays: number; series: Array<{ date: string; opened: number; resolved: number }> } | undefined
|
||||
|
||||
const channelsSeries = useQuery(
|
||||
enabled ? api.reports.ticketsByChannel : undefined,
|
||||
api.reports.ticketsByChannel,
|
||||
enabled
|
||||
? ({ tenantId, viewerId: convexUserId as Id<"users">, range: timeRange, companyId: companyId === "all" ? undefined : (companyId as Id<"companies">) })
|
||||
: undefined
|
||||
: "skip"
|
||||
) as { rangeDays: number; channels: string[]; points: Array<{ date: string; values: Record<string, number> }> } | undefined
|
||||
const companies = useQuery(
|
||||
enabled ? api.companies.list : undefined,
|
||||
enabled ? { tenantId, viewerId: convexUserId as Id<"users"> } : undefined
|
||||
api.companies.list,
|
||||
enabled ? { tenantId, viewerId: convexUserId as Id<"users"> } : "skip"
|
||||
) as Array<{ id: Id<"companies">; name: string }> | undefined
|
||||
|
||||
const queueTotal = useMemo(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue