Fix report filters and zod resolver
This commit is contained in:
parent
5b22065609
commit
06fdb54480
12 changed files with 79 additions and 26 deletions
|
|
@ -57,6 +57,12 @@ export function MachineCategoryReport() {
|
|||
|
||||
const canView = Boolean(isStaff)
|
||||
const enabled = Boolean(canView && 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.ticketsByMachineAndCategory,
|
||||
|
|
@ -66,8 +72,7 @@ export function MachineCategoryReport() {
|
|||
viewerId: convexUserId as Id<"users">,
|
||||
range: timeRange,
|
||||
companyId: companyId === "all" ? undefined : (companyId as Id<"companies">),
|
||||
dateFrom,
|
||||
dateTo,
|
||||
...dateRangeFilters,
|
||||
} as const)
|
||||
: "skip"
|
||||
) as MachineCategoryReportData | undefined
|
||||
|
|
@ -163,8 +168,7 @@ export function MachineCategoryReport() {
|
|||
companyId: companyId === "all" ? undefined : (companyId as Id<"companies">),
|
||||
machineId: selectedMachineId !== "all" ? (selectedMachineId as Id<"machines">) : undefined,
|
||||
userId: selectedUserId !== "all" ? (selectedUserId as Id<"users">) : undefined,
|
||||
dateFrom,
|
||||
dateTo,
|
||||
...dateRangeFilters,
|
||||
} as const)
|
||||
: "skip"
|
||||
) as MachineHoursResponse | undefined
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue