aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/src/apis/hooks/histories.ts
blob: 6368d11db23b6f76836a8ab2a0342f1f63c0f696 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { useQuery } from "@tanstack/react-query";
import { QueryKeys } from "@/apis/queries/keys";
import api from "@/apis/raw";

export function useHistoryStats(
  time: History.TimeFrameOptions,
  action: History.ActionOptions | null,
  provider: System.Provider | null,
  language: Language.Info | null,
) {
  return useQuery({
    queryKey: [
      QueryKeys.System,
      QueryKeys.History,
      { time, action, provider, language },
    ],

    queryFn: () =>
      api.history.stats(
        time,
        action ?? undefined,
        provider?.name,
        language?.code2,
      ),
  });
}