fix: allow nullable company filters in report exporters
This commit is contained in:
parent
d8515d08e1
commit
8cc513c532
1 changed files with 11 additions and 10 deletions
|
|
@ -7,6 +7,7 @@ import type { Id } from "@/convex/_generated/dataModel"
|
|||
import { env } from "@/lib/env"
|
||||
import { buildXlsxWorkbook } from "@/lib/xlsx"
|
||||
import { REPORT_EXPORT_DEFINITIONS, type ReportExportKey } from "@/lib/report-definitions"
|
||||
export type { ReportExportKey }
|
||||
|
||||
type ViewerIdentity = {
|
||||
tenantId: string
|
||||
|
|
@ -53,7 +54,7 @@ export type ReportArtifact = {
|
|||
|
||||
type BaseOptions = {
|
||||
range?: string
|
||||
companyId?: string
|
||||
companyId?: string | null
|
||||
}
|
||||
|
||||
export async function buildHoursWorkbook(
|
||||
|
|
@ -123,7 +124,7 @@ export async function buildHoursWorkbook(
|
|||
options.companyId ? `-${options.companyId}` : ""
|
||||
}${options.search ? `-${encodeURIComponent(options.search)}` : ""}.xlsx`
|
||||
|
||||
const arrayBuffer = workbook.buffer.slice(workbook.byteOffset, workbook.byteOffset + workbook.byteLength)
|
||||
const arrayBuffer = workbook.buffer.slice(workbook.byteOffset, workbook.byteOffset + workbook.byteLength) as ArrayBuffer
|
||||
return {
|
||||
fileName,
|
||||
mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
|
|
@ -139,7 +140,7 @@ export async function buildBacklogWorkbook(
|
|||
tenantId: ctx.tenantId,
|
||||
viewerId: ctx.viewerId,
|
||||
range: options.range,
|
||||
companyId: options.companyId as Id<"companies"> | undefined,
|
||||
companyId: (options.companyId ?? undefined) as Id<"companies"> | undefined,
|
||||
})
|
||||
|
||||
const summaryRows: Array<Array<unknown>> = [
|
||||
|
|
@ -186,7 +187,7 @@ export async function buildBacklogWorkbook(
|
|||
options.companyId ? `-${options.companyId}` : ""
|
||||
}.xlsx`
|
||||
|
||||
const arrayBuffer = workbook.buffer.slice(workbook.byteOffset, workbook.byteOffset + workbook.byteLength)
|
||||
const arrayBuffer = workbook.buffer.slice(workbook.byteOffset, workbook.byteOffset + workbook.byteLength) as ArrayBuffer
|
||||
return {
|
||||
fileName,
|
||||
mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
|
|
@ -202,7 +203,7 @@ export async function buildSlaWorkbook(
|
|||
tenantId: ctx.tenantId,
|
||||
viewerId: ctx.viewerId,
|
||||
range: options.range,
|
||||
companyId: options.companyId as Id<"companies"> | undefined,
|
||||
companyId: (options.companyId ?? undefined) as Id<"companies"> | undefined,
|
||||
})
|
||||
|
||||
const summaryRows: Array<Array<unknown>> = [
|
||||
|
|
@ -234,7 +235,7 @@ export async function buildSlaWorkbook(
|
|||
options.companyId ? `-${options.companyId}` : ""
|
||||
}.xlsx`
|
||||
|
||||
const arrayBuffer = workbook.buffer.slice(workbook.byteOffset, workbook.byteOffset + workbook.byteLength)
|
||||
const arrayBuffer = workbook.buffer.slice(workbook.byteOffset, workbook.byteOffset + workbook.byteLength) as ArrayBuffer
|
||||
return {
|
||||
fileName,
|
||||
mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
|
|
@ -250,7 +251,7 @@ export async function buildCsatWorkbook(
|
|||
tenantId: ctx.tenantId,
|
||||
viewerId: ctx.viewerId,
|
||||
range: options.range,
|
||||
companyId: options.companyId as Id<"companies"> | undefined,
|
||||
companyId: (options.companyId ?? undefined) as Id<"companies"> | undefined,
|
||||
})
|
||||
|
||||
const summaryRows: Array<Array<unknown>> = [
|
||||
|
|
@ -286,7 +287,7 @@ export async function buildCsatWorkbook(
|
|||
options.companyId ? `-${options.companyId}` : ""
|
||||
}.xlsx`
|
||||
|
||||
const arrayBuffer = workbook.buffer.slice(workbook.byteOffset, workbook.byteOffset + workbook.byteLength)
|
||||
const arrayBuffer = workbook.buffer.slice(workbook.byteOffset, workbook.byteOffset + workbook.byteLength) as ArrayBuffer
|
||||
return {
|
||||
fileName,
|
||||
mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
|
|
@ -302,7 +303,7 @@ export async function buildTicketsByChannelWorkbook(
|
|||
tenantId: ctx.tenantId,
|
||||
viewerId: ctx.viewerId,
|
||||
range: options.range,
|
||||
companyId: options.companyId as Id<"companies"> | undefined,
|
||||
companyId: (options.companyId ?? undefined) as Id<"companies"> | undefined,
|
||||
})
|
||||
|
||||
const CHANNEL_PT: Record<string, string> = {
|
||||
|
|
@ -342,7 +343,7 @@ export async function buildTicketsByChannelWorkbook(
|
|||
options.companyId ? `-${options.companyId}` : ""
|
||||
}.xlsx`
|
||||
|
||||
const arrayBuffer = workbook.buffer.slice(workbook.byteOffset, workbook.byteOffset + workbook.byteLength)
|
||||
const arrayBuffer = workbook.buffer.slice(workbook.byteOffset, workbook.byteOffset + workbook.byteLength) as ArrayBuffer
|
||||
return {
|
||||
fileName,
|
||||
mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue