19 lines
707 B
TypeScript
19 lines
707 B
TypeScript
|
|
import { useQuery } from '@tanstack/react-query'
|
||
|
|
import { getApiData, getBlob } from '../../services/http/client'
|
||
|
|
import type { DashboardOverview } from './types'
|
||
|
|
|
||
|
|
export const dashboardQueryKeys = {
|
||
|
|
overview: (date?: string) => ['dashboard', 'overview', date ?? 'default'] as const,
|
||
|
|
}
|
||
|
|
|
||
|
|
export function useDashboardOverview(date?: string) {
|
||
|
|
return useQuery({
|
||
|
|
queryKey: dashboardQueryKeys.overview(date),
|
||
|
|
queryFn: () => getApiData<DashboardOverview>(date ? `/dashboard/overview?date=${date}` : '/dashboard/overview'),
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
export function downloadDailyReportArchive(date?: string) {
|
||
|
|
return getBlob(date ? `/dashboard/daily-report/archive?date=${date}` : '/dashboard/daily-report/archive')
|
||
|
|
}
|