Fix report filters and zod resolver
This commit is contained in:
parent
5b22065609
commit
06fdb54480
12 changed files with 79 additions and 26 deletions
|
|
@ -9,7 +9,7 @@ import { DEFAULT_TENANT_ID } from "@/lib/constants"
|
|||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
import { Skeleton } from "@/components/ui/skeleton"
|
||||
import { Badge } from "@/components/ui/badge"
|
||||
import { useState } from "react"
|
||||
import { useMemo, useState } from "react"
|
||||
import { Bar, BarChart, CartesianGrid, XAxis } from "recharts"
|
||||
import { ChartContainer, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart"
|
||||
import { SearchableCombobox, type SearchableComboboxOption } from "@/components/ui/searchable-combobox"
|
||||
|
|
@ -31,6 +31,12 @@ export function CsatReport() {
|
|||
const { session, convexUserId, isStaff, isAdmin } = useAuth()
|
||||
const tenantId = session?.user.tenantId ?? DEFAULT_TENANT_ID
|
||||
const enabled = Boolean(isStaff && convexUserId)
|
||||
const dateRangeFilters = useMemo(() => {
|
||||
const filters: { dateFrom?: string; dateTo?: string } = {}
|
||||
if (dateFrom) filters.dateFrom = dateFrom
|
||||
if (dateTo) filters.dateTo = dateTo
|
||||
return filters
|
||||
}, [dateFrom, dateTo])
|
||||
const data = useQuery(
|
||||
api.reports.csatOverview,
|
||||
enabled
|
||||
|
|
@ -39,8 +45,7 @@ export function CsatReport() {
|
|||
viewerId: convexUserId as Id<"users">,
|
||||
range: timeRange,
|
||||
companyId: companyId === "all" ? undefined : (companyId as Id<"companies">),
|
||||
dateFrom,
|
||||
dateTo,
|
||||
...dateRangeFilters,
|
||||
})
|
||||
: "skip"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue