Fix report filters and zod resolver

This commit is contained in:
Esdras Renan 2025-11-14 01:25:28 -03:00
parent 5b22065609
commit 06fdb54480
12 changed files with 79 additions and 26 deletions

View file

@ -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