Fix report filters and zod resolver
This commit is contained in:
parent
5b22065609
commit
06fdb54480
12 changed files with 79 additions and 26 deletions
|
|
@ -79,6 +79,12 @@ export function HoursReport() {
|
|||
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.hoursByClient,
|
||||
enabled && groupBy === "company"
|
||||
|
|
@ -86,8 +92,7 @@ export function HoursReport() {
|
|||
tenantId,
|
||||
viewerId: convexUserId as Id<"users">,
|
||||
range: timeRange === "365d" || timeRange === "all" ? "90d" : timeRange,
|
||||
dateFrom,
|
||||
dateTo,
|
||||
...dateRangeFilters,
|
||||
}
|
||||
: "skip"
|
||||
) as { rangeDays: number; items: HoursItem[] } | undefined
|
||||
|
|
@ -100,8 +105,7 @@ export function HoursReport() {
|
|||
viewerId: convexUserId as Id<"users">,
|
||||
range: timeRange,
|
||||
companyId: companyId === "all" ? undefined : (companyId as Id<"companies">),
|
||||
dateFrom,
|
||||
dateTo,
|
||||
...dateRangeFilters,
|
||||
}
|
||||
: "skip"
|
||||
) as HoursByMachineResponse | undefined
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue