feat(reports): add date range filters and extend machine reports
This commit is contained in:
parent
82875a2252
commit
5b22065609
11 changed files with 742 additions and 290 deletions
|
|
@ -26,13 +26,22 @@ export function CsatReport() {
|
|||
const [companyId, setCompanyId] = usePersistentCompanyFilter("all")
|
||||
const [timeRange, setTimeRange] = useState<string>("90d")
|
||||
const [schedulerOpen, setSchedulerOpen] = useState(false)
|
||||
const [dateFrom, setDateFrom] = useState<string | null>(null)
|
||||
const [dateTo, setDateTo] = useState<string | null>(null)
|
||||
const { session, convexUserId, isStaff, isAdmin } = useAuth()
|
||||
const tenantId = session?.user.tenantId ?? DEFAULT_TENANT_ID
|
||||
const enabled = Boolean(isStaff && convexUserId)
|
||||
const data = useQuery(
|
||||
api.reports.csatOverview,
|
||||
enabled
|
||||
? ({ tenantId, viewerId: convexUserId as Id<"users">, range: timeRange, companyId: companyId === "all" ? undefined : (companyId as Id<"companies">) })
|
||||
? ({
|
||||
tenantId,
|
||||
viewerId: convexUserId as Id<"users">,
|
||||
range: timeRange,
|
||||
companyId: companyId === "all" ? undefined : (companyId as Id<"companies">),
|
||||
dateFrom,
|
||||
dateTo,
|
||||
})
|
||||
: "skip"
|
||||
)
|
||||
const companies = useQuery(
|
||||
|
|
@ -94,7 +103,17 @@ export function CsatReport() {
|
|||
onCompanyChange={(value) => handleCompanyChange(value)}
|
||||
companyOptions={comboboxOptions}
|
||||
timeRange={timeRange as "90d" | "30d" | "7d"}
|
||||
onTimeRangeChange={(value) => setTimeRange(value)}
|
||||
onTimeRangeChange={(value) => {
|
||||
setTimeRange(value)
|
||||
setDateFrom(null)
|
||||
setDateTo(null)
|
||||
}}
|
||||
dateFrom={dateFrom}
|
||||
dateTo={dateTo}
|
||||
onDateRangeChange={({ from, to }) => {
|
||||
setDateFrom(from)
|
||||
setDateTo(to)
|
||||
}}
|
||||
exportHref={`/api/reports/csat.xlsx?range=${timeRange}${
|
||||
companyId !== "all" ? `&companyId=${companyId}` : ""
|
||||
}`}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue