mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-12 02:02:15 +01:00
refactor timeentries queries and mutations, improve activitygraph, add dashboard reporting table
This commit is contained in:
21
resources/js/utils/useTimeEntriesReportQuery.ts
Normal file
21
resources/js/utils/useTimeEntriesReportQuery.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { useQuery } from '@tanstack/vue-query';
|
||||
import { api, type TimeEntryResponse } from '@/packages/api/src';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
import { computed, type Ref, type ComputedRef, unref } from 'vue';
|
||||
|
||||
export function useTimeEntriesReportQuery(
|
||||
filterParams: Ref<Record<string, unknown>> | ComputedRef<Record<string, unknown>>
|
||||
) {
|
||||
return useQuery<TimeEntryResponse>({
|
||||
queryKey: computed(() => ['timeEntries', 'detailed-report', unref(filterParams)]),
|
||||
enabled: computed(() => !!getCurrentOrganizationId()),
|
||||
queryFn: () =>
|
||||
api.getTimeEntries({
|
||||
params: {
|
||||
organization: getCurrentOrganizationId() || '',
|
||||
},
|
||||
queries: { ...unref(filterParams) },
|
||||
}),
|
||||
staleTime: 1000 * 30, // 30 seconds
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user